Spaces:
Running
Running
kausthubkannan17
commited on
Commit
·
f8db355
1
Parent(s):
a828a8b
feat: chat history export
Browse files- pages/chat.py +20 -6
- pages/upload_url.py +1 -1
pages/chat.py
CHANGED
@@ -1,10 +1,15 @@
|
|
1 |
import streamlit as st
|
2 |
from app import disable_sidebar, initialize_models
|
3 |
-
from model import DrakeLM
|
4 |
-
from utilis import Processing
|
5 |
|
6 |
disable_sidebar()
|
7 |
-
col1, col2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
col1.title('Chat with Drake!')
|
10 |
if col2.button("Home"):
|
@@ -13,10 +18,14 @@ if col2.button("Home"):
|
|
13 |
universal_chat = st.toggle("Universal Chat")
|
14 |
st.caption("Note: Universal Chat uses the complete DB to retrieve context, use it with caution")
|
15 |
|
16 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
st.session_state.messages = []
|
20 |
|
21 |
# Display chat messages from history on app rerun
|
22 |
for message in st.session_state.messages:
|
@@ -38,6 +47,11 @@ if prompt := st.chat_input("Ask Drake your questions"):
|
|
38 |
else:
|
39 |
response = drake.ask_llm(query, metadata_filter=st.session_state["metadata"])
|
40 |
|
|
|
|
|
|
|
41 |
with st.chat_message("assistant"):
|
42 |
st.markdown(response)
|
43 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from app import disable_sidebar, initialize_models
|
|
|
|
|
3 |
|
4 |
disable_sidebar()
|
5 |
+
col1, col2= st.columns([3, 1.6])
|
6 |
+
|
7 |
+
if "messages" not in st.session_state:
|
8 |
+
st.session_state.messages = []
|
9 |
+
|
10 |
+
if "chat_notes" not in st.session_state:
|
11 |
+
st.session_state.chat_notes = f""""""
|
12 |
+
st.session_state.encoded_text = st.session_state.chat_notes.encode('utf-8')
|
13 |
|
14 |
col1.title('Chat with Drake!')
|
15 |
if col2.button("Home"):
|
|
|
18 |
universal_chat = st.toggle("Universal Chat")
|
19 |
st.caption("Note: Universal Chat uses the complete DB to retrieve context, use it with caution")
|
20 |
|
21 |
+
st.download_button(
|
22 |
+
label="Export",
|
23 |
+
data=st.session_state.encoded_text,
|
24 |
+
file_name='chat_history.md',
|
25 |
+
mime='text/markdown',
|
26 |
+
)
|
27 |
|
28 |
+
st.divider()
|
|
|
29 |
|
30 |
# Display chat messages from history on app rerun
|
31 |
for message in st.session_state.messages:
|
|
|
47 |
else:
|
48 |
response = drake.ask_llm(query, metadata_filter=st.session_state["metadata"])
|
49 |
|
50 |
+
st.session_state.chat_notes += query + "\n" + response + "\n\n"
|
51 |
+
st.session_state.encoded_text = st.session_state.chat_notes.encode('utf-8')
|
52 |
+
|
53 |
with st.chat_message("assistant"):
|
54 |
st.markdown(response)
|
55 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
56 |
+
|
57 |
+
|
pages/upload_url.py
CHANGED
@@ -49,7 +49,7 @@ if video_url:
|
|
49 |
encoded_text = notes.encode('utf-8')
|
50 |
st.success("Notes generated successfully")
|
51 |
if st.download_button(
|
52 |
-
label="Download
|
53 |
data=encoded_text,
|
54 |
file_name='your_notes.md',
|
55 |
mime='text/markdown',
|
|
|
49 |
encoded_text = notes.encode('utf-8')
|
50 |
st.success("Notes generated successfully")
|
51 |
if st.download_button(
|
52 |
+
label="Download your notes",
|
53 |
data=encoded_text,
|
54 |
file_name='your_notes.md',
|
55 |
mime='text/markdown',
|