khartist29 commited on
Commit
3dd934b
·
verified ·
1 Parent(s): 29ec968

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -7
app.py CHANGED
@@ -4,19 +4,31 @@ 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_cutom_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:
@@ -51,7 +63,7 @@ with open("prompts.yaml", 'r') as stream:
51
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer], ## add your tools here (don't remove final answer)
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from typing import Tuple
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
+
13
  @tool
14
+ def get_anime_quotes() -> Tuple[str, str, str]:
15
+ """A tool that fetches a random anime quote.
 
16
  Args:
17
+ None
18
+
19
+ Returns:
20
+ A tuple containing the quote content, anime name, and character name.
21
  """
22
+ response = requests.get("https://animechan.io/api/v1/quotes/random")
23
+ if response.status_code == 200:
24
+ data = response.json()
25
+ if data["status"] == "success":
26
+ quote = data["data"]["content"]
27
+ anime = data["data"]["anime"]["name"]
28
+ character = data["data"]["character"]["name"]
29
+ return quote, anime, character
30
+ return "Failed to fetch quote", "", ""
31
+
32
 
33
  @tool
34
  def get_current_time_in_timezone(timezone: str) -> str:
 
63
 
64
  agent = CodeAgent(
65
  model=model,
66
+ tools=[final_answer, image_generation_tool, get_anime_quotes, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
67
  max_steps=6,
68
  verbosity_level=1,
69
  grammar=None,