srkdev384 commited on
Commit
7de5c6d
·
verified ·
1 Parent(s): 11399c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -155,20 +155,21 @@ def wiki_search(query: str) -> str:
155
  url = f"https://en.wikipedia.org/api/rest_v1/page/summary/{encoded_query}"
156
 
157
  try:
158
- response = requests.get(url, timeout=10)
159
 
160
- if response.status_code != 200:
161
- return "No Wikipedia page found."
162
 
163
- data = response.json()
 
 
 
 
 
 
164
 
165
- return {
166
- "title": data.get("title"),
167
- "summary": data.get("extract"),
168
- "url": data.get("content_urls", {}).get("desktop", {}).get("page"),
169
- }
170
  except Exception as e:
171
- return f"Error fetching Wikipedia data: {str(e)}"
172
 
173
  final_answer = FinalAnswerTool()
174
 
 
155
  url = f"https://en.wikipedia.org/api/rest_v1/page/summary/{encoded_query}"
156
 
157
  try:
158
+ response = requests.get(url, timeout=10)
159
 
160
+ if response.status_code != 200:
161
+ return "No Wikipedia page found."
162
 
163
+ data = response.json()
164
+
165
+ return {
166
+ "title": data.get("title"),
167
+ "summary": data.get("extract"),
168
+ "url": data.get("content_urls", {}).get("desktop", {}).get("page"),
169
+ }
170
 
 
 
 
 
 
171
  except Exception as e:
172
+ return f"Error fetching Wikipedia data: {str(e)}"
173
 
174
  final_answer = FinalAnswerTool()
175