Spaces:
Sleeping
Sleeping
Update app.py
Browse filesusing self to refer to class members.
app.py
CHANGED
|
@@ -36,13 +36,11 @@ def check_reasoning(final_answer,agent_memory):
|
|
| 36 |
raise Exception(output)
|
| 37 |
return True
|
| 38 |
class BasicAgent:
|
| 39 |
-
agent = None
|
| 40 |
-
web_agent = None
|
| 41 |
def __init__(self):
|
| 42 |
prompt = "You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string."
|
| 43 |
model = InferenceClientModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct", provider="together")
|
| 44 |
|
| 45 |
-
web_agent = CodeAgent(
|
| 46 |
model=model,
|
| 47 |
tools=[
|
| 48 |
GoogleSearchTool(provider="serper"),
|
|
@@ -54,7 +52,7 @@ class BasicAgent:
|
|
| 54 |
max_steps=10,
|
| 55 |
)
|
| 56 |
|
| 57 |
-
agent = CodeAgent(
|
| 58 |
model=InferenceClientModel("deepseek-ai/DeepSeek-R1", provider="together", max_tokens=8096),
|
| 59 |
tools=[GoogleSearchTool(), VisitWebpageTool()],
|
| 60 |
managed_agents=[web_agent],
|
|
@@ -66,7 +64,7 @@ class BasicAgent:
|
|
| 66 |
print("BasicAgent initialized.")
|
| 67 |
|
| 68 |
def __call__(self, question: str) -> str:
|
| 69 |
-
answer = agent.run(question)
|
| 70 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 71 |
#fixed_answer = "This is a default answer."
|
| 72 |
final_answer = answer.replace("FINAL ANSWER:","").strip()
|
|
|
|
| 36 |
raise Exception(output)
|
| 37 |
return True
|
| 38 |
class BasicAgent:
|
|
|
|
|
|
|
| 39 |
def __init__(self):
|
| 40 |
prompt = "You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string."
|
| 41 |
model = InferenceClientModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct", provider="together")
|
| 42 |
|
| 43 |
+
self.web_agent = CodeAgent(
|
| 44 |
model=model,
|
| 45 |
tools=[
|
| 46 |
GoogleSearchTool(provider="serper"),
|
|
|
|
| 52 |
max_steps=10,
|
| 53 |
)
|
| 54 |
|
| 55 |
+
self.agent = CodeAgent(
|
| 56 |
model=InferenceClientModel("deepseek-ai/DeepSeek-R1", provider="together", max_tokens=8096),
|
| 57 |
tools=[GoogleSearchTool(), VisitWebpageTool()],
|
| 58 |
managed_agents=[web_agent],
|
|
|
|
| 64 |
print("BasicAgent initialized.")
|
| 65 |
|
| 66 |
def __call__(self, question: str) -> str:
|
| 67 |
+
answer = self.agent.run(question)
|
| 68 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 69 |
#fixed_answer = "This is a default answer."
|
| 70 |
final_answer = answer.replace("FINAL ANSWER:","").strip()
|