shivanis14 commited on
Commit
5d6545b
1 Parent(s): 11c6843

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -179,7 +179,7 @@ def analyze_processing_level(ingredients, brand_name, product_name, assistant_id
179
 
180
  run = client.beta.threads.runs.create_and_poll(
181
  thread_id=thread.id,
182
- assistant_id=assistant_id, # Replace with actual assistant ID
183
  include=["step_details.tool_calls[*].file_search.results[*].content"]
184
  )
185
 
@@ -212,7 +212,7 @@ def analyze_harmful_ingredients(ingredients, brand_name, product_name, assistant
212
 
213
  run = client.beta.threads.runs.create_and_poll(
214
  thread_id=thread.id,
215
- assistant_id=assistant_id, # Replace with actual assistant ID
216
  include=["step_details.tool_calls[*].file_search.results[*].content"]
217
  )
218
 
@@ -257,7 +257,7 @@ def analyze_claims(claims, assistant_id):
257
 
258
  run = client.beta.threads.runs.create_and_poll(
259
  thread_id=thread.id,
260
- assistant_id=assistant_id, # Replace with actual assistant ID
261
  include=["step_details.tool_calls[*].file_search.results[*].content"]
262
  )
263
 
@@ -452,13 +452,17 @@ def chatbot_response(user_input):
452
  harmful_ingredient_analysis = ""
453
  claims_analysis = ""
454
 
455
- if "analyze" in user_input.lower() and "http" in user_input.lower():
456
  # Extract image URL from user input
457
- image_url = user_input.split("http")[1].split()[0]
458
- image_url = "http" + image_url
 
 
 
 
459
 
460
  with st.spinner("Analyzing the product... This may take a moment."):
461
- product_info_from_db = json.loads(extract_data_from_product_image([image_url], data_extractor_url))
462
 
463
  if product_info_from_db:
464
  brand_name = product_info_from_db.get("brandName", "")
 
179
 
180
  run = client.beta.threads.runs.create_and_poll(
181
  thread_id=thread.id,
182
+ assistant_id=assistant_id,
183
  include=["step_details.tool_calls[*].file_search.results[*].content"]
184
  )
185
 
 
212
 
213
  run = client.beta.threads.runs.create_and_poll(
214
  thread_id=thread.id,
215
+ assistant_id=assistant_id,
216
  include=["step_details.tool_calls[*].file_search.results[*].content"]
217
  )
218
 
 
257
 
258
  run = client.beta.threads.runs.create_and_poll(
259
  thread_id=thread.id,
260
+ assistant_id=assistant_id,
261
  include=["step_details.tool_calls[*].file_search.results[*].content"]
262
  )
263
 
 
452
  harmful_ingredient_analysis = ""
453
  claims_analysis = ""
454
 
455
+ if "http:/" in user_input.lower() or "https:/" in user_input.lower():
456
  # Extract image URL from user input
457
+ if "," not in user_input:
458
+ image_urls.append(user_input)
459
+ else:
460
+ for url in user_input.split(","):
461
+ if "http:/" in url.lower() or "https:/" in url.lower():
462
+ image_urls.append(url)
463
 
464
  with st.spinner("Analyzing the product... This may take a moment."):
465
+ product_info_from_db = json.loads(extract_data_from_product_image(image_urls, data_extractor_url))
466
 
467
  if product_info_from_db:
468
  brand_name = product_info_from_db.get("brandName", "")