Spaces:
Sleeping
Sleeping
tonyliu404
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -515,48 +515,23 @@ if recipe_submit and uploaded_image:
|
|
515 |
"""
|
516 |
),
|
517 |
]
|
518 |
-
with col2:
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
display_response(RAGresponse)
|
530 |
-
|
531 |
-
# elif uploaded_image is not None:
|
532 |
-
# with col1:
|
533 |
-
# # Open the image
|
534 |
-
# input_image = Image.open(uploaded_image)
|
535 |
-
|
536 |
-
# # Display the image
|
537 |
-
# st.image(input_image, caption="Uploaded Image.", use_container_width=True)
|
538 |
-
|
539 |
-
# # Classify the image and display the result
|
540 |
-
# predictions = classifyImage(input_image)
|
541 |
-
# fpredictions = ""
|
542 |
-
|
543 |
-
# # Show the top predictions with percentages
|
544 |
-
# st.write("Top Predictions:")
|
545 |
-
# for class_name, confidence in predictions:
|
546 |
-
# if int(confidence) > 0.05:
|
547 |
-
# fpredictions += f"{class_name}: {confidence:.2f}%,"
|
548 |
-
# if int(confidence) > 5:
|
549 |
-
# class_name = class_name.replace("_", " ")
|
550 |
-
# class_name = class_name.title()
|
551 |
-
# st.markdown(f"*{class_name}*: {confidence:.2f}%")
|
552 |
-
# print(fpredictions)
|
553 |
|
554 |
elif recipe_submit and query:
|
555 |
-
with col2:
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
display_response(response)
|
560 |
else:
|
561 |
st.warning('Please input an image or a query.', icon="π")
|
562 |
|
|
|
515 |
"""
|
516 |
),
|
517 |
]
|
518 |
+
with col2, st.spinner():
|
519 |
+
if query:
|
520 |
+
# Call the OpenAI API
|
521 |
+
openAIresponse = llm.invoke(openAICall)
|
522 |
+
print("AI CALL RESPONSE: ", openAIresponse.content, "END AI CALL RESONSE")
|
523 |
+
|
524 |
+
RAGresponse = get_response(openAIresponse.content + " " + query)
|
525 |
+
else:
|
526 |
+
RAGresponse = get_response(predictions[0][0])
|
527 |
+
print("RAGresponse: ", RAGresponse)
|
528 |
+
display_response(RAGresponse)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
|
530 |
elif recipe_submit and query:
|
531 |
+
with col2, st.spinner():
|
532 |
+
response = get_response(query)
|
533 |
+
print(response)
|
534 |
+
display_response(response)
|
|
|
535 |
else:
|
536 |
st.warning('Please input an image or a query.', icon="π")
|
537 |
|