laverdes commited on
Commit
f674ad5
·
verified ·
1 Parent(s): 8367cf9

feat: add get_current_time_in_timezone tool

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -8,7 +8,7 @@ from tools.visit_webpage import VisitWebpageTool
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 my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
14
  #Keep this format for the description / args / args description but feel free to modify the tool
@@ -34,6 +34,17 @@ def get_current_time_in_timezone(timezone: str) -> str:
34
  except Exception as e:
35
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
36
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  final_answer = FinalAnswerTool()
39
  web_search = DuckDuckGoSearchTool()
@@ -58,7 +69,7 @@ with open("prompts.yaml", 'r') as stream:
58
 
59
  agent = CodeAgent(
60
  model=model,
61
- tools=[final_answer, web_search, visit_webpage], ## add your tools here (don't remove final answer)
62
  max_steps=6,
63
  verbosity_level=1,
64
  grammar=None,
 
8
 
9
  from Gradio_UI import GradioUI
10
 
11
+
12
  @tool
13
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
14
  #Keep this format for the description / args / args description but feel free to modify the tool
 
34
  except Exception as e:
35
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
36
 
37
+ @tool
38
+ def conversational_utterance(user_content:str)-> str:
39
+ """A tool that replies to a single casual query or message that does not require any other tool to be triggered
40
+ Args:
41
+ user_content: the message or query such as 'Hi!', 'How are you?', 'What are you?', 'tell me a joke'
42
+ """
43
+ messages = [
44
+ {"role": "user", "content": [{"type": "text", "text": user_content}]}
45
+ ]
46
+ return model(messages)
47
+
48
 
49
  final_answer = FinalAnswerTool()
50
  web_search = DuckDuckGoSearchTool()
 
69
 
70
  agent = CodeAgent(
71
  model=model,
72
+ tools=[final_answer, web_search, visit_webpage, get_current_time_in_timezone],
73
  max_steps=6,
74
  verbosity_level=1,
75
  grammar=None,