Anesti commited on
Commit
d5cfb89
·
verified ·
1 Parent(s): ff5e99b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -6,6 +6,8 @@ import yaml
6
  from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
 
 
9
 
10
  @tool
11
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
@@ -32,7 +34,6 @@ def generate_image_with_prompt(prompt: str) -> str:
32
  @tool
33
  def random_fact() -> str:
34
  """Fetches a random fun fact."""
35
- import random
36
  facts = [
37
  "Honey never spoils.",
38
  "Octopuses have three hearts.",
@@ -42,16 +43,17 @@ def random_fact() -> str:
42
 
43
 
44
  @tool
45
- def tell_joke()-> str:
46
  """Returns a random joke."""
47
- import random
48
- jokes = [
49
- "Why don't skeletons fight each other? They don't have the guts.",
50
- "I told my wife she was drawing her eyebrows too high. She looked surprised.",
51
- "Why don’t scientists trust atoms? Because they make up everything!"
52
- ]
53
- return random.choice(jokes)
54
-
 
55
 
56
  @tool
57
  def get_current_time_in_timezone(timezone: str) -> str:
 
6
  from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
9
+ import random
10
+
11
 
12
  @tool
13
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
 
34
  @tool
35
  def random_fact() -> str:
36
  """Fetches a random fun fact."""
 
37
  facts = [
38
  "Honey never spoils.",
39
  "Octopuses have three hearts.",
 
43
 
44
 
45
  @tool
46
+ def tell_joke() -> str:
47
  """Returns a random joke."""
48
+ try:
49
+ jokes = [
50
+ "Why don't skeletons fight each other? They don't have the guts.",
51
+ "I told my wife she was drawing her eyebrows too high. She looked surprised.",
52
+ "Why don’t scientists trust atoms? Because they make up everything!"
53
+ ]
54
+ return random.choice(jokes)
55
+ except Exception as e:
56
+ return f"Error fetching joke: {str(e)}"
57
 
58
  @tool
59
  def get_current_time_in_timezone(timezone: str) -> str: