Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -515,54 +515,7 @@ def main():
|
|
515 |
|
516 |
|
517 |
|
518 |
-
|
519 |
-
|
520 |
-
# save_or_clone_to_cosmos_db special project
|
521 |
-
if st.session_state.selected_database:
|
522 |
-
database = st.session_state.client.get_database_client(st.session_state.selected_database)
|
523 |
-
containers = get_containers(database)
|
524 |
-
selected_container = st.sidebar.selectbox("๐ Select Container", containers)
|
525 |
|
526 |
-
if selected_container != st.session_state.selected_container:
|
527 |
-
st.session_state.selected_container = selected_container
|
528 |
-
st.session_state.selected_document_id = None
|
529 |
-
st.session_state.current_index = 0
|
530 |
-
st.rerun()
|
531 |
-
|
532 |
-
if st.session_state.selected_container:
|
533 |
-
container = database.get_container_client(st.session_state.selected_container)
|
534 |
-
|
535 |
-
# Add Export button
|
536 |
-
if st.button("๐ฆ Export Container Data"):
|
537 |
-
download_link = archive_current_container(st.session_state.selected_database, st.session_state.selected_container, st.session_state.client)
|
538 |
-
if download_link.startswith('<a'):
|
539 |
-
st.markdown(download_link, unsafe_allow_html=True)
|
540 |
-
else:
|
541 |
-
st.error(download_link)
|
542 |
-
|
543 |
-
# Fetch documents
|
544 |
-
st.session_state.documents = get_documents(container)
|
545 |
-
total_docs = len(st.session_state.documents)
|
546 |
-
|
547 |
-
# Add buttons for saving new document and cloning
|
548 |
-
if st.button("๐พ Save New Document"):
|
549 |
-
user_query = st.session_state.get('user_query', '')
|
550 |
-
ai_response = st.session_state.get('ai_response', '')
|
551 |
-
save_or_clone_to_cosmos_db(container, query=user_query, response=ai_response)
|
552 |
-
|
553 |
-
if st.button("๐ Clone Document"):
|
554 |
-
doc_to_clone = st.selectbox("Select document to clone", [doc['id'] for doc in st.session_state.documents])
|
555 |
-
if doc_to_clone:
|
556 |
-
save_or_clone_to_cosmos_db(container, clone_id=doc_to_clone)
|
557 |
-
|
558 |
-
# Display documents
|
559 |
-
if st.session_state.documents:
|
560 |
-
for doc in st.session_state.documents:
|
561 |
-
st.write(f"ID: {doc['id']}")
|
562 |
-
st.write(f"Query: {doc.get('query', 'N/A')}")
|
563 |
-
st.write(f"Response: {doc.get('response', 'N/A')}")
|
564 |
-
st.write("---")
|
565 |
-
|
566 |
|
567 |
|
568 |
|
@@ -580,6 +533,28 @@ def main():
|
|
580 |
# Fetch documents
|
581 |
documents = get_documents(container)
|
582 |
total_docs = len(documents)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
583 |
|
584 |
if total_docs > 5:
|
585 |
documents_to_display = documents[:5]
|
|
|
515 |
|
516 |
|
517 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
519 |
|
520 |
|
521 |
|
|
|
533 |
# Fetch documents
|
534 |
documents = get_documents(container)
|
535 |
total_docs = len(documents)
|
536 |
+
|
537 |
+
# Add buttons for saving new document and cloning
|
538 |
+
if st.button("๐พ Save New Document"):
|
539 |
+
user_query = st.session_state.get('user_query', '')
|
540 |
+
ai_response = st.session_state.get('ai_response', '')
|
541 |
+
save_or_clone_to_cosmos_db(container, query=user_query, response=ai_response)
|
542 |
+
|
543 |
+
if st.button("๐ Clone Document"):
|
544 |
+
doc_to_clone = st.selectbox("Select document to clone", [doc['id'] for doc in st.session_state.documents])
|
545 |
+
if doc_to_clone:
|
546 |
+
save_or_clone_to_cosmos_db(container, clone_id=doc_to_clone)
|
547 |
+
|
548 |
+
# Display documents
|
549 |
+
if st.session_state.documents:
|
550 |
+
for doc in st.session_state.documents:
|
551 |
+
st.write(f"ID: {doc['id']}")
|
552 |
+
st.write(f"Query: {doc.get('query', 'N/A')}")
|
553 |
+
st.write(f"Response: {doc.get('response', 'N/A')}")
|
554 |
+
st.write("---")
|
555 |
+
|
556 |
+
|
557 |
+
|
558 |
|
559 |
if total_docs > 5:
|
560 |
documents_to_display = documents[:5]
|