Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -509,7 +509,6 @@ def page2():
|
|
509 |
|
510 |
def page3():
|
511 |
try:
|
512 |
-
# Style adjustments for the Streamlit page
|
513 |
st.markdown("""
|
514 |
<style>
|
515 |
#MainMenu {visibility: hidden;}
|
@@ -517,7 +516,6 @@ def page3():
|
|
517 |
</style>
|
518 |
""", unsafe_allow_html=True)
|
519 |
|
520 |
-
# Layout configuration
|
521 |
col1, col2 = st.columns([3, 1])
|
522 |
with col1:
|
523 |
st.title("Kosten- und Strukturdaten der Krankenhäuser")
|
@@ -527,40 +525,36 @@ def page3():
|
|
527 |
image = Image.open(image_path)
|
528 |
st.image(image, use_column_width='always')
|
529 |
|
530 |
-
|
531 |
-
display_chat_history(st.session_state['chat_history_page3'])
|
532 |
|
533 |
-
# Input for new user query
|
534 |
query = st.text_input("Geben Sie hier Ihre Frage ein / Enter your question here:")
|
535 |
|
536 |
if query:
|
537 |
-
# Convert the query text to a vector
|
538 |
query_vector = text_to_vector(query)
|
|
|
|
|
|
|
|
|
|
|
539 |
|
540 |
-
#
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
similarity_score = match["score"]
|
547 |
-
response_message = f"Matched Text: {matched_text} - Score: {similarity_score:.2f}"
|
548 |
-
st.write(response_message)
|
549 |
-
# Append the response to the chat history
|
550 |
-
st.session_state['chat_history_page3'].append(("Eve", response_message))
|
551 |
|
552 |
-
#
|
553 |
st.session_state['chat_history_page3'].append(("User", query))
|
|
|
|
|
554 |
|
555 |
-
# Save the updated chat history
|
556 |
-
|
557 |
-
# save_conversation(st.session_state['chat_history_page3'], st.session_state['session_id'])
|
558 |
|
559 |
except Exception as e:
|
560 |
st.error(f"An unexpected error occurred: {e}")
|
561 |
|
562 |
-
|
563 |
-
|
564 |
|
565 |
def page4():
|
566 |
try:
|
|
|
509 |
|
510 |
def page3():
|
511 |
try:
|
|
|
512 |
st.markdown("""
|
513 |
<style>
|
514 |
#MainMenu {visibility: hidden;}
|
|
|
516 |
</style>
|
517 |
""", unsafe_allow_html=True)
|
518 |
|
|
|
519 |
col1, col2 = st.columns([3, 1])
|
520 |
with col1:
|
521 |
st.title("Kosten- und Strukturdaten der Krankenhäuser")
|
|
|
525 |
image = Image.open(image_path)
|
526 |
st.image(image, use_column_width='always')
|
527 |
|
528 |
+
display_chat_history(st.session_state.get('chat_history_page3', []))
|
|
|
529 |
|
|
|
530 |
query = st.text_input("Geben Sie hier Ihre Frage ein / Enter your question here:")
|
531 |
|
532 |
if query:
|
|
|
533 |
query_vector = text_to_vector(query)
|
534 |
+
# Ensure the vector is in the correct format for Pinecone
|
535 |
+
query_vector = query_vector.tolist() if isinstance(query_vector, np.ndarray) else query_vector
|
536 |
+
|
537 |
+
# Query the Pinecone index
|
538 |
+
results = pc.query(index=index_name, vector=query_vector, top_k=5)
|
539 |
|
540 |
+
# Process and display results
|
541 |
+
for result in results['matches']:
|
542 |
+
matched_id = result['id']
|
543 |
+
score = result['score']
|
544 |
+
# Assuming you have metadata to display, adjust as necessary
|
545 |
+
st.write(f"Matched ID: {matched_id}, Score: {score}")
|
|
|
|
|
|
|
|
|
|
|
546 |
|
547 |
+
# Update chat history
|
548 |
st.session_state['chat_history_page3'].append(("User", query))
|
549 |
+
for result in results['matches']:
|
550 |
+
st.session_state['chat_history_page3'].append(("Result", f"Matched ID: {result['id']}, Score: {result['score']}"))
|
551 |
|
552 |
+
# Save the updated chat history
|
553 |
+
save_conversation(st.session_state['chat_history_page3'], st.session_state['session_id'])
|
|
|
554 |
|
555 |
except Exception as e:
|
556 |
st.error(f"An unexpected error occurred: {e}")
|
557 |
|
|
|
|
|
558 |
|
559 |
def page4():
|
560 |
try:
|