palltaruo commited on
Commit
823769b
·
verified ·
1 Parent(s): d9b40a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -16
app.py CHANGED
@@ -1,42 +1,41 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
-
8
  from tools.recipe_tools import search_recipe, parse_recipe, generate_shopping_list, format_shopping_list
9
-
10
  from Gradio_UI import GradioUI
11
 
12
-
13
  final_answer = FinalAnswerTool()
14
 
15
- # 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:
16
- # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
17
-
18
  model = HfApiModel(
19
- max_tokens=2096,
20
- temperature=0.5,
21
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
22
- custom_role_conversions=None,
23
  )
24
 
25
-
26
  # Import tool from Hub
27
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
28
 
 
29
  with open("prompts.yaml", 'r') as stream:
30
  prompt_templates = yaml.safe_load(stream)
31
-
 
32
  agent = CodeAgent(
33
  model=model,
34
- tools=[final_answer,
 
35
  search_recipe,
36
  parse_recipe,
37
  generate_shopping_list,
38
  format_shopping_list,
39
- image_generation_tool], ## add your tools here (don't remove final answer)
 
40
  max_steps=6,
41
  verbosity_level=1,
42
  grammar=None,
@@ -46,5 +45,5 @@ agent = CodeAgent(
46
  prompt_templates=prompt_templates
47
  )
48
 
49
-
50
  GradioUI(agent).launch()
 
1
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
2
  import datetime
3
  import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
  from tools.recipe_tools import search_recipe, parse_recipe, generate_shopping_list, format_shopping_list
 
8
  from Gradio_UI import GradioUI
9
 
10
+ # Initialize tools
11
  final_answer = FinalAnswerTool()
12
 
13
+ # Initialize model
 
 
14
  model = HfApiModel(
15
+ max_tokens=2096,
16
+ temperature=0.5,
17
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct', # it is possible that this model may be overloaded
18
+ custom_role_conversions=None,
19
  )
20
 
 
21
  # Import tool from Hub
22
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
23
 
24
+ # Load prompts
25
  with open("prompts.yaml", 'r') as stream:
26
  prompt_templates = yaml.safe_load(stream)
27
+
28
+ # Initialize agent
29
  agent = CodeAgent(
30
  model=model,
31
+ tools=[
32
+ final_answer,
33
  search_recipe,
34
  parse_recipe,
35
  generate_shopping_list,
36
  format_shopping_list,
37
+ image_generation_tool
38
+ ],
39
  max_steps=6,
40
  verbosity_level=1,
41
  grammar=None,
 
45
  prompt_templates=prompt_templates
46
  )
47
 
48
+ # Launch UI
49
  GradioUI(agent).launch()