Chem-210-Autograder / pages /2_Retrieval_Demo.py
anthony-chen's picture
kek
a1551fc
raw
history blame contribute delete
946 Bytes
import streamlit as st
from generator2 import response
from retrieve import retrieve_molecule_index
from PIL import Image
st.title("Retrieval System Demo")
if "messages" not in st.session_state:
st.session_state.messages = []
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# Use text_area for text input with a smaller height
text_input = st.text_input("Indicate a desired molecule from our database")
if st.button("Submit"):
if text_input:
with st.chat_message("user"):
st.markdown(f"Sending request to Milvus...")
index = int(retrieve_molecule_index(text_input)[0])
image_path = f"test/CID_{index}.png"
image = Image.open(image_path).convert('RGB')
with st.chat_message("AI"):
st.write("Retrieved from our database:")
st.image(image, use_column_width=True)