DawnR0270 commited on
Commit
0e4d92b
·
verified ·
1 Parent(s): e86a004

Deleted duplicate lines generated with Share=True

Browse files
Files changed (1) hide show
  1. app.py +1 -137
app.py CHANGED
@@ -66,140 +66,4 @@ agent = CodeAgent(
66
  )
67
 
68
 
69
- GradioUI(agent).launch(from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
70
- import datetime
71
- import requests
72
- import pytz
73
- import yaml
74
- from tools.final_answer import FinalAnswerTool
75
-
76
- from Gradio_UI import GradioUI
77
-
78
- # Below is an example of a tool that does nothing. Amaze us with your creativity !
79
- @tool
80
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
81
- #Keep this format for the description / args / args description but feel free to modify the tool
82
- """A tool that does nothing yet
83
- Args:
84
- arg1: the first argument
85
- arg2: the second argument
86
- """
87
- return "What magic will you build ?"
88
-
89
- @tool
90
- def get_current_time_in_timezone(timezone: str) -> str:
91
- """A tool that fetches the current local time in a specified timezone.
92
- Args:
93
- timezone: A string representing a valid timezone (e.g., 'America/New_York').
94
- """
95
- try:
96
- # Create timezone object
97
- tz = pytz.timezone(timezone)
98
- # Get current time in that timezone
99
- local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
100
- return f"The current local time in {timezone} is: {local_time}"
101
- except Exception as e:
102
- return f"Error fetching time for timezone '{timezone}': {str(e)}"
103
-
104
-
105
- final_answer = FinalAnswerTool()
106
-
107
- # 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:
108
- # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
109
-
110
- model = HfApiModel(
111
- max_tokens=2096,
112
- temperature=0.5,
113
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
114
- custom_role_conversions=None,
115
- )
116
-
117
-
118
- # Import tool from Hub
119
- image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
120
-
121
- with open("prompts.yaml", 'r') as stream:
122
- prompt_templates = yaml.safe_load(stream)
123
-
124
- agent = CodeAgent(
125
- model=model,
126
- tools=[final_answer, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
127
- max_steps=6,
128
- verbosity_level=1,
129
- grammar=None,
130
- planning_interval=None,
131
- name=None,
132
- description=None,
133
- prompt_templates=prompt_templates
134
- )
135
-
136
-
137
- GradioUI(agent).launch(from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
138
- import datetime
139
- import requests
140
- import pytz
141
- import yaml
142
- from tools.final_answer import FinalAnswerTool
143
-
144
- from Gradio_UI import GradioUI
145
-
146
- # Below is an example of a tool that does nothing. Amaze us with your creativity !
147
- @tool
148
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
149
- #Keep this format for the description / args / args description but feel free to modify the tool
150
- """A tool that does nothing yet
151
- Args:
152
- arg1: the first argument
153
- arg2: the second argument
154
- """
155
- return "What magic will you build ?"
156
-
157
- @tool
158
- def get_current_time_in_timezone(timezone: str) -> str:
159
- """A tool that fetches the current local time in a specified timezone.
160
- Args:
161
- timezone: A string representing a valid timezone (e.g., 'America/New_York').
162
- """
163
- try:
164
- # Create timezone object
165
- tz = pytz.timezone(timezone)
166
- # Get current time in that timezone
167
- local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
168
- return f"The current local time in {timezone} is: {local_time}"
169
- except Exception as e:
170
- return f"Error fetching time for timezone '{timezone}': {str(e)}"
171
-
172
-
173
- final_answer = FinalAnswerTool()
174
-
175
- # 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:
176
- # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
177
-
178
- model = HfApiModel(
179
- max_tokens=2096,
180
- temperature=0.5,
181
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
182
- custom_role_conversions=None,
183
- )
184
-
185
-
186
- # Import tool from Hub
187
- image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
188
-
189
- with open("prompts.yaml", 'r') as stream:
190
- prompt_templates = yaml.safe_load(stream)
191
-
192
- agent = CodeAgent(
193
- model=model,
194
- tools=[final_answer, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
195
- max_steps=6,
196
- verbosity_level=1,
197
- grammar=None,
198
- planning_interval=None,
199
- name=None,
200
- description=None,
201
- prompt_templates=prompt_templates
202
- )
203
-
204
-
205
- GradioUI(agent).launch(share=True)
 
66
  )
67
 
68
 
69
+ GradioUI(agent).launch(from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool, share=True)