Spaces:
Running
Running
File size: 1,915 Bytes
afd56bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #!/usr/bin/env python3
"""
Uruchamia ewaluacj臋 jako艣ci odpowiedzi LangGraph (DeepEval).
Skrypt ten jest skr贸tem pozwalaj膮cym na 艂atwe w艂膮czanie test贸w LLMOps.
"""
import os
import sys
import subprocess
import shutil
def main():
print("==============================================")
print(" Uruchamianie test贸w DeepEval (Faithfulness) ")
print("==============================================")
# 2. Uruchamiany konkretny zestaw testowy
target_test = os.path.join(
os.path.dirname(__file__), "..", "tests", "test_deepeval_rag.py"
)
print(f"[*] Wykorzystywany zbi贸r test贸w: {target_test}")
# Znajd藕 'deepeval' - albo w PATH, albo w sys.executable's Scripts folder
deepeval_bin = shutil.which("deepeval")
if not deepeval_bin:
deepeval_bin = os.path.join(
os.path.dirname(sys.executable), "Scripts", "deepeval.exe"
)
if not os.path.exists(deepeval_bin):
print("[!] Biblioteka 'deepeval' nieznaleziona.")
print("Aby uruchomi膰 ewaluacj臋 lokalnie wpisz:")
print(" pip install -r requirements-dev.txt")
sys.exit(1)
print(f"[*] Wykonywanie przez {deepeval_bin} ...")
env = os.environ.copy()
env["PYTHONPATH"] = os.path.join(os.path.dirname(__file__), "..")
env["PYTHONIOENCODING"] = "utf-8"
result = subprocess.run(
[deepeval_bin, "test", "run", target_test],
cwd=os.path.join(os.path.dirname(__file__), ".."),
env=env,
text=True,
encoding="utf-8",
)
print("\n----------------------------------------------")
if result.returncode == 0:
print("[V] Zako艅czono pomy艣lnie. Nie wykryto halucynacji poni偶ej progu.")
else:
print(
"[X] Wykryto nie艣cis艂o艣ci (odpowiedzi mog艂y wzi膮膰 dane z zewn膮trz Prawnika)."
)
if __name__ == "__main__":
main()
|