foleymon commited on
Commit
c7bc97c
·
verified ·
1 Parent(s): 048fb84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -17
app.py CHANGED
@@ -3,12 +3,17 @@ import datetime
3
  import requests
4
  import pytz
5
  import yaml
 
6
  from tools.final_answer import FinalAnswerTool
7
 
8
 
 
 
9
  from Gradio_UI import GradioUI
10
 
11
 
 
 
12
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
13
  @tool
14
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
@@ -21,6 +26,8 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
21
  return "What magic will you build ?"
22
 
23
 
 
 
24
  @tool
25
  def get_current_time_in_timezone(timezone: str) -> str:
26
  """A tool that fetches the current local time in a specified timezone.
@@ -39,13 +46,27 @@ def get_current_time_in_timezone(timezone: str) -> str:
39
 
40
 
41
 
 
 
 
 
42
  final_answer = FinalAnswerTool()
43
 
44
 
 
 
 
 
 
 
 
 
45
  # 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:
46
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
47
 
48
 
 
 
49
  model = HfApiModel(
50
  max_tokens=2096,
51
  temperature=0.5,
@@ -56,26 +77,15 @@ custom_role_conversions=None,
56
 
57
 
58
 
59
- # Import tool from Hub
60
- image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
61
 
62
 
63
- with open("prompts.yaml", 'r') as stream:
64
- prompt_templates = yaml.safe_load(stream)
65
-
66
- agent = CodeAgent(
67
- model=model,
68
- tools=[final_answer, DuckDuckGoSearchTool(), get_current_time_in_timezone, image_generation_tool],
69
- max_steps=6,
70
- verbosity_level=1,
71
- grammar=None,
72
- planning_interval=None,
73
- name=None,
74
- description=None,
75
- prompt_templates=prompt_templates
76
- )
77
 
78
 
79
 
80
 
81
- GradioUI(agent).launch()
 
 
3
  import requests
4
  import pytz
5
  import yaml
6
+ import spaces
7
  from tools.final_answer import FinalAnswerTool
8
 
9
 
10
+
11
+
12
  from Gradio_UI import GradioUI
13
 
14
 
15
+
16
+
17
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
18
  @tool
19
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
 
26
  return "What magic will you build ?"
27
 
28
 
29
+
30
+
31
  @tool
32
  def get_current_time_in_timezone(timezone: str) -> str:
33
  """A tool that fetches the current local time in a specified timezone.
 
46
 
47
 
48
 
49
+
50
+
51
+
52
+
53
  final_answer = FinalAnswerTool()
54
 
55
 
56
+ @spaces.GPU(duration=120)
57
+ def _zero_gpu_check() -> str:
58
+ """Placeholder GPU function so the ZeroGPU runtime detects a GPU function."""
59
+ return "ok"
60
+
61
+
62
+
63
+
64
  # 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:
65
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
66
 
67
 
68
+
69
+
70
  model = HfApiModel(
71
  max_tokens=2096,
72
  temperature=0.5,
 
77
 
78
 
79
 
 
 
80
 
81
 
82
+
83
+
84
+ # Import tool from Hub
85
+ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
 
 
 
 
 
 
 
 
 
 
86
 
87
 
88
 
89
 
90
+ with open("prompts.yaml", 'r') as stream:
91
+ prompt_templates = yaml.safe_load(stream)