dlarionov commited on
Commit
800079e
·
1 Parent(s): d109e79

try to fix errors

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -4,17 +4,21 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
 
8
  from Gradio_UI import GradioUI
9
 
10
-
11
  @tool
12
- def get_hello(name:str)-> str:
13
- """A tool that greetings you by name
14
  Args:
15
- name: the first name
16
  """
17
- return f'For the Hordr, {name}!'
 
 
 
 
18
 
19
  @tool
20
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -33,6 +37,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
 
34
 
35
  final_answer = FinalAnswerTool()
 
36
 
37
  # 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:
38
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
@@ -40,21 +45,19 @@ final_answer = FinalAnswerTool()
40
  model = HfApiModel(
41
  max_tokens=2096,
42
  temperature=0.5,
43
- model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud',
44
- #model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
45
  custom_role_conversions=None,
46
  )
47
 
48
-
49
  # Import tool from Hub
50
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
51
 
52
  with open("prompts.yaml", 'r') as stream:
53
  prompt_templates = yaml.safe_load(stream)
54
-
55
  agent = CodeAgent(
56
  model=model,
57
- tools=[final_answer, get_current_time_in_timezone, get_hello], ## add your tools here (don't remove final answer)
58
  max_steps=6,
59
  verbosity_level=1,
60
  grammar=None,
@@ -64,5 +67,4 @@ agent = CodeAgent(
64
  prompt_templates=prompt_templates
65
  )
66
 
67
-
68
  GradioUI(agent).launch()
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from tools.visit_webpage import VisitWebpageTool
8
 
9
  from Gradio_UI import GradioUI
10
 
 
11
  @tool
12
+ def calculate_sum(numbers: list) -> str:
13
+ """A tool that calculates the sum of a list of numbers.
14
  Args:
15
+ numbers: A list of numbers to sum.
16
  """
17
+ try:
18
+ total = sum(numbers)
19
+ return f"The sum of the numbers is: {total}"
20
+ except Exception as e:
21
+ return f"Error calculating sum: {str(e)}"
22
 
23
  @tool
24
  def get_current_time_in_timezone(timezone: str) -> str:
 
37
 
38
 
39
  final_answer = FinalAnswerTool()
40
+ visit_web = VisitWebpageTool()
41
 
42
  # 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:
43
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
 
45
  model = HfApiModel(
46
  max_tokens=2096,
47
  temperature=0.5,
48
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
 
49
  custom_role_conversions=None,
50
  )
51
 
 
52
  # Import tool from Hub
53
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
54
 
55
  with open("prompts.yaml", 'r') as stream:
56
  prompt_templates = yaml.safe_load(stream)
57
+
58
  agent = CodeAgent(
59
  model=model,
60
+ tools=[final_answer, visit_web], ## add your tools here (don't remove final answer)
61
  max_steps=6,
62
  verbosity_level=1,
63
  grammar=None,
 
67
  prompt_templates=prompt_templates
68
  )
69
 
 
70
  GradioUI(agent).launch()