File size: 946 Bytes
a1551fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)