Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -175,9 +175,6 @@ class SmartShoppingAssistant:
|
|
| 175 |
Analyze this image and extract products and their quantities.
|
| 176 |
If quantities aren't specified, assume 1.
|
| 177 |
List each item with its quantity
|
| 178 |
-
Think it through and extract items in this format: {quantity} {product name}
|
| 179 |
-
|
| 180 |
-
Do not extract anything else and ignore punctuation and special characters.
|
| 181 |
"""
|
| 182 |
try:
|
| 183 |
response = model.generate_content([prompt, image])
|
|
@@ -192,7 +189,19 @@ class SmartShoppingAssistant:
|
|
| 192 |
text = ""
|
| 193 |
for page in pdf_reader.pages:
|
| 194 |
text += page.extract_text()
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
except Exception as e:
|
| 197 |
return f"Error processing PDF: {str(e)}"
|
| 198 |
|
|
|
|
| 175 |
Analyze this image and extract products and their quantities.
|
| 176 |
If quantities aren't specified, assume 1.
|
| 177 |
List each item with its quantity
|
|
|
|
|
|
|
|
|
|
| 178 |
"""
|
| 179 |
try:
|
| 180 |
response = model.generate_content([prompt, image])
|
|
|
|
| 189 |
text = ""
|
| 190 |
for page in pdf_reader.pages:
|
| 191 |
text += page.extract_text()
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
prompt = """
|
| 195 |
+
extract products and their quantities from this text.
|
| 196 |
+
If quantities aren't specified, assume 1.
|
| 197 |
+
List each item with its quantity and nothing else
|
| 198 |
+
"""
|
| 199 |
+
try:
|
| 200 |
+
response = model.generate_content([prompt,text])
|
| 201 |
+
return response.text
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
|
| 205 |
except Exception as e:
|
| 206 |
return f"Error processing PDF: {str(e)}"
|
| 207 |
|