Update app.py
Browse files
app.py
CHANGED
|
@@ -48,24 +48,20 @@ def fetch_page_content(url: str):
|
|
| 48 |
def search_full_plant_information(plant_name:str):
|
| 49 |
""" """
|
| 50 |
query = f"{plant_name} plant medicinal uses scientific information site:.edu OR site:.gov OR site:.org"
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
prompt = PROMPT_TEMPLATE.format(plant_name=plant_name, content=content)
|
| 66 |
-
response = requests.get(f"{specialtoken}/{prompt}")
|
| 67 |
-
print (response)
|
| 68 |
-
return response.text
|
| 69 |
|
| 70 |
DB_NAME="plants.db"
|
| 71 |
def save_to_db(plant_data: Dict) -> bool:
|
|
|
|
| 48 |
def search_full_plant_information(plant_name:str):
|
| 49 |
""" """
|
| 50 |
query = f"{plant_name} plant medicinal uses scientific information site:.edu OR site:.gov OR site:.org"
|
| 51 |
+
search_results=""
|
| 52 |
+
try:
|
| 53 |
+
search_results = DDGS().text(keywords=query, max_results=3)
|
| 54 |
+
except Exception as e :
|
| 55 |
+
pass
|
| 56 |
+
if search_results:
|
| 57 |
+
content=""
|
| 58 |
+
for result in search_results:
|
| 59 |
+
content+=fetch_page_content(result['href']);
|
| 60 |
+
prompt = PROMPT_TEMPLATE.format(plant_name=plant_name, content=content)
|
| 61 |
+
response = requests.get(f"{specialtoken}/{prompt}")
|
| 62 |
+
print (response)
|
| 63 |
+
return response.text
|
| 64 |
+
return "No data Found!"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
DB_NAME="plants.db"
|
| 67 |
def save_to_db(plant_data: Dict) -> bool:
|