Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,7 +39,7 @@ def perform_search(prompt):
|
|
| 39 |
try:
|
| 40 |
# HTTP GET-Anfrage an die Google Custom Search API
|
| 41 |
response = requests.get(url)
|
| 42 |
-
|
| 43 |
#soup = BeautifulSoup(response.content, 'html.parser')
|
| 44 |
#response_text = soup.find('body')
|
| 45 |
#return response_text.text
|
|
@@ -53,11 +53,11 @@ def perform_search(prompt):
|
|
| 53 |
#return results[0]
|
| 54 |
# Kombiniere die Ergebnisse zu einem String
|
| 55 |
result_text = '\n'.join(results)
|
| 56 |
-
return results[0]
|
| 57 |
# Formuliere die Antwort
|
| 58 |
search_query = f"{prompt} antworte kurz und knapp. antworte auf deutsch. du findest die antwort hier: {result_text}"
|
| 59 |
-
result = predict(search_query)
|
| 60 |
-
return result
|
| 61 |
return search_query
|
| 62 |
|
| 63 |
except requests.exceptions.RequestException as e:
|
|
|
|
| 39 |
try:
|
| 40 |
# HTTP GET-Anfrage an die Google Custom Search API
|
| 41 |
response = requests.get(url)
|
| 42 |
+
response.raise_for_status() # Wirft eine Exception, wenn die Anfrage fehlschlägt
|
| 43 |
#soup = BeautifulSoup(response.content, 'html.parser')
|
| 44 |
#response_text = soup.find('body')
|
| 45 |
#return response_text.text
|
|
|
|
| 53 |
#return results[0]
|
| 54 |
# Kombiniere die Ergebnisse zu einem String
|
| 55 |
result_text = '\n'.join(results)
|
| 56 |
+
#return results[0]
|
| 57 |
# Formuliere die Antwort
|
| 58 |
search_query = f"{prompt} antworte kurz und knapp. antworte auf deutsch. du findest die antwort hier: {result_text}"
|
| 59 |
+
#result = predict(search_query)
|
| 60 |
+
#return result
|
| 61 |
return search_query
|
| 62 |
|
| 63 |
except requests.exceptions.RequestException as e:
|