rairo commited on
Commit
74ab061
·
verified ·
1 Parent(s): 90696a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
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
- return text
 
 
 
 
 
 
 
 
 
 
 
 
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