ffreemt commited on
Commit
e49f581
·
1 Parent(s): 9a8c112
README.md CHANGED
@@ -1,12 +1,12 @@
1
  ---
2
- title: First Agent Template
3
- emoji:
4
- colorFrom: pink
5
  colorTo: yellow
6
  sdk: gradio
7
  sdk_version: 5.15.0
8
  app_file: app.py
9
- pinned: false
10
  tags:
11
  - smolagents
12
  - agent
 
1
  ---
2
+ title: hf agent
3
+ emoji: 👁️
4
+ colorFrom: blue
5
  colorTo: yellow
6
  sdk: gradio
7
  sdk_version: 5.15.0
8
  app_file: app.py
9
+ pinned: true
10
  tags:
11
  - smolagents
12
  - agent
__pycache__/Gradio_UI.cpython-312.pyc ADDED
Binary file (12 kB). View file
 
app.py CHANGED
@@ -1,28 +1,45 @@
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
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_cutom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
 
 
15
  Args:
16
  arg1: the first argument
17
  arg2: the second argument
 
18
  """
19
- return "What magic will you build ?"
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
- """A tool that fetches the current local time in a specified timezone.
 
 
24
  Args:
25
  timezone: A string representing a valid timezone (e.g., 'America/New_York').
 
26
  """
27
  try:
28
  # Create timezone object
@@ -36,30 +53,30 @@ def get_current_time_in_timezone(timezone: str) -> str:
36
 
37
  final_answer = FinalAnswerTool()
38
  model = HfApiModel(
39
- max_tokens=2096,
40
- temperature=0.5,
41
- model_id='https://wxknx1kg971u7k1n.us-east-1.aws.endpoints.huggingface.cloud',# it is possible that this model may be overloaded
42
- custom_role_conversions=None,
43
  )
44
 
45
 
46
  # Import tool from Hub
47
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
48
 
49
- with open("prompts.yaml", 'r') as stream:
50
  prompt_templates = yaml.safe_load(stream)
51
-
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer], ## add your tools here (don't remove final answer)
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
58
  planning_interval=None,
59
  name=None,
60
  description=None,
61
- prompt_templates=prompt_templates
62
  )
63
 
64
 
65
- GradioUI(agent).launch()
 
1
+ """Run hf agent."""
2
+
3
+ # pylint: disable=line-too-long, broad-exception-caught
4
  import datetime
5
+
6
+ # import requests
7
  import pytz
8
  import yaml
9
+ from smolagents import (
10
+ CodeAgent,
11
+ # DuckDuckGoSearchTool,
12
+ HfApiModel,
13
+ load_tool,
14
+ tool,
15
+ )
16
+ from Gradio_UI import GradioUI
17
  from tools.final_answer import FinalAnswerTool
18
 
 
19
 
20
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
21
  @tool
22
+ def my_cutom_tool(arg1: str, arg2: int) -> str: # it's import to specify the return type
23
+ # Keep this format for the description / args / args description but feel free to modify the tool
24
+ """
25
+ Run a tool that does nothing yet.
26
+
27
  Args:
28
  arg1: the first argument
29
  arg2: the second argument
30
+
31
  """
32
+ return f"What magic will you build? {arg1=}, {arg2=}"
33
+
34
 
35
  @tool
36
  def get_current_time_in_timezone(timezone: str) -> str:
37
+ """
38
+ Run a tool that fetches the current local time in a specified timezone.
39
+
40
  Args:
41
  timezone: A string representing a valid timezone (e.g., 'America/New_York').
42
+
43
  """
44
  try:
45
  # Create timezone object
 
53
 
54
  final_answer = FinalAnswerTool()
55
  model = HfApiModel(
56
+ max_tokens=2096,
57
+ temperature=0.5,
58
+ model_id="https://wxknx1kg971u7k1n.us-east-1.aws.endpoints.huggingface.cloud", # it is possible that this model may be overloaded
59
+ custom_role_conversions=None,
60
  )
61
 
62
 
63
  # Import tool from Hub
64
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
65
 
66
+ with open("prompts.yaml", "r", encoding="utf8") as stream:
67
  prompt_templates = yaml.safe_load(stream)
68
+
69
  agent = CodeAgent(
70
  model=model,
71
+ tools=[my_cutom_tool, get_current_time_in_timezone, final_answer], ## add your tools here (don't remove final answer)
72
  max_steps=6,
73
  verbosity_level=1,
74
  grammar=None,
75
  planning_interval=None,
76
  name=None,
77
  description=None,
78
+ prompt_templates=prompt_templates,
79
  )
80
 
81
 
82
+ GradioUI(agent).launch()
tools/__pycache__/final_answer.cpython-312.pyc ADDED
Binary file (1.02 kB). View file