Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -145,9 +145,15 @@ def get_today_matches() -> str:
|
|
| 145 |
return result
|
| 146 |
|
| 147 |
@tool
|
| 148 |
-
def wiki_search(query: str) ->
|
| 149 |
"""
|
| 150 |
Fetches a short summary from Wikipedia for a given topic.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
"""
|
| 152 |
|
| 153 |
encoded_query = urllib.parse.quote(query)
|
|
@@ -157,7 +163,7 @@ def wiki_search(query: str) -> str:
|
|
| 157 |
response = requests.get(url, timeout=10)
|
| 158 |
|
| 159 |
if response.status_code != 200:
|
| 160 |
-
return "No Wikipedia page found."
|
| 161 |
|
| 162 |
data = response.json()
|
| 163 |
|
|
@@ -168,7 +174,7 @@ def wiki_search(query: str) -> str:
|
|
| 168 |
}
|
| 169 |
|
| 170 |
except Exception as e:
|
| 171 |
-
return
|
| 172 |
|
| 173 |
final_answer = FinalAnswerTool()
|
| 174 |
|
|
|
|
| 145 |
return result
|
| 146 |
|
| 147 |
@tool
|
| 148 |
+
def wiki_search(query: str) -> dict:
|
| 149 |
"""
|
| 150 |
Fetches a short summary from Wikipedia for a given topic.
|
| 151 |
+
|
| 152 |
+
Args:
|
| 153 |
+
query: The topic or keyword to search on Wikipedia.
|
| 154 |
+
|
| 155 |
+
Returns:
|
| 156 |
+
A dictionary containing the page title, summary, and URL.
|
| 157 |
"""
|
| 158 |
|
| 159 |
encoded_query = urllib.parse.quote(query)
|
|
|
|
| 163 |
response = requests.get(url, timeout=10)
|
| 164 |
|
| 165 |
if response.status_code != 200:
|
| 166 |
+
return {"error": "No Wikipedia page found."}
|
| 167 |
|
| 168 |
data = response.json()
|
| 169 |
|
|
|
|
| 174 |
}
|
| 175 |
|
| 176 |
except Exception as e:
|
| 177 |
+
return {"error": str(e)}
|
| 178 |
|
| 179 |
final_answer = FinalAnswerTool()
|
| 180 |
|