rogulin commited on
Commit
b617a62
·
verified ·
1 Parent(s): 2194b61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -16
app.py CHANGED
@@ -7,17 +7,16 @@ 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_custom_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 outputs arg1 N times joined with '-', where N is arg2.
15
  Args:
16
  arg1: the string to output
17
  arg2: the number of times
18
  """
19
  result = ""
20
- for range(arg2):
21
  if len(result) > 0:
22
  result += "-"
23
  result += arg1
@@ -38,29 +37,27 @@ def get_current_time_in_timezone(timezone: str) -> str:
38
  except Exception as e:
39
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
40
 
41
-
42
  final_answer = FinalAnswerTool()
43
 
44
- # 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:
45
- # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
46
 
47
  model = HfApiModel(
48
- max_tokens=2096,
49
- temperature=0.5,
50
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
51
- custom_role_conversions=None,
52
  )
53
 
54
-
55
  # Import tool from Hub
56
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
57
 
58
  with open("prompts.yaml", 'r') as stream:
59
  prompt_templates = yaml.safe_load(stream)
60
-
61
  agent = CodeAgent(
62
  model=model,
63
- tools=[final_answer, get_current_time_in_timezone, image_generation_tool, my_custom_tool], ## add your tools here (don't remove final answer)
64
  max_steps=6,
65
  verbosity_level=1,
66
  grammar=None,
@@ -70,5 +67,4 @@ agent = CodeAgent(
70
  prompt_templates=prompt_templates
71
  )
72
 
73
-
74
  GradioUI(agent).launch()
 
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_custom_tool(arg1: str, arg2: int) -> str: # it's important to specify the return type
13
+ """A tool that outputs arg1 N times joined with '-', where N is arg2.
 
14
  Args:
15
  arg1: the string to output
16
  arg2: the number of times
17
  """
18
  result = ""
19
+ for _ in range(arg2): # Fixed syntax error
20
  if len(result) > 0:
21
  result += "-"
22
  result += arg1
 
37
  except Exception as e:
38
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
39
 
 
40
  final_answer = FinalAnswerTool()
41
 
42
+ # If the agent does not answer, the model is overloaded. Use another model or the following Hugging Face Endpoint:
43
+ # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
44
 
45
  model = HfApiModel(
46
+ max_tokens=2096,
47
+ temperature=0.5,
48
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct', # Ensure this model is available
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, get_current_time_in_timezone, image_generation_tool, my_custom_tool], # Fixed tool list format
61
  max_steps=6,
62
  verbosity_level=1,
63
  grammar=None,
 
67
  prompt_templates=prompt_templates
68
  )
69
 
 
70
  GradioUI(agent).launch()