Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -783,35 +783,48 @@ def check_test_file():
|
|
| 783 |
return f"β Failure. Test file not found at: {path}"
|
| 784 |
|
| 785 |
|
| 786 |
-
# --- START:
|
| 787 |
-
#
|
| 788 |
-
def get_current_vectorstore_and_evaluate(vs_general,
|
| 789 |
"""
|
| 790 |
-
This helper function ensures we get the LATEST version of
|
| 791 |
-
|
| 792 |
"""
|
| 793 |
-
global
|
|
|
|
|
|
|
| 794 |
|
| 795 |
-
#
|
| 796 |
print("\n" + "="*20 + " PRE-EVALUATION CHECK (from app.py) " + "="*20)
|
| 797 |
-
print(
|
|
|
|
| 798 |
if personal_vectorstore and hasattr(personal_vectorstore.docstore, '_dict'):
|
| 799 |
-
print(f"
|
| 800 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 801 |
else:
|
| 802 |
-
print("
|
|
|
|
| 803 |
print("="*78 + "\n")
|
| 804 |
|
| 805 |
-
# Now call the evaluation function with the CURRENT vector
|
| 806 |
return run_comprehensive_evaluation(
|
| 807 |
vs_general=vs_general,
|
| 808 |
vs_personal=personal_vectorstore,
|
| 809 |
-
nlu_vectorstore=
|
| 810 |
-
vs_playbook=
|
| 811 |
config=config,
|
| 812 |
storage_path=storage_path
|
| 813 |
)
|
| 814 |
-
# --- END:
|
| 815 |
|
| 816 |
|
| 817 |
# --- UI Definition ---
|
|
|
|
| 783 |
return f"β Failure. Test file not found at: {path}"
|
| 784 |
|
| 785 |
|
| 786 |
+
# --- START: DEFINITIVE FIX ---
|
| 787 |
+
# Replace your existing helper function with this one.
|
| 788 |
+
def get_current_vectorstore_and_evaluate(vs_general, nlu_vs_stale, playbook_vs_stale, config, storage_path):
|
| 789 |
"""
|
| 790 |
+
This helper function ensures we get the LATEST version of ALL global
|
| 791 |
+
vectorstores right before running the evaluation.
|
| 792 |
"""
|
| 793 |
+
# Re-fetch the CURRENT versions of the global variables, ignoring the stale
|
| 794 |
+
# ones passed in from the gr.State UI components.
|
| 795 |
+
global personal_vectorstore, nlu_vectorstore, playbook_vectorstore
|
| 796 |
|
| 797 |
+
# Debug block to prove the fix
|
| 798 |
print("\n" + "="*20 + " PRE-EVALUATION CHECK (from app.py) " + "="*20)
|
| 799 |
+
print("Fetching CURRENT state of all vector stores...")
|
| 800 |
+
|
| 801 |
if personal_vectorstore and hasattr(personal_vectorstore.docstore, '_dict'):
|
| 802 |
+
print(f" - β
Current personal_vectorstore has {len(personal_vectorstore.docstore._dict)} documents.")
|
| 803 |
+
else:
|
| 804 |
+
print(" - β Current personal_vectorstore is None or invalid.")
|
| 805 |
+
|
| 806 |
+
if nlu_vectorstore and hasattr(nlu_vectorstore.docstore, '_dict'):
|
| 807 |
+
print(f" - β
Current nlu_vectorstore has {len(nlu_vectorstore.docstore._dict)} documents.")
|
| 808 |
+
else:
|
| 809 |
+
print(" - β Current nlu_vectorstore is None or invalid.")
|
| 810 |
+
|
| 811 |
+
if playbook_vectorstore and hasattr(playbook_vectorstore.docstore, '_dict'):
|
| 812 |
+
print(f" - β
Current playbook_vectorstore has {len(playbook_vectorstore.docstore._dict)} documents.")
|
| 813 |
else:
|
| 814 |
+
print(" - β Current playbook_vectorstore is None or invalid.")
|
| 815 |
+
|
| 816 |
print("="*78 + "\n")
|
| 817 |
|
| 818 |
+
# Now call the evaluation function with the CURRENT, fully-loaded vector stores
|
| 819 |
return run_comprehensive_evaluation(
|
| 820 |
vs_general=vs_general,
|
| 821 |
vs_personal=personal_vectorstore,
|
| 822 |
+
nlu_vectorstore=nlu_vectorstore,
|
| 823 |
+
vs_playbook=playbook_vectorstore,
|
| 824 |
config=config,
|
| 825 |
storage_path=storage_path
|
| 826 |
)
|
| 827 |
+
# --- END: DEFINITIVE FIX ---
|
| 828 |
|
| 829 |
|
| 830 |
# --- UI Definition ---
|