Diego-Fco commited on
Commit
9c0fdc9
·
verified ·
1 Parent(s): 26f0e5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -37,7 +37,7 @@ class BasicAgent:
37
  self.agent = CodeAgent(
38
  tools=[search_tool],
39
  model=self.model,
40
- max_steps=5,
41
  verbosity_level=1
42
  )
43
 
@@ -46,12 +46,12 @@ class BasicAgent:
46
 
47
  prompt = f"""
48
  IMPORTANT INSTRUCTIONS:
49
- 1. Use the search tool if you need external information.
50
- 2. Solve the problem step by step using code if necessary.
51
- 3. The final output must be ONLY the answer strings.
52
- - Do not add "The answer is...".
53
- - Do not add punctuation like periods at the end unless part of the answer.
54
- - If the answer is a list, format it exactly as requested.
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
- return str(answer).strip()
 
 
 
 
 
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}")