Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ import pandas as pd
|
|
| 7 |
# Import our custom tools from their modules
|
| 8 |
from huggingface_hub import login
|
| 9 |
from smolagents import CodeAgent, InferenceClientModel
|
| 10 |
-
from tools import web_search, visit_webpage, final_answer
|
| 11 |
from retriever import load_guest_dataset
|
| 12 |
from functools import lru_cache
|
| 13 |
|
|
@@ -33,6 +33,12 @@ class BasicAgent:
|
|
| 33 |
self.visit_webpage = visit_webpage
|
| 34 |
|
| 35 |
self.final_answer = final_answer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# Create the model
|
| 38 |
self.model = InferenceClientModel(model_id="Qwen/Qwen2.5-72B-Instruct")
|
|
@@ -43,6 +49,7 @@ class BasicAgent:
|
|
| 43 |
# Create the agent with tools
|
| 44 |
self.agent = CodeAgent(
|
| 45 |
tools=[self.web_search, self.visit_webpage, self.final_answer],
|
|
|
|
| 46 |
model=self.model,
|
| 47 |
max_steps=10 # Limit reasoning steps
|
| 48 |
)
|
|
@@ -62,6 +69,7 @@ class BasicAgent:
|
|
| 62 |
formatted_question = f"{question}\n\nOnly return the exact answer, no explanation."
|
| 63 |
formatted_question = f"{self.system_prompt}\n\nQuestion: {question}\n\n"
|
| 64 |
answer = self.agent.run(formatted_question)
|
|
|
|
| 65 |
# answer = self.agent.run(question)
|
| 66 |
print(f"Agent returning answer: {answer[:100]}...")
|
| 67 |
fixed_answer = answer
|
|
|
|
| 7 |
# Import our custom tools from their modules
|
| 8 |
from huggingface_hub import login
|
| 9 |
from smolagents import CodeAgent, InferenceClientModel
|
| 10 |
+
from tools import web_search, visit_webpage, final_answer, go_back, close_popups, search_item_ctrl_f
|
| 11 |
from retriever import load_guest_dataset
|
| 12 |
from functools import lru_cache
|
| 13 |
|
|
|
|
| 33 |
self.visit_webpage = visit_webpage
|
| 34 |
|
| 35 |
self.final_answer = final_answer
|
| 36 |
+
|
| 37 |
+
self.go_back = go_back,
|
| 38 |
+
|
| 39 |
+
self.close_popups = close_popups,
|
| 40 |
+
|
| 41 |
+
self.search_item_ctrl_f = search_item_ctrl_f
|
| 42 |
|
| 43 |
# Create the model
|
| 44 |
self.model = InferenceClientModel(model_id="Qwen/Qwen2.5-72B-Instruct")
|
|
|
|
| 49 |
# Create the agent with tools
|
| 50 |
self.agent = CodeAgent(
|
| 51 |
tools=[self.web_search, self.visit_webpage, self.final_answer],
|
| 52 |
+
# tools=[self.web_search, self.visit_webpage, self.final_answer, go_back, close_popups, search_item_ctrl_f],
|
| 53 |
model=self.model,
|
| 54 |
max_steps=10 # Limit reasoning steps
|
| 55 |
)
|
|
|
|
| 69 |
formatted_question = f"{question}\n\nOnly return the exact answer, no explanation."
|
| 70 |
formatted_question = f"{self.system_prompt}\n\nQuestion: {question}\n\n"
|
| 71 |
answer = self.agent.run(formatted_question)
|
| 72 |
+
answer = str(answer).strip() if answer is not None else "No answer produced."
|
| 73 |
# answer = self.agent.run(question)
|
| 74 |
print(f"Agent returning answer: {answer[:100]}...")
|
| 75 |
fixed_answer = answer
|