Spaces:
Sleeping
Sleeping
Update app.py
Browse files2 unmodified lines345678910 unmodified lines202122232425262728293031323334352 unmodified linesimport requestsimport inspectimport pandas as pdfrom smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, LiteLLMModel, GoogleSearchTool# (Keep Constants as is)# --- Constants ---10 unmodified lines)self.agent = CodeAgent(model = model,tools=[GoogleSearchTool()],add_base_tools=True, # Add any additional base toolsmax_steps=15,planning_interval=3 # Enable planning every 3 steps)def __call__(self, question: str) -> str:print(f"Agent received question (first 50 chars): {question[:50]}...")fixed_answer = self.agent.run(question)print(f"Agent returning fixed answer: {fixed_answer}")return fixed_answerdef run_and_submit_all( profile: gr.OAuthProfile | None):"""2 unmodified lines34567891010 unmodified lines21222324252627282930313233343536373839404142434445462 unmodified linesimport requestsimport inspectimport pandas as pdimport asynciofrom smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, LiteLLMModel, GoogleSearchTool, WikipediaSearchTool# (Keep Constants as is)# --- Constants ---10 unmodified lines)self.agent = CodeAgent(model = model,tools=[GoogleSearchTool(), WikipediaSearchTool() ],add_base_tools=True, # Add any additional base toolsmax_steps=15,planning_interval=3 # Enable planning every 3 steps)async def __call__(self, question: str) -> str:print(f"Agent received question (first 50 chars): {question[:50]}...")# fixed_answer = self.agent.run(question)response = await asyncio.to_thread(self.agent.run,question=question)# Ensure response is a string, fixing the integer errorresponse = str(response)if response is None:print(f"No answer found.")print(f"Agent returning fixed answer: {response}")return responsedef run_and_submit_all( profile: gr.OAuthProfile | None):"""
app.py+17-6