nvipin63 commited on
Commit
618dbe1
·
verified ·
1 Parent(s): ae7a494

added new tool to suggest a place from the timezone

Browse files
Files changed (1) hide show
  1. app.py +22 -7
app.py CHANGED
@@ -4,19 +4,34 @@ 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_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 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:
@@ -55,7 +70,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from huggingface_hub import InferenceClient
8
 
9
  from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
+ def suggest_famous_place(timezone:str)-> str:
14
+ """This tool suggests a famous place from the parsed timezone.
 
15
  Args:
16
+ timezone: a timezone from user
 
17
  """
18
+ model = HfApiModel(
19
+ max_tokens=2096,
20
+ temperature=0.5,
21
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
22
+ custom_role_conversions=None,
23
+ )
24
+ client = InferenceClient(model=model)
25
+ # Example chat input
26
+ messages = [
27
+ {"role": "system", "content": "Suggest one of the most famous place related to the timezone in user input."},
28
+ {"role": "user", "content": f"{timezone}"}
29
+ ]
30
+ # Get the response
31
+ response = client.chat_completions(messages)
32
+ print(response['choices'][0]['message']['content'])
33
+
34
+ return response['choices'][0]['message']['content']
35
 
36
  @tool
37
  def get_current_time_in_timezone(timezone: str) -> str:
 
70
 
71
  agent = CodeAgent(
72
  model=model,
73
+ tools=[final_answer,get_current_time_in_timezone,suggest_historic_place,image_generation_tool], ## add your tools here (don't remove final answer)
74
  max_steps=6,
75
  verbosity_level=1,
76
  grammar=None,