Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import yaml
|
|
|
2 |
import os
|
3 |
from smolagents import GradioUI, CodeAgent, TransformersModel
|
4 |
|
@@ -10,12 +11,6 @@ from tools.get_current_weather import SimpleTool as GetCurrentWeather
|
|
10 |
from tools.final_answer import FinalAnswerTool as FinalAnswer
|
11 |
|
12 |
|
13 |
-
|
14 |
-
model = TransformersModel(
|
15 |
-
max_new_tokens=1000,
|
16 |
-
model_id='Qwen/Qwen2.5-Coder-3B-Instruct',
|
17 |
-
)
|
18 |
-
|
19 |
get_coordinates = GetCoordinates()
|
20 |
get_current_weather = GetCurrentWeather()
|
21 |
final_answer = FinalAnswer()
|
@@ -24,20 +19,30 @@ final_answer = FinalAnswer()
|
|
24 |
with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream:
|
25 |
prompt_templates = yaml.safe_load(stream)
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
GradioUI(agent_get_weather_agent).launch()
|
|
|
|
|
|
|
|
|
|
1 |
import yaml
|
2 |
+
import space
|
3 |
import os
|
4 |
from smolagents import GradioUI, CodeAgent, TransformersModel
|
5 |
|
|
|
11 |
from tools.final_answer import FinalAnswerTool as FinalAnswer
|
12 |
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
get_coordinates = GetCoordinates()
|
15 |
get_current_weather = GetCurrentWeather()
|
16 |
final_answer = FinalAnswer()
|
|
|
19 |
with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream:
|
20 |
prompt_templates = yaml.safe_load(stream)
|
21 |
|
22 |
+
@spaces.GPU
|
23 |
+
def call_agent():
|
24 |
+
model = TransformersModel(
|
25 |
+
max_new_tokens=1000,
|
26 |
+
model_id='Qwen/Qwen2.5-Coder-3B-Instruct',
|
27 |
+
)
|
28 |
+
|
29 |
+
agent_get_weather_agent = CodeAgent(
|
30 |
+
model=model,
|
31 |
+
tools=[get_coordinates, get_current_weather],
|
32 |
+
managed_agents=[],
|
33 |
+
max_steps=20,
|
34 |
+
verbosity_level=2,
|
35 |
+
grammar=None,
|
36 |
+
planning_interval=None,
|
37 |
+
name='get_weather_agent',
|
38 |
+
description=None,
|
39 |
+
executor_type='local',
|
40 |
+
executor_kwargs={},
|
41 |
+
max_print_outputs_length=None,
|
42 |
+
prompt_templates=prompt_templates
|
43 |
+
)
|
44 |
GradioUI(agent_get_weather_agent).launch()
|
45 |
+
|
46 |
+
|
47 |
+
if __name__ == "__main__":
|
48 |
+
call_agent()
|