Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -229,6 +229,12 @@ def save_conversation(chat_histories, session_id):
|
|
| 229 |
except Exception as e:
|
| 230 |
st.error(f"Error during Git operations: {e}")
|
| 231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
|
| 233 |
def page1():
|
| 234 |
try:
|
|
@@ -313,12 +319,22 @@ def page1():
|
|
| 313 |
|
| 314 |
# Calculate duration
|
| 315 |
duration = end_time - start_time
|
| 316 |
-
|
| 317 |
-
# You can use Streamlit's text function to display the timing
|
| 318 |
st.text(f"Response time: {duration:.2f} seconds")
|
| 319 |
|
| 320 |
st.session_state['chat_history_page1'].append(("Bot", response, "new"))
|
| 321 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
|
| 323 |
# Display new messages at the bottom
|
| 324 |
new_messages = st.session_state['chat_history_page1'][-2:]
|
|
@@ -327,15 +343,6 @@ def page1():
|
|
| 327 |
new_messages_placeholder.markdown(f"<div style='background-color: {background_color}; padding: 10px; border-radius: 10px; margin: 10px;'>{chat[0]}: {chat[1]}</div>", unsafe_allow_html=True)
|
| 328 |
|
| 329 |
|
| 330 |
-
|
| 331 |
-
# Save the chat historie in sepearte files
|
| 332 |
-
save_conversation(st.session_state['chat_history_page1'], st.session_state['session_id'], 1)
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
# Display the current working directory after save_conversation
|
| 337 |
-
#current_dir = os.getcwd()
|
| 338 |
-
#st.text(f"Current working directory after save_conversation: {current_dir}")
|
| 339 |
|
| 340 |
# Clear the input field after the query is made
|
| 341 |
query = ""
|
|
@@ -426,20 +433,27 @@ def page2():
|
|
| 426 |
with get_openai_callback() as cb:
|
| 427 |
response = chain.run(input_documents=docs, question=full_query)
|
| 428 |
response = handle_no_answer(response) # Process the response through the new function
|
|
|
|
|
|
|
| 429 |
|
| 430 |
# Stop timing
|
| 431 |
end_time = time.time()
|
| 432 |
|
| 433 |
# Calculate duration
|
| 434 |
duration = end_time - start_time
|
| 435 |
-
|
| 436 |
-
# You can use Streamlit's text function to display the timing
|
| 437 |
st.text(f"Response time: {duration:.2f} seconds")
|
| 438 |
|
| 439 |
st.session_state['chat_history_page2'].append(("Bot", response, "new"))
|
| 440 |
-
|
| 441 |
-
#
|
| 442 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
|
| 444 |
# Display new messages at the bottom
|
| 445 |
new_messages = st.session_state['chat_history_page2'][-2:]
|
|
@@ -537,18 +551,28 @@ def page3():
|
|
| 537 |
with get_openai_callback() as cb:
|
| 538 |
response = chain.run(input_documents=docs, question=full_query)
|
| 539 |
response = handle_no_answer(response) # Process the response through the new function
|
|
|
|
|
|
|
| 540 |
|
| 541 |
# Stop timing
|
| 542 |
end_time = time.time()
|
| 543 |
|
| 544 |
# Calculate duration
|
| 545 |
duration = end_time - start_time
|
| 546 |
-
|
| 547 |
-
# You can use Streamlit's text function to display the timing
|
| 548 |
st.text(f"Response time: {duration:.2f} seconds")
|
| 549 |
|
| 550 |
st.session_state['chat_history_page3'].append(("Bot", response, "new"))
|
| 551 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 552 |
|
| 553 |
# Display new messages at the bottom
|
| 554 |
new_messages = st.session_state['chat_history_page3'][-2:]
|
|
@@ -603,6 +627,7 @@ def main():
|
|
| 603 |
# Sidebar content
|
| 604 |
with st.sidebar:
|
| 605 |
st.title('BinDoc GmbH')
|
|
|
|
| 606 |
st.markdown("Experience revolutionary interaction with BinDocs Chat App, leveraging state-of-the-art AI technology.")
|
| 607 |
add_vertical_space(1)
|
| 608 |
page = st.sidebar.selectbox("Choose a page", ["KH_Reform", "Kennzahlenbuch 100 Kennzahlen", "Kosten- und Strukturdaten der Krankenhäuser", "Form"])
|
|
|
|
| 229 |
except Exception as e:
|
| 230 |
st.error(f"Error during Git operations: {e}")
|
| 231 |
|
| 232 |
+
|
| 233 |
+
def display_session_id():
|
| 234 |
+
session_id = st.session_state['session_id']
|
| 235 |
+
st.sidebar.markdown(f"**Your Session ID:** `{session_id}`")
|
| 236 |
+
st.sidebar.markdown("Use this ID for reference in communications or feedback.")
|
| 237 |
+
|
| 238 |
|
| 239 |
def page1():
|
| 240 |
try:
|
|
|
|
| 319 |
|
| 320 |
# Calculate duration
|
| 321 |
duration = end_time - start_time
|
|
|
|
|
|
|
| 322 |
st.text(f"Response time: {duration:.2f} seconds")
|
| 323 |
|
| 324 |
st.session_state['chat_history_page1'].append(("Bot", response, "new"))
|
| 325 |
|
| 326 |
+
# Combine chat histories from all pages
|
| 327 |
+
all_chat_histories = [
|
| 328 |
+
st.session_state['chat_history_page1'],
|
| 329 |
+
st.session_state['chat_history_page2'],
|
| 330 |
+
st.session_state['chat_history_page3']
|
| 331 |
+
]
|
| 332 |
+
|
| 333 |
+
# Save the combined chat histories
|
| 334 |
+
save_conversation(all_chat_histories, st.session_state['session_id'])
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
|
| 338 |
|
| 339 |
# Display new messages at the bottom
|
| 340 |
new_messages = st.session_state['chat_history_page1'][-2:]
|
|
|
|
| 343 |
new_messages_placeholder.markdown(f"<div style='background-color: {background_color}; padding: 10px; border-radius: 10px; margin: 10px;'>{chat[0]}: {chat[1]}</div>", unsafe_allow_html=True)
|
| 344 |
|
| 345 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 346 |
|
| 347 |
# Clear the input field after the query is made
|
| 348 |
query = ""
|
|
|
|
| 433 |
with get_openai_callback() as cb:
|
| 434 |
response = chain.run(input_documents=docs, question=full_query)
|
| 435 |
response = handle_no_answer(response) # Process the response through the new function
|
| 436 |
+
|
| 437 |
+
|
| 438 |
|
| 439 |
# Stop timing
|
| 440 |
end_time = time.time()
|
| 441 |
|
| 442 |
# Calculate duration
|
| 443 |
duration = end_time - start_time
|
|
|
|
|
|
|
| 444 |
st.text(f"Response time: {duration:.2f} seconds")
|
| 445 |
|
| 446 |
st.session_state['chat_history_page2'].append(("Bot", response, "new"))
|
| 447 |
+
|
| 448 |
+
# Combine chat histories from all pages
|
| 449 |
+
all_chat_histories = [
|
| 450 |
+
st.session_state['chat_history_page1'],
|
| 451 |
+
st.session_state['chat_history_page2'],
|
| 452 |
+
st.session_state['chat_history_page3']
|
| 453 |
+
]
|
| 454 |
+
|
| 455 |
+
# Save the combined chat histories
|
| 456 |
+
save_conversation(all_chat_histories, st.session_state['session_id'])
|
| 457 |
|
| 458 |
# Display new messages at the bottom
|
| 459 |
new_messages = st.session_state['chat_history_page2'][-2:]
|
|
|
|
| 551 |
with get_openai_callback() as cb:
|
| 552 |
response = chain.run(input_documents=docs, question=full_query)
|
| 553 |
response = handle_no_answer(response) # Process the response through the new function
|
| 554 |
+
|
| 555 |
+
|
| 556 |
|
| 557 |
# Stop timing
|
| 558 |
end_time = time.time()
|
| 559 |
|
| 560 |
# Calculate duration
|
| 561 |
duration = end_time - start_time
|
|
|
|
|
|
|
| 562 |
st.text(f"Response time: {duration:.2f} seconds")
|
| 563 |
|
| 564 |
st.session_state['chat_history_page3'].append(("Bot", response, "new"))
|
| 565 |
|
| 566 |
+
# Combine chat histories from all pages
|
| 567 |
+
all_chat_histories = [
|
| 568 |
+
st.session_state['chat_history_page1'],
|
| 569 |
+
st.session_state['chat_history_page2'],
|
| 570 |
+
st.session_state['chat_history_page3']
|
| 571 |
+
]
|
| 572 |
+
|
| 573 |
+
# Save the combined chat histories
|
| 574 |
+
save_conversation(all_chat_histories, st.session_state['session_id'])
|
| 575 |
+
|
| 576 |
|
| 577 |
# Display new messages at the bottom
|
| 578 |
new_messages = st.session_state['chat_history_page3'][-2:]
|
|
|
|
| 627 |
# Sidebar content
|
| 628 |
with st.sidebar:
|
| 629 |
st.title('BinDoc GmbH')
|
| 630 |
+
display_session_id() # Display the session ID in the sidebar
|
| 631 |
st.markdown("Experience revolutionary interaction with BinDocs Chat App, leveraging state-of-the-art AI technology.")
|
| 632 |
add_vertical_space(1)
|
| 633 |
page = st.sidebar.selectbox("Choose a page", ["KH_Reform", "Kennzahlenbuch 100 Kennzahlen", "Kosten- und Strukturdaten der Krankenhäuser", "Form"])
|