XMMR12 commited on
Commit
6f35cd3
·
verified ·
1 Parent(s): 6241817

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -18
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
- check=1
52
- while check:
53
- check+=1
54
- print(check)
55
- try:
56
- search_results = DDGS().text(keywords=query, max_results=3)
57
- if search_results:
58
- check=0
59
- except Exception as e :
60
- time.sleep(1)
61
- pass
62
- content=""
63
- for result in search_results:
64
- content+=fetch_page_content(result['href']);
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: