GusLovesMath commited on
Commit
d31afb6
·
verified ·
1 Parent(s): aee272f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -22
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
@@ -11,10 +11,6 @@ import math
11
  import random
12
  from typing import Literal
13
 
14
- import math
15
- import random
16
- from typing import Literal
17
-
18
 
19
  @tool
20
  def get_approximate_integral(
@@ -65,33 +61,32 @@ def get_current_time_in_timezone(timezone: str) -> str:
65
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
66
 
67
 
68
- final_answer = FinalAnswerTool()
 
 
 
 
 
 
 
 
69
 
70
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
71
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
 
72
 
73
  model = HfApiModel(
74
- max_tokens=2096,
75
- temperature=0.5,
76
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
77
- custom_role_conversions=None,
78
  )
79
 
80
 
81
- GradioUI(agent).launch()
82
-
83
-
84
  # Import tool from Hub
85
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
86
 
87
- tool_list = [
88
- final_answer,
89
- get_approximate_integral,
90
- get_current_time_in_timezone,
91
- image_generation_tool, # the hub‑loaded tool
92
- DuckDuckGoSearchTool(), # plain class → instantiate
93
- ]
94
-
95
  with open("prompts.yaml", 'r') as stream:
96
  prompt_templates = yaml.safe_load(stream)
97
 
@@ -104,7 +99,7 @@ agent = CodeAgent(
104
  planning_interval=None,
105
  name=None,
106
  description=None,
107
- prompt_templates=prompt_templates
108
  )
109
 
110
 
 
1
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
2
  import datetime
3
  import requests
4
  import pytz
 
11
  import random
12
  from typing import Literal
13
 
 
 
 
 
14
 
15
  @tool
16
  def get_approximate_integral(
 
61
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
62
 
63
 
64
+
65
+ tool_list = [
66
+ final_answer,
67
+ get_approximate_integral,
68
+ get_current_time_in_timezone,
69
+ image_generation_tool, # the hub‑loaded tool
70
+ DuckDuckGoSearchTool(), # plain class → instantiate
71
+ ]
72
+
73
 
74
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
75
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
76
+ final_answer = FinalAnswerTool()
77
 
78
  model = HfApiModel(
79
+ max_tokens=2096,
80
+ temperature=0.5,
81
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
82
+ custom_role_conversions=None,
83
  )
84
 
85
 
 
 
 
86
  # Import tool from Hub
87
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
88
 
89
+ # Load system prompt from prompt.yaml file
 
 
 
 
 
 
 
90
  with open("prompts.yaml", 'r') as stream:
91
  prompt_templates = yaml.safe_load(stream)
92
 
 
99
  planning_interval=None,
100
  name=None,
101
  description=None,
102
+ prompt_templates=prompt_templates
103
  )
104
 
105