Spaces:
Sleeping
Sleeping
Update BasicAgent.py
Browse files- BasicAgent.py +5 -17
BasicAgent.py
CHANGED
@@ -10,17 +10,6 @@ from smolagents import (
|
|
10 |
GoogleSearchTool,
|
11 |
)
|
12 |
|
13 |
-
#model_id = "Qwen/Qwen2.5-Coder-32B-Instruct"
|
14 |
-
#model_id = 'meta-llama/Llama-3.3-70B-Instruct'
|
15 |
-
|
16 |
-
#model = HfApiModel(model_id=model_id, token="HUGGINGFACEHUB_API_TOKEN")
|
17 |
-
|
18 |
-
#agent = CodeAgent(tools=[], model=model, add_base_tools=True)
|
19 |
-
|
20 |
-
#max_steps=5
|
21 |
-
#import os
|
22 |
-
#from smolagents import CodeAgent, HfApiModel, InferenceClientModel, WebSearchTool
|
23 |
-
|
24 |
class newAgent:
|
25 |
"""Adapts smolagents.CodeAgent to the HF course template API."""
|
26 |
def __init__(self):
|
@@ -30,22 +19,21 @@ class newAgent:
|
|
30 |
raise RuntimeError("HUGGINGFACEHUB_API_TOKEN not set in Space secrets")
|
31 |
|
32 |
model = HfApiModel(model_id=model_id, token=hf_token)
|
33 |
-
|
34 |
-
|
35 |
-
#*
|
36 |
-
# include FinalAnswerTool in tools so agent knows when to stop
|
37 |
tools = [FinalAnswerTool()]
|
38 |
self.agent = CodeAgent(
|
39 |
tools=tools,
|
40 |
model=model,
|
41 |
add_base_tools=True
|
|
|
42 |
)
|
43 |
-
|
44 |
def __call__(self, question: str) -> str:
|
45 |
"""ONE question in β ONE pure-text answer out."""
|
46 |
#β Replace .run with whatever method actually returns the answer string.
|
47 |
result = self.agent.run(question)
|
48 |
-
return
|
49 |
|
50 |
#answer = self.run
|
51 |
|
|
|
10 |
GoogleSearchTool,
|
11 |
)
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
class newAgent:
|
14 |
"""Adapts smolagents.CodeAgent to the HF course template API."""
|
15 |
def __init__(self):
|
|
|
19 |
raise RuntimeError("HUGGINGFACEHUB_API_TOKEN not set in Space secrets")
|
20 |
|
21 |
model = HfApiModel(model_id=model_id, token=hf_token)
|
22 |
+
|
23 |
+
# include FinalAnswerTool in tools so agent knows when to stop
|
|
|
|
|
24 |
tools = [FinalAnswerTool()]
|
25 |
self.agent = CodeAgent(
|
26 |
tools=tools,
|
27 |
model=model,
|
28 |
add_base_tools=True
|
29 |
+
max_steps=5 # limit reasoning time
|
30 |
)
|
31 |
+
|
32 |
def __call__(self, question: str) -> str:
|
33 |
"""ONE question in β ONE pure-text answer out."""
|
34 |
#β Replace .run with whatever method actually returns the answer string.
|
35 |
result = self.agent.run(question)
|
36 |
+
return result
|
37 |
|
38 |
#answer = self.run
|
39 |
|