Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -527,11 +527,6 @@ def page3():
|
|
| 527 |
st.error("File not found. Please check the file path.")
|
| 528 |
return
|
| 529 |
|
| 530 |
-
display_chat_history(st.session_state['chat_history_page3'])
|
| 531 |
-
new_messages_placeholder = st.empty()
|
| 532 |
-
query = st.text_input("Geben Sie hier Ihre Frage ein / Enter your question here:")
|
| 533 |
-
|
| 534 |
-
|
| 535 |
# Initialize CromA client
|
| 536 |
chroma_client = chromadb.Client()
|
| 537 |
|
|
@@ -554,6 +549,38 @@ def page3():
|
|
| 554 |
)
|
| 555 |
st.session_state["documents_added"] = True
|
| 556 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 557 |
# Simple interaction
|
| 558 |
if st.button("Test Button"):
|
| 559 |
st.write("Button clicked.")
|
|
|
|
| 527 |
st.error("File not found. Please check the file path.")
|
| 528 |
return
|
| 529 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 530 |
# Initialize CromA client
|
| 531 |
chroma_client = chromadb.Client()
|
| 532 |
|
|
|
|
| 549 |
)
|
| 550 |
st.session_state["documents_added"] = True
|
| 551 |
|
| 552 |
+
|
| 553 |
+
display_chat_history(st.session_state['chat_history_page3'])
|
| 554 |
+
new_messages_placeholder = st.empty()
|
| 555 |
+
query = st.text_input("Geben Sie hier Ihre Frage ein / Enter your question here:")
|
| 556 |
+
|
| 557 |
+
# Handling query input
|
| 558 |
+
if query:
|
| 559 |
+
full_query = ask_bot(query)
|
| 560 |
+
st.session_state['chat_history_page3'].append(("User", query, "new"))
|
| 561 |
+
|
| 562 |
+
# Start timing for response
|
| 563 |
+
start_time = time.time()
|
| 564 |
+
|
| 565 |
+
# Querying the CromA collection
|
| 566 |
+
results = collection.query(
|
| 567 |
+
query_texts=[full_query],
|
| 568 |
+
n_results=5 # Adjust the number of results as needed
|
| 569 |
+
)
|
| 570 |
+
|
| 571 |
+
# Calculate the response duration
|
| 572 |
+
end_time = time.time()
|
| 573 |
+
duration = end_time - start_time
|
| 574 |
+
|
| 575 |
+
# Process and display response from CromA results
|
| 576 |
+
if results:
|
| 577 |
+
# TODO: Adjust the following logic based on CromA's actual result structure
|
| 578 |
+
response = f"Top result: {results[0]['text']}" # Example response using the first result
|
| 579 |
+
else:
|
| 580 |
+
response = "No results found for your query."
|
| 581 |
+
|
| 582 |
+
st.session_state['chat_history_page3'].append(("Eve", response, "new"))
|
| 583 |
+
|
| 584 |
# Simple interaction
|
| 585 |
if st.button("Test Button"):
|
| 586 |
st.write("Button clicked.")
|