dagiro commited on
Commit
9389059
·
verified ·
1 Parent(s): 4b53383

Update app.py

Browse files

new tool added to code

Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel, load_tool, tool
2
  import datetime
3
  import requests
4
  import pytz
@@ -10,10 +10,10 @@ from PIL import Image
10
  import io
11
  import base64
12
 
13
- # Below is an example of a tool that does nothing. Amaze us with your creativity!
14
  @tool
15
- def my_custom_tool(arg1:str, arg2:int)-> str: # it's important to specify the return type
16
- # Keep this format for the tool description / args description but feel free to modify the tool
17
  """A tool that does nothing yet
18
  Args:
19
  arg1: the first argument
@@ -90,31 +90,34 @@ def generate_image(
90
 
91
 
92
  final_answer = FinalAnswerTool()
93
- model = InferenceClientModel(
94
- max_tokens=2096,
95
- temperature=0.5,
96
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct', # 'mistralai/Mistral-Small-3.1-24B-Instruct-2503',
97
- custom_role_conversions=None,
 
 
 
 
98
  )
99
 
100
 
101
  # Import tool from Hub
102
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
103
 
104
- # Load system prompt from prompt.yaml file
105
  with open("prompts.yaml", 'r') as stream:
106
  prompt_templates = yaml.safe_load(stream)
107
 
108
  agent = CodeAgent(
109
  model=model,
110
- tools=[final_answer, get_current_time_in_timezone], # add your tools here (don't remove final_answer)
111
  max_steps=6,
112
  verbosity_level=1,
113
  grammar=None,
114
  planning_interval=None,
115
  name=None,
116
  description=None,
117
- # prompt_templates=prompt_templates # Pass system prompt to CodeAgent
118
  )
119
 
120
 
 
1
+ from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
 
10
  import io
11
  import base64
12
 
13
+ # Below is an example of a tool that does nothing. Amaze us with your creativity !
14
  @tool
15
+ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
16
+ #Keep this format for the description / args / args description but feel free to modify the tool
17
  """A tool that does nothing yet
18
  Args:
19
  arg1: the first argument
 
90
 
91
 
92
  final_answer = FinalAnswerTool()
93
+
94
+ # 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:
95
+ # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
96
+
97
+ model = HfApiModel(
98
+ max_tokens=2096,
99
+ temperature=0.5,
100
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
101
+ custom_role_conversions=None,
102
  )
103
 
104
 
105
  # Import tool from Hub
106
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
107
 
 
108
  with open("prompts.yaml", 'r') as stream:
109
  prompt_templates = yaml.safe_load(stream)
110
 
111
  agent = CodeAgent(
112
  model=model,
113
+ tools=[final_answer], ## add your tools here (don't remove final answer)
114
  max_steps=6,
115
  verbosity_level=1,
116
  grammar=None,
117
  planning_interval=None,
118
  name=None,
119
  description=None,
120
+ prompt_templates=prompt_templates
121
  )
122
 
123