Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,8 +40,8 @@ def fetch_page_content(url: str):
|
|
| 40 |
text = soup.get_text(separator='\n', strip=True)
|
| 41 |
for each in ["Page not available","403 Forbidden"]:
|
| 42 |
if each in text:
|
| 43 |
-
return ""
|
| 44 |
-
return text[:
|
| 45 |
except Exception as e:
|
| 46 |
return f"Error fetching page: {str(e)}"
|
| 47 |
|
|
@@ -56,7 +56,7 @@ def search_full_plant_information(plant_name:str):
|
|
| 56 |
if search_results:
|
| 57 |
content=""
|
| 58 |
for result in search_results:
|
| 59 |
-
|
| 60 |
content+=fetch_page_content(result['href'])
|
| 61 |
time.sleep(2)
|
| 62 |
prompt = PROMPT_TEMPLATE.format(plant_name=plant_name, content=content)
|
|
|
|
| 40 |
text = soup.get_text(separator='\n', strip=True)
|
| 41 |
for each in ["Page not available","403 Forbidden"]:
|
| 42 |
if each in text:
|
| 43 |
+
return "No information found!"
|
| 44 |
+
return text[:3500] # Limit to 3.5k characters
|
| 45 |
except Exception as e:
|
| 46 |
return f"Error fetching page: {str(e)}"
|
| 47 |
|
|
|
|
| 56 |
if search_results:
|
| 57 |
content=""
|
| 58 |
for result in search_results:
|
| 59 |
+
content+=result['body']
|
| 60 |
content+=fetch_page_content(result['href'])
|
| 61 |
time.sleep(2)
|
| 62 |
prompt = PROMPT_TEMPLATE.format(plant_name=plant_name, content=content)
|