Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -187,7 +187,10 @@ user_agents = [
|
|
| 187 |
|
| 188 |
@tool
|
| 189 |
def gresb(query: str) -> str:
|
| 190 |
-
"""Processes a question, retrieves relevant context, and generates a response.
|
|
|
|
|
|
|
|
|
|
| 191 |
base_url = "https://www.gresb.com/nl-en?s="
|
| 192 |
search_url = f"{base_url}{query.replace(' ', '+')}"
|
| 193 |
|
|
@@ -216,8 +219,9 @@ def gresb(query: str) -> str:
|
|
| 216 |
article_response = requests.get(article_url, headers=headers)
|
| 217 |
|
| 218 |
if article_response.status_code == 200:
|
| 219 |
-
# Extract and return the
|
| 220 |
-
|
|
|
|
| 221 |
else:
|
| 222 |
return f"Failed to retrieve the article page. Status code: {article_response.status_code}"
|
| 223 |
else:
|
|
|
|
| 187 |
|
| 188 |
@tool
|
| 189 |
def gresb(query: str) -> str:
|
| 190 |
+
"""Processes a question, retrieves relevant context, and generates a response.
|
| 191 |
+
1. article_text
|
| 192 |
+
2. article_url
|
| 193 |
+
"""
|
| 194 |
base_url = "https://www.gresb.com/nl-en?s="
|
| 195 |
search_url = f"{base_url}{query.replace(' ', '+')}"
|
| 196 |
|
|
|
|
| 219 |
article_response = requests.get(article_url, headers=headers)
|
| 220 |
|
| 221 |
if article_response.status_code == 200:
|
| 222 |
+
# Extract the article text and return it with the URL
|
| 223 |
+
article_text = extract_article_text(article_response.content)
|
| 224 |
+
return f"Article Text: {article_text}\n\nArticle URL: {article_url}"
|
| 225 |
else:
|
| 226 |
return f"Failed to retrieve the article page. Status code: {article_response.status_code}"
|
| 227 |
else:
|