danielkorat commited on
Commit
47e0c42
·
verified ·
1 Parent(s): bd99edb

Update my_tools.py

Browse files
Files changed (1) hide show
  1. my_tools.py +6 -5
my_tools.py CHANGED
@@ -9,18 +9,17 @@ from urllib import parse
9
  WOLFRAM_RESPONSE_KEYS = [
10
  "Result",
11
  "Solution",
12
- "RealSolution",
13
  ]
14
 
15
 
16
  @tool
17
  def knowledge_and_intelligence_tool(query: str)-> str:
18
  """
19
- A wrapper around Wolfram Alpha. Useful for when you need to answer questions about
20
- Math, Geography, Demographics, Sports, Music, Science, Technology, Culture, Society
21
  and Everyday Life. Input should be a search query."
22
  Args:
23
- query: search query.
24
  Returns:
25
  A string containing the answer for the query.
26
  """
@@ -40,7 +39,9 @@ def knowledge_and_intelligence_tool(query: str)-> str:
40
  if data.get("error"): # Check if there's an error in the response
41
  return f"Error: {data['error'].get('info', 'Unable to fetch Wolfram response.')}"
42
 
43
- response = data.get("queryresult").get("pods")[0].get("subpods")[0].get("plaintext")
 
 
44
  return response
45
 
46
  except requests.exceptions.RequestException as e:
 
9
  WOLFRAM_RESPONSE_KEYS = [
10
  "Result",
11
  "Solution",
 
12
  ]
13
 
14
 
15
  @tool
16
  def knowledge_and_intelligence_tool(query: str)-> str:
17
  """
18
+ An intelligent tool that answers questions about Math, Geography,
19
+ Demographics, Sports, Music, Science, Technology, Culture, Society
20
  and Everyday Life. Input should be a search query."
21
  Args:
22
+ query: The search query.
23
  Returns:
24
  A string containing the answer for the query.
25
  """
 
39
  if data.get("error"): # Check if there's an error in the response
40
  return f"Error: {data['error'].get('info', 'Unable to fetch Wolfram response.')}"
41
 
42
+ response = ""
43
+ for result in data.get("queryresult").get("pods")[0].get("subpods"):
44
+ response += f"{result.get('plaintext')}; "
45
  return response
46
 
47
  except requests.exceptions.RequestException as e: