Update app.py
Browse files
app.py
CHANGED
@@ -173,35 +173,34 @@ elif input_type == 'Upload PDF':
|
|
173 |
st.markdown(message["content"])
|
174 |
|
175 |
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
llm_chain = create_chain(retriever)
|
181 |
|
182 |
-
|
183 |
-
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
|
205 |
-
|
206 |
-
|
207 |
-
|
|
|
173 |
st.markdown(message["content"])
|
174 |
|
175 |
|
176 |
+
# We initialize the quantized LLM from a local path.
|
177 |
+
# Currently most parameters are fixed but we can make them
|
178 |
+
# configurable.
|
179 |
+
llm_chain = create_chain(retriever)
|
|
|
180 |
|
181 |
+
# We take questions/instructions from the chat input to pass to the LLM
|
182 |
+
if user_prompt := st.chat_input("Your message here", key="user_input"):
|
183 |
|
184 |
+
# Add our input to the session state
|
185 |
+
st.session_state.messages.append(
|
186 |
+
{"role": "user", "content": user_prompt}
|
187 |
+
)
|
188 |
|
189 |
+
# Add our input to the chat window
|
190 |
+
with st.chat_message("user"):
|
191 |
+
st.markdown(user_prompt)
|
192 |
|
193 |
+
# Pass our input to the llm chain and capture the final responses.
|
194 |
+
# It is worth noting that the Stream Handler is already receiving the
|
195 |
+
# streaming response as the llm is generating. We get our response
|
196 |
+
# here once the llm has finished generating the complete response.
|
197 |
+
response = llm_chain.run(user_prompt)
|
198 |
|
199 |
+
# Add the response to the session state
|
200 |
+
st.session_state.messages.append(
|
201 |
+
{"role": "assistant", "content": response}
|
202 |
+
)
|
203 |
|
204 |
+
# Add the response to the chat window
|
205 |
+
with st.chat_message("assistant"):
|
206 |
+
st.markdown(response)
|