JustusI commited on
Commit
5c1f652
·
verified ·
1 Parent(s): a6779f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -16
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
- # Query input
75
- query = st.text_input("Enter your query", "")
76
-
77
- if st.button("Send"):
78
- if query:
79
- # Add user query to chat history
80
- st.session_state.messages.append({"role": "user", "content": query})
81
- with st.chat_message("user"):
82
- st.markdown(query)
83
-
84
- # Chat with OpenAI
85
  openai_api_key = st.secrets["OPENAI_API_KEY"]
86
- response = chat_with_openai(query, vectordb, openai_api_key)
 
 
 
87
 
88
- # Add AI response to chat history
89
- st.session_state.messages.append({"role": "assistant", "content": response})
90
- with st.chat_message("assistant"):
91
- st.markdown(response)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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