Update app.py
Browse files
app.py
CHANGED
@@ -261,7 +261,7 @@ def generate_response(db, query_text, previous_context):
|
|
261 |
|
262 |
return full_response
|
263 |
|
264 |
-
def streamlit_app(
|
265 |
st.title("BioModelsRAG")
|
266 |
|
267 |
search_str = st.text_input("Enter search query:")
|
@@ -299,30 +299,29 @@ def streamlit_app(db):
|
|
299 |
|
300 |
db = create_vector_db(final_items)
|
301 |
|
302 |
-
|
303 |
-
st.write("Models have been processed and added to the database.")
|
304 |
|
305 |
-
if db:
|
306 |
-
@st.cache_resource
|
307 |
-
def get_messages(db):
|
308 |
-
if "messages" not in st.session_state:
|
309 |
-
st.session_state.messages = []
|
310 |
-
return st.session_state.messages
|
311 |
-
st.session_state.messages = get_messages()
|
312 |
|
313 |
-
|
314 |
-
|
315 |
-
|
|
|
|
|
|
|
316 |
|
317 |
-
|
318 |
-
|
319 |
-
st.
|
320 |
-
response = generate_response(db, query_text, st.session_state)
|
321 |
|
322 |
-
|
323 |
-
|
|
|
|
|
324 |
|
325 |
-
|
|
|
|
|
|
|
326 |
|
327 |
if __name__ == "__main__":
|
328 |
streamlit_app()
|
|
|
261 |
|
262 |
return full_response
|
263 |
|
264 |
+
def streamlit_app():
|
265 |
st.title("BioModelsRAG")
|
266 |
|
267 |
search_str = st.text_input("Enter search query:")
|
|
|
299 |
|
300 |
db = create_vector_db(final_items)
|
301 |
|
302 |
+
st.write("Models have been processed and added to the database.")
|
|
|
303 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
|
305 |
+
@st.cache_resource
|
306 |
+
def get_messages(db):
|
307 |
+
if "messages" not in st.session_state:
|
308 |
+
st.session_state.messages = []
|
309 |
+
return st.session_state.messages
|
310 |
+
st.session_state.messages = get_messages()
|
311 |
|
312 |
+
for message in st.session_state.messages:
|
313 |
+
with st.chat_message(message["role"]):
|
314 |
+
st.markdown(message["content"])
|
|
|
315 |
|
316 |
+
if prompt := st.chat_input(query_text):
|
317 |
+
st.chat_message("user").markdown(prompt)
|
318 |
+
st.session_state.messages.append({"role": "user", "content":prompt})
|
319 |
+
response = generate_response(db, query_text, st.session_state)
|
320 |
|
321 |
+
with st.chat_message("assistant"):
|
322 |
+
st.markdown(response)
|
323 |
+
|
324 |
+
st.session_state.messages.append({"role":"assistant","content":response})
|
325 |
|
326 |
if __name__ == "__main__":
|
327 |
streamlit_app()
|