kakimtched commited on
Commit
6288afb
·
verified ·
1 Parent(s): 8d26650

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -1,14 +1,15 @@
1
- from smolagents import CodeAgent, HfApiModel, load_tool, tool
2
  import datetime
 
3
  import pytz
4
  import yaml
5
  from tools.final_answer import FinalAnswerTool
6
 
7
  from Gradio_UI import GradioUI
8
 
9
- # Below is an example of a tool that does nothing. Amaze us with your creativity !
10
  @tool
11
- def my_custom_tool(arg1: str, arg2: int) -> str: # it's import to specify the return type
 
12
  """A tool that does nothing yet
13
  Args:
14
  arg1: the first argument
@@ -31,6 +32,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
31
  except Exception as e:
32
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
33
 
 
34
  @tool
35
  def emoji_summarizer(text: str) -> str:
36
  """
@@ -60,18 +62,16 @@ def emoji_summarizer(text: str) -> str:
60
  return "🤔 (no matching emojis found)"
61
  return "".join(emojis)
62
 
63
- final_answer = FinalAnswerTool()
64
-
65
- # 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:
66
- # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
67
 
 
68
  model = HfApiModel(
69
- max_tokens=2096,
70
- temperature=0.5,
71
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct', # it is possible that this model may be overloaded
72
- custom_role_conversions=None,
73
  )
74
 
 
75
  # Import tool from Hub
76
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
77
 
@@ -80,7 +80,7 @@ with open("prompts.yaml", 'r') as stream:
80
 
81
  agent = CodeAgent(
82
  model=model,
83
- tools=[final_answer, emoji_summarizer, image_generation_tool], ## add your tools here (don't remove final answer)
84
  max_steps=6,
85
  verbosity_level=1,
86
  grammar=None,
@@ -90,4 +90,5 @@ agent = CodeAgent(
90
  prompt_templates=prompt_templates
91
  )
92
 
 
93
  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
 
8
  from Gradio_UI import GradioUI
9
 
 
10
  @tool
11
+ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
12
+ #Keep this format for the description / args / args description but feel free to modify the tool
13
  """A tool that does nothing yet
14
  Args:
15
  arg1: the first argument
 
32
  except Exception as e:
33
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
34
 
35
+
36
  @tool
37
  def emoji_summarizer(text: str) -> str:
38
  """
 
62
  return "🤔 (no matching emojis found)"
63
  return "".join(emojis)
64
 
 
 
 
 
65
 
66
+ final_answer = FinalAnswerTool()
67
  model = HfApiModel(
68
+ max_tokens=2096,
69
+ temperature=0.5,
70
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
71
+ custom_role_conversions=None,
72
  )
73
 
74
+
75
  # Import tool from Hub
76
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
77
 
 
80
 
81
  agent = CodeAgent(
82
  model=model,
83
+ tools=[image_generation_tool, emoji_summarizer, get_current_time_in_timezone, final_answer, DuckDuckGoSearchTool()], ## add or remove tools here
84
  max_steps=6,
85
  verbosity_level=1,
86
  grammar=None,
 
90
  prompt_templates=prompt_templates
91
  )
92
 
93
+
94
  GradioUI(agent).launch()