First attempt at hello world basically
Browse files
app.py
CHANGED
@@ -3,6 +3,10 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# (Keep Constants as is)
|
8 |
# --- Constants ---
|
@@ -12,12 +16,14 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
13 |
class BasicAgent:
|
14 |
def __init__(self):
|
|
|
|
|
15 |
print("BasicAgent initialized.")
|
|
|
16 |
def __call__(self, question: str) -> str:
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
return fixed_answer
|
21 |
|
22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
23 |
"""
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
from llama_index.tools.duckduckgo import DuckDuckGoSearchToolSpec
|
7 |
+
from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI
|
8 |
+
from llama_index.core.agent.workflow import AgentWorkflow
|
9 |
+
|
10 |
|
11 |
# (Keep Constants as is)
|
12 |
# --- Constants ---
|
|
|
16 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
17 |
class BasicAgent:
|
18 |
def __init__(self):
|
19 |
+
llm = HuggingFaceInferenceAPI(model_name="Qwen/Qwen2.5-Coder-32B-Instruct")
|
20 |
+
search_tool = DuckDuckGoSearchToolSpec()
|
21 |
print("BasicAgent initialized.")
|
22 |
+
|
23 |
def __call__(self, question: str) -> str:
|
24 |
+
agent = AgentWorkflow.from_tools_or_functions([search_tool], llm=llm)
|
25 |
+
response = await agent.run(question)
|
26 |
+
return response
|
|
|
27 |
|
28 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
29 |
"""
|