KeenWoo commited on
Commit
b04bcbc
Β·
verified Β·
1 Parent(s): 3103962

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -15
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: NEW HELPER FUNCTION ---
787
- # Add this function anywhere before the Gradio UI block
788
- def get_current_vectorstore_and_evaluate(vs_general, nlu_vs, playbook_vs, config, storage_path):
789
  """
790
- This helper function ensures we get the LATEST version of the global
791
- personal_vectorstore right before running the evaluation.
792
  """
793
- global personal_vectorstore
 
 
794
 
795
- # This is the same debug block from before, now inside the helper
796
  print("\n" + "="*20 + " PRE-EVALUATION CHECK (from app.py) " + "="*20)
797
- print(f"Type of personal_vectorstore: {type(personal_vectorstore)}")
 
798
  if personal_vectorstore and hasattr(personal_vectorstore.docstore, '_dict'):
799
- print(f"Number of documents in personal_vectorstore BEFORE evaluation: {len(personal_vectorstore.docstore._dict)}")
800
- # You can add the content check here too if desired
 
 
 
 
 
 
 
 
 
801
  else:
802
- print("personal_vectorstore is None or has no docstore.")
 
803
  print("="*78 + "\n")
804
 
805
- # Now call the evaluation function with the CURRENT vector store
806
  return run_comprehensive_evaluation(
807
  vs_general=vs_general,
808
  vs_personal=personal_vectorstore,
809
- nlu_vectorstore=nlu_vs,
810
- vs_playbook=playbook_vs,
811
  config=config,
812
  storage_path=storage_path
813
  )
814
- # --- END: NEW HELPER FUNCTION ---
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 ---