STARX33 commited on
Commit
e73c841
·
verified ·
1 Parent(s): 67bae22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -191,18 +191,28 @@ class BasicAgent:
191
  )
192
  print("✅ Agent initialized with all tools")
193
 
194
- def __call__(self, question: str) -> str:
195
  response = self.agent.run(question)
196
- if "Final Answer:" not in response:
197
- # Check for fallback matches
 
 
 
 
 
 
 
 
198
  for key, fallback in self.rag_fallbacks.items():
199
  if key.lower() in question.lower():
200
  return f"Tool response inconclusive. Based on known data: Final Answer: {fallback}"
201
- # Otherwise, default to the last line
 
 
202
  last_line = response.strip().split("\n")[-1]
203
  response += f"\nFinal Answer: {last_line}"
204
- return response
205
 
 
206
 
207
 
208
  # === Evaluation Logic ===
 
191
  )
192
  print("✅ Agent initialized with all tools")
193
 
194
+ def __call__(self, question: str) -> str:
195
  response = self.agent.run(question)
196
+
197
+ # Use fallback RAG answers if the output is inconclusive
198
+ if (
199
+ "Final Answer:" not in response
200
+ or "None" in response
201
+ or "Out: None" in response
202
+ or "Execution logs:\n" in response and all(
203
+ x in response for x in ["Out: None", "Execution logs"]
204
+ )
205
+ ):
206
  for key, fallback in self.rag_fallbacks.items():
207
  if key.lower() in question.lower():
208
  return f"Tool response inconclusive. Based on known data: Final Answer: {fallback}"
209
+
210
+ # Default to last line as Final Answer if not present
211
+ if "Final Answer:" not in response:
212
  last_line = response.strip().split("\n")[-1]
213
  response += f"\nFinal Answer: {last_line}"
 
214
 
215
+ return response
216
 
217
 
218
  # === Evaluation Logic ===