Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
-
from smolagents import
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
@@ -19,26 +19,21 @@ If you are asked for a comma separated list, apply the above rules depending of
|
|
| 19 |
class BasicAgent:
|
| 20 |
def __init__(self):
|
| 21 |
print("BasicAgent initialized.")
|
| 22 |
-
self.model =
|
| 23 |
-
model_id="
|
| 24 |
-
|
| 25 |
)
|
| 26 |
self.agent = CodeAgent(
|
| 27 |
tools=[DuckDuckGoSearchTool()],
|
| 28 |
-
model=self.model
|
|
|
|
| 29 |
)
|
| 30 |
def __call__(self, question: str) -> str:
|
| 31 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 32 |
full_question = f"{SYSTEM_PROMPT}\n\nQuestion: {question}"
|
| 33 |
raw_answer = self.agent.run(full_question)
|
| 34 |
|
| 35 |
-
|
| 36 |
-
raw_answer = str(raw_answer)
|
| 37 |
-
if "FINAL ANSWER:" in raw_answer:
|
| 38 |
-
answer = raw_answer.split("FINAL ANSWER:")[-1].strip()
|
| 39 |
-
else:
|
| 40 |
-
answer = raw_answer.strip()
|
| 41 |
-
|
| 42 |
print(f"Agent returning answer: {answer}")
|
| 43 |
return answer
|
| 44 |
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from smolagents import CodeAegnt,LiteLLMModel, DuckDuckGoSearchTool
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
|
| 19 |
class BasicAgent:
|
| 20 |
def __init__(self):
|
| 21 |
print("BasicAgent initialized.")
|
| 22 |
+
self.model = LiteLLMModel(
|
| 23 |
+
model_id="groq/llama-3.3-70b-versatile",
|
| 24 |
+
api_key=os.getenv("GROQ_API_KEY")
|
| 25 |
)
|
| 26 |
self.agent = CodeAgent(
|
| 27 |
tools=[DuckDuckGoSearchTool()],
|
| 28 |
+
model=self.model,
|
| 29 |
+
max_steps=8
|
| 30 |
)
|
| 31 |
def __call__(self, question: str) -> str:
|
| 32 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 33 |
full_question = f"{SYSTEM_PROMPT}\n\nQuestion: {question}"
|
| 34 |
raw_answer = self.agent.run(full_question)
|
| 35 |
|
| 36 |
+
answer = raw_answer.split("FINAL ANSWER:")[-1].strip() if "FINAL ANSWER:" in raw_answer else raw_answer.strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
print(f"Agent returning answer: {answer}")
|
| 38 |
return answer
|
| 39 |
|