Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,7 +37,7 @@ class BasicAgent:
|
|
| 37 |
self.agent = CodeAgent(
|
| 38 |
tools=[search_tool],
|
| 39 |
model=self.model,
|
| 40 |
-
max_steps=
|
| 41 |
verbosity_level=1
|
| 42 |
)
|
| 43 |
|
|
@@ -46,12 +46,12 @@ class BasicAgent:
|
|
| 46 |
|
| 47 |
prompt = f"""
|
| 48 |
IMPORTANT INSTRUCTIONS:
|
| 49 |
-
1. Use
|
| 50 |
-
2.
|
| 51 |
-
3. The final
|
| 52 |
-
-
|
| 53 |
-
-
|
| 54 |
-
-
|
| 55 |
|
| 56 |
Answer the following question as accurately as possible.
|
| 57 |
QUESTION: {question}
|
|
@@ -60,7 +60,12 @@ class BasicAgent:
|
|
| 60 |
try:
|
| 61 |
# Ejecutar el agente
|
| 62 |
answer = self.agent.run(prompt)
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
except Exception as e:
|
| 66 |
print(f"Error executing agent: {e}")
|
|
|
|
| 37 |
self.agent = CodeAgent(
|
| 38 |
tools=[search_tool],
|
| 39 |
model=self.model,
|
| 40 |
+
max_steps=7,
|
| 41 |
verbosity_level=1
|
| 42 |
)
|
| 43 |
|
|
|
|
| 46 |
|
| 47 |
prompt = f"""
|
| 48 |
IMPORTANT INSTRUCTIONS:
|
| 49 |
+
1. Use Python code or Search ONLY if needed.
|
| 50 |
+
2. Once you have the answer, print it clearly.
|
| 51 |
+
3. CRITICAL: The final return value must be a CLEAN string.
|
| 52 |
+
- NO markdown formatting (no **bold**, no `code`).
|
| 53 |
+
- NO explanations like "The answer is".
|
| 54 |
+
- Just the raw data (e.g., "14", "Paris", "apple, banana").
|
| 55 |
|
| 56 |
Answer the following question as accurately as possible.
|
| 57 |
QUESTION: {question}
|
|
|
|
| 60 |
try:
|
| 61 |
# Ejecutar el agente
|
| 62 |
answer = self.agent.run(prompt)
|
| 63 |
+
clean = str(answer).strip()
|
| 64 |
+
|
| 65 |
+
if "<code>" in clean or "Calling tools:" in clean:
|
| 66 |
+
return "Agent Error: Output contains raw code"
|
| 67 |
+
|
| 68 |
+
return clean
|
| 69 |
|
| 70 |
except Exception as e:
|
| 71 |
print(f"Error executing agent: {e}")
|