shivanis14
commited on
Commit
•
2168033
1
Parent(s):
ec20771
Update app.py
Browse files
app.py
CHANGED
@@ -107,12 +107,12 @@ assistant3 = client.beta.assistants.update(
|
|
107 |
tool_resources={"file_search": {"vector_store_ids": [vector_store3.id]}},
|
108 |
)
|
109 |
|
110 |
-
def analyze_processing_level(ingredients, assistant_id):
|
111 |
thread = client.beta.threads.create(
|
112 |
messages=[
|
113 |
{
|
114 |
"role": "user",
|
115 |
-
"content": f"Categorize
|
116 |
}
|
117 |
]
|
118 |
)
|
@@ -137,12 +137,12 @@ def analyze_processing_level(ingredients, assistant_id):
|
|
137 |
processing_level_str = message_content.value
|
138 |
return processing_level_str
|
139 |
|
140 |
-
def analyze_harmful_ingredients(ingredients, assistant_id):
|
141 |
thread = client.beta.threads.create(
|
142 |
messages=[
|
143 |
{
|
144 |
"role": "user",
|
145 |
-
"content": "Provide detailed information about
|
146 |
}
|
147 |
]
|
148 |
)
|
@@ -303,10 +303,15 @@ def main():
|
|
303 |
# Display a message while analyzing
|
304 |
with st.spinner("Analyzing the product... This may take a moment."):
|
305 |
# Perform analysis
|
306 |
-
processing_level =
|
307 |
-
harmful_ingredient_analysis =
|
308 |
-
|
309 |
-
|
|
|
|
|
|
|
|
|
|
|
310 |
# Generate final analysis
|
311 |
final_analysis = generate_final_analysis(
|
312 |
product_info,
|
|
|
107 |
tool_resources={"file_search": {"vector_store_ids": [vector_store3.id]}},
|
108 |
)
|
109 |
|
110 |
+
def analyze_processing_level(ingredients, product_info, assistant_id):
|
111 |
thread = client.beta.threads.create(
|
112 |
messages=[
|
113 |
{
|
114 |
"role": "user",
|
115 |
+
"content": f"Categorize product {product_info["brandName"] + product_info["productName"]} that has following ingredients: {', '.join(ingredients)} into Group A, Group B, or Group C based on the document. The output must only be the group category name (Group A, Group B, or Group C) alongwith the definition of the respective category. If the group category cannot be determined, output 'NOT FOUND'.",
|
116 |
}
|
117 |
]
|
118 |
)
|
|
|
137 |
processing_level_str = message_content.value
|
138 |
return processing_level_str
|
139 |
|
140 |
+
def analyze_harmful_ingredients(ingredients, product_info, assistant_id):
|
141 |
thread = client.beta.threads.create(
|
142 |
messages=[
|
143 |
{
|
144 |
"role": "user",
|
145 |
+
"content": "Provide detailed information about product " + product_info["brandName"] + product_info["productName"] +" that has following ingredients: " + ', '.join(ingredients) + ". The output must be in JSON format: {<ingredient_name>: <information from the document>}. If information about an ingredient is not found in the documents, the value for that ingredient must start with the prefix '(NOT FOUND IN DOCUMENT)' followed by the LLM's response based on its own knowledge.",
|
146 |
}
|
147 |
]
|
148 |
)
|
|
|
303 |
# Display a message while analyzing
|
304 |
with st.spinner("Analyzing the product... This may take a moment."):
|
305 |
# Perform analysis
|
306 |
+
processing_level = ""
|
307 |
+
harmful_ingredient_analysis = ""
|
308 |
+
if len(ingredients_list) > 0:
|
309 |
+
processing_level = analyze_processing_level(ingredients_list, product_info, assistant1.id)
|
310 |
+
harmful_ingredient_analysis = analyze_harmful_ingredients(ingredients_list, product_info, assistant2.id)
|
311 |
+
claims_analysis = ""
|
312 |
+
if len(claims_list) > 0:
|
313 |
+
claims_analysis = analyze_claims(claims_list, assistant3.id)
|
314 |
+
|
315 |
# Generate final analysis
|
316 |
final_analysis = generate_final_analysis(
|
317 |
product_info,
|