Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
|
|
|
|
6 |
|
7 |
# (Keep Constants as is)
|
8 |
# --- Constants ---
|
@@ -12,10 +14,31 @@ 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
def __call__(self, question: str) -> str:
|
17 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
18 |
-
fixed_answer =
|
|
|
19 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
20 |
return fixed_answer
|
21 |
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
from smolagents import HfApiModel,CodeAgent,PythonInterpreterTool, UserInputTool, FinalAnswerTool, DuckDuckGoSearchTool, WikipediaSearchTool, WolframAlphaTool, VisitWebpageTool, SpeechToTextTool
|
7 |
+
|
8 |
|
9 |
# (Keep Constants as is)
|
10 |
# --- Constants ---
|
|
|
14 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
15 |
class BasicAgent:
|
16 |
def __init__(self):
|
17 |
+
|
18 |
+
model = HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct", provider="together")
|
19 |
+
self.agent = CodeAgent(
|
20 |
+
model=model,
|
21 |
+
tools=[
|
22 |
+
PythonInterpreterTool(),
|
23 |
+
UserInputTool(),
|
24 |
+
FinalAnswerTool(),
|
25 |
+
DuckDuckGoSearchTool(),
|
26 |
+
WikipediaSearchTool(),
|
27 |
+
WolframAlphaTool(),
|
28 |
+
VisitWebpageTool(),
|
29 |
+
SpeechToTextTool()
|
30 |
+
],
|
31 |
+
max_tokens=2000,
|
32 |
+
temperature=0.5,
|
33 |
+
top_p=0.9,
|
34 |
+
top_k=50,
|
35 |
+
frequency_penalty=0.5,
|
36 |
+
presence_penalty=0.5,
|
37 |
+
)
|
38 |
def __call__(self, question: str) -> str:
|
39 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
40 |
+
fixed_answer = self.agent.run(question)
|
41 |
+
# Here you can add any post-processing to the answer if needed
|
42 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
43 |
return fixed_answer
|
44 |
|