danielkorat commited on
Commit
85625b4
·
verified ·
1 Parent(s): dbde0cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -73,13 +73,15 @@ def wolfram_alpha(query: str)-> str:
73
  url = f"http://api.wolframalpha.com/v2/query?appid={api_key}&input={formatted_query}&output=json&format=plaintext"
74
  for key in WOLFRAM_RESPONSE_KEYS:
75
  url += f"&includepodid={key}"
76
- print(f"\nURL:\n{url}")
77
 
78
  try:
79
  response = requests.get(url)
80
  response.raise_for_status() # Raise an exception for HTTP errors
81
 
82
- if query_result := response.json().get("queryresult") is None or query_result.get("error"): # Check if there's an error in the response
 
 
83
  return f"Error: {query_result['error'].get('msg', 'Unable to fetch Wolfram response.')}"
84
 
85
  if pods := query_result.get("pods") is None:
 
73
  url = f"http://api.wolframalpha.com/v2/query?appid={api_key}&input={formatted_query}&output=json&format=plaintext"
74
  for key in WOLFRAM_RESPONSE_KEYS:
75
  url += f"&includepodid={key}"
76
+ print(f"\nWolfram URL:\n{url}")
77
 
78
  try:
79
  response = requests.get(url)
80
  response.raise_for_status() # Raise an exception for HTTP errors
81
 
82
+ query_result = response.json().get("queryresult")
83
+
84
+ if query_result is None or query_result.get("error"): # Check if there's an error in the response
85
  return f"Error: {query_result['error'].get('msg', 'Unable to fetch Wolfram response.')}"
86
 
87
  if pods := query_result.get("pods") is None: