Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,6 +15,8 @@ prompt_template = """Answer the question only according to the information provi
|
|
15 |
## Question :
|
16 |
# {}"""
|
17 |
|
|
|
|
|
18 |
if not "stage" in st.session_state:
|
19 |
st.session_state.stage = "crawl-input"
|
20 |
elif st.session_state.stage == "remove-crawl-input-widgets":
|
@@ -35,11 +37,15 @@ if st.session_state.stage == "crawl-input":
|
|
35 |
st.session_state.stage = "remove-crawl-input-widgets"
|
36 |
|
37 |
if st.session_state.stage == "prompt-input":
|
|
|
|
|
|
|
38 |
prompt = st.chat_input("Ask the documentation a question!")
|
39 |
|
40 |
if prompt:
|
41 |
with st.chat_message("user"):
|
42 |
st.markdown(prompt)
|
|
|
43 |
results = st.session_state.collection.query(query_texts=[prompt],n_results=5)
|
44 |
infos = results["documents"][0]
|
45 |
|
@@ -63,4 +69,5 @@ if st.session_state.stage == "prompt-input":
|
|
63 |
full_response += chunk + " "
|
64 |
time.sleep(0.05)
|
65 |
message_placeholder.markdown(full_response + "▌")
|
66 |
-
message_placeholder.markdown(full_response)
|
|
|
|
15 |
## Question :
|
16 |
# {}"""
|
17 |
|
18 |
+
st.session_state.messages = []
|
19 |
+
|
20 |
if not "stage" in st.session_state:
|
21 |
st.session_state.stage = "crawl-input"
|
22 |
elif st.session_state.stage == "remove-crawl-input-widgets":
|
|
|
37 |
st.session_state.stage = "remove-crawl-input-widgets"
|
38 |
|
39 |
if st.session_state.stage == "prompt-input":
|
40 |
+
for message in st.session_state.messages:
|
41 |
+
with st.chat_message(message["role"]):
|
42 |
+
st.markdown(message)
|
43 |
prompt = st.chat_input("Ask the documentation a question!")
|
44 |
|
45 |
if prompt:
|
46 |
with st.chat_message("user"):
|
47 |
st.markdown(prompt)
|
48 |
+
st.session_state.messages.append({"role":"user","message":prompt})
|
49 |
results = st.session_state.collection.query(query_texts=[prompt],n_results=5)
|
50 |
infos = results["documents"][0]
|
51 |
|
|
|
69 |
full_response += chunk + " "
|
70 |
time.sleep(0.05)
|
71 |
message_placeholder.markdown(full_response + "▌")
|
72 |
+
message_placeholder.markdown(full_response)
|
73 |
+
st.session_state.messages.append({"role":"assistant","message":full_response})
|