Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,6 +17,7 @@ from smolagents import (
|
|
| 17 |
)
|
| 18 |
|
| 19 |
class BasicAgent:
|
|
|
|
| 20 |
def __init__(self):
|
| 21 |
|
| 22 |
print("Initializing Smart Agent...")
|
|
@@ -25,9 +26,9 @@ class BasicAgent:
|
|
| 25 |
search_tool = DuckDuckGoSearchTool()
|
| 26 |
|
| 27 |
# Free Hugging Face model
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
)
|
| 31 |
|
| 32 |
# Main Agent
|
| 33 |
self.agent = CodeAgent(
|
|
@@ -42,22 +43,22 @@ class BasicAgent:
|
|
| 42 |
print(f"Question: {question}")
|
| 43 |
|
| 44 |
prompt = f"""
|
| 45 |
-
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
|
| 57 |
try:
|
|
|
|
| 58 |
response = self.agent.run(prompt)
|
| 59 |
|
| 60 |
-
# convert to clean string
|
| 61 |
answer = str(response).strip()
|
| 62 |
|
| 63 |
print(f"Agent answer: {answer}")
|
|
@@ -65,6 +66,7 @@ class BasicAgent:
|
|
| 65 |
return answer
|
| 66 |
|
| 67 |
except Exception as e:
|
|
|
|
| 68 |
print(f"Error: {e}")
|
| 69 |
|
| 70 |
return "Error"
|
|
|
|
| 17 |
)
|
| 18 |
|
| 19 |
class BasicAgent:
|
| 20 |
+
|
| 21 |
def __init__(self):
|
| 22 |
|
| 23 |
print("Initializing Smart Agent...")
|
|
|
|
| 26 |
search_tool = DuckDuckGoSearchTool()
|
| 27 |
|
| 28 |
# Free Hugging Face model
|
| 29 |
+
model = InferenceClientModel(
|
| 30 |
+
model_id="meta-llama/Llama-3.1-8B-Instruct"
|
| 31 |
+
)
|
| 32 |
|
| 33 |
# Main Agent
|
| 34 |
self.agent = CodeAgent(
|
|
|
|
| 43 |
print(f"Question: {question}")
|
| 44 |
|
| 45 |
prompt = f"""
|
| 46 |
+
Answer the following question.
|
| 47 |
|
| 48 |
+
IMPORTANT:
|
| 49 |
+
- Return ONLY the final answer
|
| 50 |
+
- Do NOT explain
|
| 51 |
+
- Do NOT write FINAL ANSWER
|
| 52 |
+
- Keep the answer short and exact
|
| 53 |
|
| 54 |
+
Question:
|
| 55 |
+
{question}
|
| 56 |
+
"""
|
| 57 |
|
| 58 |
try:
|
| 59 |
+
|
| 60 |
response = self.agent.run(prompt)
|
| 61 |
|
|
|
|
| 62 |
answer = str(response).strip()
|
| 63 |
|
| 64 |
print(f"Agent answer: {answer}")
|
|
|
|
| 66 |
return answer
|
| 67 |
|
| 68 |
except Exception as e:
|
| 69 |
+
|
| 70 |
print(f"Error: {e}")
|
| 71 |
|
| 72 |
return "Error"
|