streamlit app
This commit is contained in:
parent
f8f94b947e
commit
cdbbc0e8a5
36
app.py
Normal file
36
app.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import streamlit as st
|
||||||
|
from rag import RAG
|
||||||
|
|
||||||
|
llm_model_path = '/Users/peportier/llm/a/a/zephyr-7b-beta.Q5_K_M.gguf'
|
||||||
|
embed_model_name = 'intfloat/multilingual-e5-large'
|
||||||
|
collection_name = 'cera'
|
||||||
|
chromadb_path = './chromadb'
|
||||||
|
|
||||||
|
rag = RAG(llm_model_path, embed_model_name, collection_name, chromadb_path)
|
||||||
|
|
||||||
|
st.title("CERA Chat")
|
||||||
|
|
||||||
|
if st.sidebar.button("Nouvelle conversation"):
|
||||||
|
st.session_state.messages = []
|
||||||
|
rag.reset_history()
|
||||||
|
|
||||||
|
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"])
|
||||||
|
|
||||||
|
if prompt := st.chat_input("Comment puis-je vous aider ?"):
|
||||||
|
st.session_state.messages.append({"role": "user", "content": prompt})
|
||||||
|
with st.chat_message("user"):
|
||||||
|
st.markdown(prompt)
|
||||||
|
|
||||||
|
with st.chat_message("assistant"):
|
||||||
|
message_placeholder = st.empty()
|
||||||
|
full_response = ""
|
||||||
|
for response in rag.chat(prompt):
|
||||||
|
full_response += response
|
||||||
|
message_placeholder.markdown(full_response + "▌")
|
||||||
|
message_placeholder.markdown(full_response)
|
||||||
|
st.session_state.messages.append({"role": "assistant", "content": full_response})
|
Loading…
Reference in New Issue
Block a user