Update app.py
Browse files
app.py
CHANGED
|
@@ -253,18 +253,23 @@ if st.session_state.current_conversation:
|
|
| 253 |
# User Prompt
|
| 254 |
if len(convo) % 2 == 1:
|
| 255 |
last_user_msg = convo[-1]["text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
with st.spinner("Generating response..."):
|
| 257 |
try:
|
| 258 |
-
assistant_reply =
|
|
|
|
| 259 |
except Exception as e:
|
| 260 |
-
assistant_reply = "⚠️ Failed to generate response"
|
| 261 |
convo.append({"role": "assistant", "text": assistant_reply})
|
| 262 |
st.session_state.chat_sessions[st.session_state.current_conversation] = convo
|
| 263 |
st.rerun()
|
| 264 |
|
| 265 |
-
# --- Input Form at Bottom ---
|
| 266 |
st.markdown("---")
|
| 267 |
-
#
|
| 268 |
if st.button("📥 Export Conversation as PDF"):
|
| 269 |
pdf_bytes = generate_pdf(convo, st.session_state.current_conversation)
|
| 270 |
if pdf_bytes:
|
|
|
|
| 253 |
# User Prompt
|
| 254 |
if len(convo) % 2 == 1:
|
| 255 |
last_user_msg = convo[-1]["text"]
|
| 256 |
+
question_input, context_input = last_user_msg.split("<br><br>")
|
| 257 |
+
question_input = question_input.replace("Question: ", "")
|
| 258 |
+
context_input = context_input.replace("Context: ", "")
|
| 259 |
+
|
| 260 |
+
prompt = create_test_prompt(question_input, context_input, st.session_state.llama_tokenizer)
|
| 261 |
with st.spinner("Generating response..."):
|
| 262 |
try:
|
| 263 |
+
assistant_reply = get_llama_response(prompt)
|
| 264 |
+
|
| 265 |
except Exception as e:
|
| 266 |
+
assistant_reply = f"⚠️ Failed to generate response"
|
| 267 |
convo.append({"role": "assistant", "text": assistant_reply})
|
| 268 |
st.session_state.chat_sessions[st.session_state.current_conversation] = convo
|
| 269 |
st.rerun()
|
| 270 |
|
|
|
|
| 271 |
st.markdown("---")
|
| 272 |
+
# Export PDF
|
| 273 |
if st.button("📥 Export Conversation as PDF"):
|
| 274 |
pdf_bytes = generate_pdf(convo, st.session_state.current_conversation)
|
| 275 |
if pdf_bytes:
|