Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
-
from smolagents import CodeAgent, InferenceClientModel, OpenAIServerModel
|
| 4 |
import requests
|
| 5 |
import inspect
|
| 6 |
import pandas as pd
|
| 7 |
-
from tools import search_tool, google_search_tool
|
| 8 |
|
| 9 |
# (Keep Constants as is)
|
| 10 |
# --- Constants ---
|
|
@@ -24,14 +24,14 @@ class BasicAgent:
|
|
| 24 |
api_key=os.environ["OPENAI_API_KEY"],
|
| 25 |
)
|
| 26 |
self.my_agent = CodeAgent(
|
| 27 |
-
tools=[search_tool, google_search_tool],
|
| 28 |
model=model,
|
| 29 |
add_base_tools=True, # Add any additional base tools
|
| 30 |
planning_interval=3 # Enable planning every 3 steps
|
| 31 |
)
|
| 32 |
print("BasicAgent initialized.")
|
| 33 |
-
def __call__(self, question: str) -> str:
|
| 34 |
-
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 35 |
# fixed_answer = "This is a default answer."
|
| 36 |
# print(f"Agent returning fixed answer: {fixed_answer}")
|
| 37 |
response = self.my_agent.run(question)
|
|
@@ -98,7 +98,8 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 98 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 99 |
continue
|
| 100 |
try:
|
| 101 |
-
|
|
|
|
| 102 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 103 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 104 |
except Exception as e:
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
+
from smolagents import CodeAgent, InferenceClientModel, OpenAIServerModel, FinalAnswerTool
|
| 4 |
import requests
|
| 5 |
import inspect
|
| 6 |
import pandas as pd
|
| 7 |
+
from tools import search_tool, google_search_tool, wiki_search_tool
|
| 8 |
|
| 9 |
# (Keep Constants as is)
|
| 10 |
# --- Constants ---
|
|
|
|
| 24 |
api_key=os.environ["OPENAI_API_KEY"],
|
| 25 |
)
|
| 26 |
self.my_agent = CodeAgent(
|
| 27 |
+
tools=[search_tool, google_search_tool, wiki_search_tool, FinalAnswerTool()],
|
| 28 |
model=model,
|
| 29 |
add_base_tools=True, # Add any additional base tools
|
| 30 |
planning_interval=3 # Enable planning every 3 steps
|
| 31 |
)
|
| 32 |
print("BasicAgent initialized.")
|
| 33 |
+
def __call__(self, question: str, task_id: str, file_name:str="") -> str:
|
| 34 |
+
print(f"Task {task_id} - Agent received question (first 50 chars): {question[:50]}...")
|
| 35 |
# fixed_answer = "This is a default answer."
|
| 36 |
# print(f"Agent returning fixed answer: {fixed_answer}")
|
| 37 |
response = self.my_agent.run(question)
|
|
|
|
| 98 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 99 |
continue
|
| 100 |
try:
|
| 101 |
+
file_name = item.get("file_name")
|
| 102 |
+
submitted_answer = agent(question=question_text, task_id=task_id, file_name=file_name)
|
| 103 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 104 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 105 |
except Exception as e:
|