Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -71,24 +71,38 @@ for message in st.session_state.messages:
|
|
| 71 |
with st.chat_message(message["role"]):
|
| 72 |
st.markdown(message["content"])
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
st.markdown(query)
|
| 83 |
-
|
| 84 |
-
# Chat with OpenAI
|
| 85 |
openai_api_key = st.secrets["OPENAI_API_KEY"]
|
| 86 |
-
response = chat_with_openai(
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
|
| 94 |
|
|
|
|
| 71 |
with st.chat_message(message["role"]):
|
| 72 |
st.markdown(message["content"])
|
| 73 |
|
| 74 |
+
|
| 75 |
+
# User input
|
| 76 |
+
if prompt := st.chat_input("Enter your query"):
|
| 77 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 78 |
+
with st.chat_message("user"):
|
| 79 |
+
st.markdown(prompt)
|
| 80 |
+
|
| 81 |
+
with st.chat_message("assistant"):
|
|
|
|
|
|
|
|
|
|
| 82 |
openai_api_key = st.secrets["OPENAI_API_KEY"]
|
| 83 |
+
response = chat_with_openai(prompt, vectordb, openai_api_key)
|
| 84 |
+
st.markdown(response)
|
| 85 |
+
|
| 86 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|
| 87 |
|
| 88 |
+
# # Query input
|
| 89 |
+
# query = st.text_input("Enter your query", "")
|
| 90 |
+
|
| 91 |
+
# if st.button("Send"):
|
| 92 |
+
# if query:
|
| 93 |
+
# # Add user query to chat history
|
| 94 |
+
# st.session_state.messages.append({"role": "user", "content": query})
|
| 95 |
+
# with st.chat_message("user"):
|
| 96 |
+
# st.markdown(query)
|
| 97 |
+
|
| 98 |
+
# # Chat with OpenAI
|
| 99 |
+
# openai_api_key = st.secrets["OPENAI_API_KEY"]
|
| 100 |
+
# response = chat_with_openai(query, vectordb, openai_api_key)
|
| 101 |
+
|
| 102 |
+
# # Add AI response to chat history
|
| 103 |
+
# st.session_state.messages.append({"role": "assistant", "content": response})
|
| 104 |
+
# with st.chat_message("assistant"):
|
| 105 |
+
# st.markdown(response)
|
| 106 |
|
| 107 |
|
| 108 |
|