Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Required imports
|
2 |
+
import streamlit as st
|
3 |
+
from anjibot_logging import append_to_sheet
|
4 |
+
from rag import handle_query
|
5 |
+
|
6 |
+
|
7 |
+
def main():
|
8 |
+
st.title("Ask Anjibot 2.0")
|
9 |
+
|
10 |
+
if "messages" not in st.session_state:
|
11 |
+
st.session_state.messages = []
|
12 |
+
|
13 |
+
for message in st.session_state.messages:
|
14 |
+
with st.chat_message(message["role"]):
|
15 |
+
st.markdown(message["content"])
|
16 |
+
|
17 |
+
if prompt := st.chat_input("Ask me anything"):
|
18 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
19 |
+
with st.chat_message("user"):
|
20 |
+
st.markdown(prompt)
|
21 |
+
|
22 |
+
with st.chat_message("assistant"):
|
23 |
+
response = st.write_stream(handle_query(prompt))
|
24 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|
25 |
+
|
26 |
+
append_to_sheet(prompt, response)
|
27 |
+
|
28 |
+
if __name__ == "__main__":
|
29 |
+
main()
|
30 |
+
|
31 |
+
|