orbulat commited on
Commit
2edbbb3
·
verified ·
1 Parent(s): 10b2a99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -12
app.py CHANGED
@@ -10,20 +10,28 @@ from Gradio_UI import GradioUI
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
  def get_dad_jokes(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
- try:
21
- response = requests.get("https://icanhazdadjoke.com/", headers={"Accept": "text/plain"})
22
- response.raise_for_status()
23
- joke = response.text.strip()
24
- return f"Dad Joke: {joke}"
25
- except requests.RequestException as e:
26
- return f"Failed to fetch a joke: {e}"
 
 
 
 
27
 
28
  @tool
29
  def get_current_time_in_timezone(timezone: str) -> str:
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
  def get_dad_jokes(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
+ """
14
+ A tool that returns a random dad joke from a hardcoded list.
15
+
16
  Args:
17
+ arg1: The first argument (not used)
18
+ arg2: The second argument (used to select a joke index)
19
+
20
+ Returns:
21
+ A dad joke as a string.
22
  """
23
+ jokes = [
24
+ "Why don't skeletons fight each other? They don't have the guts.",
25
+ "I used to play piano by ear, but now I use my hands.",
26
+ "Why did the scarecrow win an award? Because he was outstanding in his field.",
27
+ "I only know 25 letters of the alphabet. I don't know y.",
28
+ "What do you call fake spaghetti? An impasta.",
29
+ "Why couldn't the bicycle stand up by itself? It was two-tired."
30
+ ]
31
+
32
+ # Use modulo to safely loop through the jokes
33
+ index = arg2 % len(jokes)
34
+ return f"Dad Joke: {jokes[index]}"
35
 
36
  @tool
37
  def get_current_time_in_timezone(timezone: str) -> str: