ChIrish06 commited on
Commit
6bab3bb
·
verified ·
1 Parent(s): 50b23d7

Update app.py

Browse files

Adding a requests.json() tool as it is desired by the agent for certain web based questions.

Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -9,6 +9,7 @@ from Gradio_UI import GradioUI
9
  import requests
10
 
11
  from bs4 import BeautifulSoup
 
12
 
13
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
14
  @tool
@@ -45,6 +46,16 @@ def webpage_header_get(url:str)-> str: #it's import to specify the return type
45
  """
46
  response = requests.get(url)
47
  return response.headers
 
 
 
 
 
 
 
 
 
 
48
  @tool
49
  def webpage_contents_soup_paragraphs(response_content:bytes)->list:
50
  '''
@@ -162,7 +173,7 @@ agent = CodeAgent(
162
  model=model,
163
  tools=[final_answer, image_generation_tool,webpage_contents_get,
164
  webpage_header_get, webpage_contents_soup_links, webpage_contents_soup_paragraphs,
165
- summarize_and_answer_from_web], ## add your tools here (don't remove final answer)
166
  max_steps=6,
167
  verbosity_level=1,
168
  grammar=None,
 
9
  import requests
10
 
11
  from bs4 import BeautifulSoup
12
+ import json
13
 
14
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
15
  @tool
 
46
  """
47
  response = requests.get(url)
48
  return response.headers
49
+
50
+ @tool
51
+ def webpage_json_get(url:str)-> json: #it's import to specify the return type
52
+ #Keep this format for the description / args / args description but feel free to modify the tool
53
+ """A simple function to grab json formatted data from a webpage.
54
+ Args:
55
+ url: string The URL the contents of which the tool will get
56
+ """
57
+ response = requests.get(url)
58
+ return response.json()
59
  @tool
60
  def webpage_contents_soup_paragraphs(response_content:bytes)->list:
61
  '''
 
173
  model=model,
174
  tools=[final_answer, image_generation_tool,webpage_contents_get,
175
  webpage_header_get, webpage_contents_soup_links, webpage_contents_soup_paragraphs,
176
+ summarize_and_answer_from_web, webpage_json_get], ## add your tools here (don't remove final answer)
177
  max_steps=6,
178
  verbosity_level=1,
179
  grammar=None,