dhiegorp commited on
Commit
82e336d
·
verified ·
1 Parent(s): 35e57a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -3,6 +3,7 @@ import datetime
3
  import requests
4
  import pytz
5
  import yaml
 
6
  from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
@@ -14,7 +15,10 @@ def useless_random_facts() -> str :
14
  """A tool to generate random facts to entertain your users"""
15
  url = "https://uselessfacts.jsph.pl/api/v2/facts/random"
16
  try:
17
- return requests.get(url)
 
 
 
18
  except Exception as e:
19
  return f"Error fetching random facts: {str(e)}"
20
 
@@ -67,7 +71,7 @@ with open("prompts.yaml", 'r') as stream:
67
 
68
  agent = CodeAgent(
69
  model=model,
70
- tools=[useless_random_facts, get_current_time_in_timezone, final_answer], ## add your tools here (don't remove final answer)
71
  max_steps=6,
72
  verbosity_level=1,
73
  grammar=None,
 
3
  import requests
4
  import pytz
5
  import yaml
6
+ import json
7
  from tools.final_answer import FinalAnswerTool
8
 
9
  from Gradio_UI import GradioUI
 
15
  """A tool to generate random facts to entertain your users"""
16
  url = "https://uselessfacts.jsph.pl/api/v2/facts/random"
17
  try:
18
+ response = requests.get(url)
19
+ fact_as_json = json.loads(response.text)
20
+ funny_fact = fact_as_json["text"]
21
+ return funny_fact
22
  except Exception as e:
23
  return f"Error fetching random facts: {str(e)}"
24
 
 
71
 
72
  agent = CodeAgent(
73
  model=model,
74
+ tools=[quacquackgo, useless_random_facts, get_current_time_in_timezone, final_answer], ## add your tools here (don't remove final answer)
75
  max_steps=6,
76
  verbosity_level=1,
77
  grammar=None,