Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,9 +60,9 @@ Please provide a helpful response based on the insurance document content above.
|
|
| 60 |
messages.append(msg)
|
| 61 |
# Get response from Azure OpenAI
|
| 62 |
response = self.azure_client.chat.completions.create(
|
| 63 |
-
model="gpt-4o-mini,
|
| 64 |
messages=messages,
|
| 65 |
-
max_tokens=
|
| 66 |
temperature=0.7
|
| 67 |
)
|
| 68 |
bot_response = response.choices[0].message.content
|
|
@@ -82,27 +82,7 @@ def main():
|
|
| 82 |
st.session_state.pdf_processed = False
|
| 83 |
st.session_state.chat_history = []
|
| 84 |
# Sidebar for PDF upload and settings
|
| 85 |
-
|
| 86 |
-
st.header("📁 Upload Insurance Document")
|
| 87 |
-
uploaded_file = st.file_uploader("Choose a PDF file", type="pdf")
|
| 88 |
-
if uploaded_file is not None:
|
| 89 |
-
if st.button("Process PDF"):
|
| 90 |
-
with st.spinner("Processing your insurance document..."):
|
| 91 |
-
# Extract text from PDF
|
| 92 |
-
text_content = st.session_state.chatbot.extract_text_from_pdf(uploaded_file)
|
| 93 |
-
if text_content:
|
| 94 |
-
st.session_state.chatbot.pdf_content = text_content
|
| 95 |
-
st.session_state.pdf_processed = True
|
| 96 |
-
st.success("Insurance document processed successfully!")
|
| 97 |
-
# Show PDF summary
|
| 98 |
-
st.subheader("Document Preview")
|
| 99 |
-
st.text_area(
|
| 100 |
-
"First 500 characters:",
|
| 101 |
-
text_content[:500] + "..." if len(text_content) > 500 else text_content,
|
| 102 |
-
height=100
|
| 103 |
-
)
|
| 104 |
-
else:
|
| 105 |
-
st.error("Failed to process PDF")
|
| 106 |
# Clear conversation
|
| 107 |
if st.button("Xóa lịch sử"):
|
| 108 |
st.session_state.chatbot.conversation_history = []
|
|
|
|
| 60 |
messages.append(msg)
|
| 61 |
# Get response from Azure OpenAI
|
| 62 |
response = self.azure_client.chat.completions.create(
|
| 63 |
+
model="gpt-4o-mini",
|
| 64 |
messages=messages,
|
| 65 |
+
max_tokens=300, #TODO
|
| 66 |
temperature=0.7
|
| 67 |
)
|
| 68 |
bot_response = response.choices[0].message.content
|
|
|
|
| 82 |
st.session_state.pdf_processed = False
|
| 83 |
st.session_state.chat_history = []
|
| 84 |
# Sidebar for PDF upload and settings
|
| 85 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
# Clear conversation
|
| 87 |
if st.button("Xóa lịch sử"):
|
| 88 |
st.session_state.chatbot.conversation_history = []
|