iamTangsang commited on
Commit
e7b5772
·
verified ·
1 Parent(s): 7dd891f

Add: get_random_cat_facts tool

Browse files
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -4,10 +4,28 @@ 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
  """A tool that does nothing yet
@@ -69,7 +87,7 @@ with open("prompts.yaml", 'r') as stream:
69
 
70
  agent = CodeAgent(
71
  model=model,
72
- tools=[final_answer, get_current_time_in_timezone, search_for_information], ## add your tools here (don't remove final answer)
73
  max_steps=6,
74
  verbosity_level=1,
75
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ import json
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 get_random_cat_facts() -> str:
14
+ """A tool that gives random facts about cats.
15
+ Args:
16
+ None
17
+ """
18
+ try:
19
+ response = requests.get("https://catfact.ninja/fact")
20
+ response = response.json()
21
+ fact = response['fact']
22
+ return fact
23
+ except Exception as e:
24
+ return f"Error: {str(e)}"
25
+
26
+
27
+
28
+
29
  @tool
30
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
31
  """A tool that does nothing yet
 
87
 
88
  agent = CodeAgent(
89
  model=model,
90
+ tools=[final_answer, get_current_time_in_timezone, search_for_information, get_random_cat_facts], ## add your tools here (don't remove final answer)
91
  max_steps=6,
92
  verbosity_level=1,
93
  grammar=None,