Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -98,7 +98,8 @@ def get_more_web_info(query):
|
|
98 |
|
99 |
def get_commercial_product_info(recommendation, disease_name):
|
100 |
"""Fetch commercial product information related to a pesticide recommendation.
|
101 |
-
If no relevant products are found, return default products based on
|
|
|
102 |
"""
|
103 |
indiamart_query = f"site:indiamart.com pesticide '{disease_name}' '{recommendation}'"
|
104 |
krishi_query = f"site:krishisevakendra.in/products pesticide '{disease_name}' '{recommendation}'"
|
@@ -109,15 +110,17 @@ def get_commercial_product_info(recommendation, disease_name):
|
|
109 |
# Merge results from both sources
|
110 |
results = indiamart_results + krishi_results
|
111 |
|
112 |
-
# If no products were found, use fallback defaults based on the detected issue
|
113 |
if not results:
|
114 |
-
|
115 |
-
|
116 |
-
|
|
|
|
|
|
|
117 |
results = [
|
118 |
{
|
119 |
"title": "UPL SAAF Carbendazin Mancozeb Bactericide",
|
120 |
-
"link": "https://www.amazon.in/UPL-SAAF-Carbendazinm12-Mancozeb63-Action/dp/B0DJLQRL44",
|
121 |
"snippet": "Bactericide for controlling bacterial infections."
|
122 |
},
|
123 |
{
|
@@ -126,16 +129,52 @@ def get_commercial_product_info(recommendation, disease_name):
|
|
126 |
"snippet": "Bactericide for effective bacterial infection management."
|
127 |
}
|
128 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
else:
|
130 |
results = [
|
131 |
{
|
132 |
"title": "Syngenta Actara Insecticide",
|
133 |
-
"link": "https://www.amazon.in/syngenta-Actara-Insect-Repellent-Insecticide/dp/B08W55XTHS",
|
134 |
"snippet": "Effective systemic insecticide for pest control."
|
135 |
},
|
136 |
{
|
137 |
-
"title": "
|
138 |
-
"link": "https://www.amazon.in/Cyhalothrin-Control-Eradication-Mosquitoes-Crawling/dp/B01N53VH1T",
|
139 |
"snippet": "Broad-spectrum insecticide for pest management."
|
140 |
}
|
141 |
]
|
@@ -144,6 +183,7 @@ def get_commercial_product_info(recommendation, disease_name):
|
|
144 |
|
145 |
|
146 |
|
|
|
147 |
def analyze_plant_image(image_path, plant_name, language):
|
148 |
try:
|
149 |
# Load the image
|
|
|
98 |
|
99 |
def get_commercial_product_info(recommendation, disease_name):
|
100 |
"""Fetch commercial product information related to a pesticide recommendation.
|
101 |
+
If no relevant products are found from web sources, return default products based on issue type:
|
102 |
+
bacterial, fungicide (disease), or insecticide.
|
103 |
"""
|
104 |
indiamart_query = f"site:indiamart.com pesticide '{disease_name}' '{recommendation}'"
|
105 |
krishi_query = f"site:krishisevakendra.in/products pesticide '{disease_name}' '{recommendation}'"
|
|
|
110 |
# Merge results from both sources
|
111 |
results = indiamart_results + krishi_results
|
112 |
|
|
|
113 |
if not results:
|
114 |
+
lower_disease = disease_name.lower()
|
115 |
+
lower_recommendation = recommendation.lower()
|
116 |
+
|
117 |
+
# Bacterial fallback
|
118 |
+
if ("bacteria" in lower_disease or "bacterial" in lower_disease or
|
119 |
+
"bacteria" in lower_recommendation or "bacterial" in lower_recommendation):
|
120 |
results = [
|
121 |
{
|
122 |
"title": "UPL SAAF Carbendazin Mancozeb Bactericide",
|
123 |
+
"link": "https://www.amazon.in/UPL-SAAF-Carbendazinm12-Mancozeb63-Action/dp/B0DJLQRL44?source=ps-sl-shoppingads-lpcontext&ref_=fplfs&psc=1&smid=A1BIAFERY87G8Q",
|
124 |
"snippet": "Bactericide for controlling bacterial infections."
|
125 |
},
|
126 |
{
|
|
|
129 |
"snippet": "Bactericide for effective bacterial infection management."
|
130 |
}
|
131 |
]
|
132 |
+
# Fungicide / Disease fallback
|
133 |
+
elif ("fungus" in lower_disease or "fungicide" in lower_recommendation or
|
134 |
+
"antibiotic" in lower_recommendation or "disease" in lower_disease):
|
135 |
+
results = [
|
136 |
+
{
|
137 |
+
"title": "Plantomycin Bio Organic Antibiotic Effective Disease",
|
138 |
+
"link": "https://www.amazon.in/Plantomycin-Bio-Organic-Antibiotic-Effective-Disease/dp/B0DRVVJKQ4?source=ps-sl-shoppingads-lpcontext&ref_=fplfs&psc=1&smid=A2PDMX630A5EG6",
|
139 |
+
"snippet": "Bio organic antibiotic for effective control of plant diseases."
|
140 |
+
},
|
141 |
+
{
|
142 |
+
"title": "WET-TREE Larvicide Thuringiensis Insecticide",
|
143 |
+
"link": "https://www.amazon.in/WET-TREE-Larvicide-Thuringiensis-Insecticide/dp/B0D6R72KHV?source=ps-sl-shoppingads-lpcontext&ref_=fplfs&psc=1&smid=A3V4YZ24A56I42",
|
144 |
+
"snippet": "Larvicide with thuringiensis for disease prevention."
|
145 |
+
},
|
146 |
+
{
|
147 |
+
"title": "WET-TREE Larvicide Thuringiensis Insecticide",
|
148 |
+
"link": "https://www.amazon.in/WET-TREE-Larvicide-Thuringiensis-Insecticide/dp/B0D6R72KHV?source=ps-sl-shoppingads-lpcontext&ref_=fplfs&psc=1&smid=A3V4YZ24A56I42",
|
149 |
+
"snippet": "Larvicide with thuringiensis for disease prevention."
|
150 |
+
}
|
151 |
+
]
|
152 |
+
# Insecticide fallback
|
153 |
+
elif ("insecticide" in lower_disease or "insect" in lower_disease or "pest" in lower_disease or
|
154 |
+
"insecticide" in lower_recommendation or "insect" in lower_recommendation or "pest" in lower_recommendation):
|
155 |
+
results = [
|
156 |
+
{
|
157 |
+
"title": "Syngenta Actara Insecticide",
|
158 |
+
"link": "https://www.amazon.in/syngenta-Actara-Insect-Repellent-Insecticide/dp/B08W55XTHS?source=ps-sl-shoppingads-lpcontext&ref_=fplfs&psc=1&smid=A3ABQWNNCUI42M",
|
159 |
+
"snippet": "Effective systemic insecticide for pest control."
|
160 |
+
},
|
161 |
+
{
|
162 |
+
"title": "Cyhalothrin Insecticide",
|
163 |
+
"link": "https://www.amazon.in/Cyhalothrin-Control-Eradication-Mosquitoes-Crawling/dp/B01N53VH1T?source=ps-sl-shoppingads-lpcontext&ref_=fplfs&psc=1&smid=A1ZSKCLHK592D5",
|
164 |
+
"snippet": "Broad-spectrum insecticide for pest management."
|
165 |
+
}
|
166 |
+
]
|
167 |
+
# Default fallback to insecticide if none of the above match
|
168 |
else:
|
169 |
results = [
|
170 |
{
|
171 |
"title": "Syngenta Actara Insecticide",
|
172 |
+
"link": "https://www.amazon.in/syngenta-Actara-Insect-Repellent-Insecticide/dp/B08W55XTHS?source=ps-sl-shoppingads-lpcontext&ref_=fplfs&psc=1&smid=A3ABQWNNCUI42M",
|
173 |
"snippet": "Effective systemic insecticide for pest control."
|
174 |
},
|
175 |
{
|
176 |
+
"title": "Cyhalothrin Insecticide",
|
177 |
+
"link": "https://www.amazon.in/Cyhalothrin-Control-Eradication-Mosquitoes-Crawling/dp/B01N53VH1T?source=ps-sl-shoppingads-lpcontext&ref_=fplfs&psc=1&smid=A1ZSKCLHK592D5",
|
178 |
"snippet": "Broad-spectrum insecticide for pest management."
|
179 |
}
|
180 |
]
|
|
|
183 |
|
184 |
|
185 |
|
186 |
+
|
187 |
def analyze_plant_image(image_path, plant_name, language):
|
188 |
try:
|
189 |
# Load the image
|