danielkorat commited on
Commit
3a36f87
·
verified ·
1 Parent(s): f2950cf

Update my_tools.py

Browse files
Files changed (1) hide show
  1. my_tools.py +5 -3
my_tools.py CHANGED
@@ -4,6 +4,7 @@ import requests
4
  import pytz
5
  import os
6
  import datetime
 
7
 
8
  WOLFRAM_RESPONSE_KEYS = [
9
  "Result",
@@ -15,15 +16,16 @@ WOLFRAM_RESPONSE_KEYS = [
15
  @tool
16
  def wolfram(query: str)-> str:
17
  """
18
- A wrapper around Wolfram Alpha. Useful for when you need to answer questions about Math,
19
- Science, Technology, Culture, Society and Everyday Life. Input should be a search query."
 
20
  Args:
21
  query: search query.
22
  Returns:
23
  A string containing the answer for the query.
24
  """
25
  api_key = os.environ["WOLFRAM_API_KEY"]
26
- formatted_query = query
27
  url = f"http://api.wolframalpha.com/v2/query?appid={api_key}&input={formatted_query}&output=json&format=plaintext"
28
  for key in WOLFRAM_RESPONSE_KEYS:
29
  url += f"&includepodid={key}"
 
4
  import pytz
5
  import os
6
  import datetime
7
+ from urllib import parse
8
 
9
  WOLFRAM_RESPONSE_KEYS = [
10
  "Result",
 
16
  @tool
17
  def wolfram(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
  """
27
  api_key = os.environ["WOLFRAM_API_KEY"]
28
+ formatted_query = parse.quote_plus(query)
29
  url = f"http://api.wolframalpha.com/v2/query?appid={api_key}&input={formatted_query}&output=json&format=plaintext"
30
  for key in WOLFRAM_RESPONSE_KEYS:
31
  url += f"&includepodid={key}"