Spaces:
Sleeping
Sleeping
Update evaluate.py
Browse files- evaluate.py +13 -1
evaluate.py
CHANGED
|
@@ -85,8 +85,19 @@ def load_test_fixtures():
|
|
| 85 |
global test_fixtures
|
| 86 |
test_fixtures = []
|
| 87 |
env_path = os.environ.get("TEST_FIXTURES_PATH", "").strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
# candidates = [env_path] if env_path else ["conversation_test_fixtures_v10.jsonl"]
|
| 89 |
-
candidates = [env_path] if env_path else ["small_test_cases_v10.jsonl"]
|
|
|
|
| 90 |
path = next((p for p in candidates if p and os.path.exists(p)), None)
|
| 91 |
if not path:
|
| 92 |
print("Warning: No test fixtures file found for evaluation.")
|
|
@@ -105,6 +116,7 @@ def load_test_fixtures():
|
|
| 105 |
print(f"Skipping malformed JSON line in {path}")
|
| 106 |
print(f"Loaded {len(test_fixtures)} fixtures for evaluation from {path}")
|
| 107 |
|
|
|
|
| 108 |
def evaluate_nlu_tags(expected: Dict[str, Any], actual: Dict[str, Any], tag_key: str, expected_key_override: str = None) -> Dict[str, float]:
|
| 109 |
lookup_key = expected_key_override or tag_key
|
| 110 |
expected_raw = expected.get(lookup_key, [])
|
|
|
|
| 85 |
global test_fixtures
|
| 86 |
test_fixtures = []
|
| 87 |
env_path = os.environ.get("TEST_FIXTURES_PATH", "").strip()
|
| 88 |
+
|
| 89 |
+
# --- START: DEFINITIVE FIX ---
|
| 90 |
+
# The old code used a relative path, which is unreliable.
|
| 91 |
+
# This new code builds an absolute path to the fixture file based on
|
| 92 |
+
# the location of this (evaluate.py) script.
|
| 93 |
+
script_dir = Path(__file__).parent
|
| 94 |
+
default_fixture_file = script_dir / "small_test_cases_v10.jsonl"
|
| 95 |
+
|
| 96 |
+
candidates = [env_path] if env_path else [str(default_fixture_file)]
|
| 97 |
+
# --- END: DEFINITIVE FIX ---
|
| 98 |
# candidates = [env_path] if env_path else ["conversation_test_fixtures_v10.jsonl"]
|
| 99 |
+
# candidates = [env_path] if env_path else ["small_test_cases_v10.jsonl"]
|
| 100 |
+
|
| 101 |
path = next((p for p in candidates if p and os.path.exists(p)), None)
|
| 102 |
if not path:
|
| 103 |
print("Warning: No test fixtures file found for evaluation.")
|
|
|
|
| 116 |
print(f"Skipping malformed JSON line in {path}")
|
| 117 |
print(f"Loaded {len(test_fixtures)} fixtures for evaluation from {path}")
|
| 118 |
|
| 119 |
+
|
| 120 |
def evaluate_nlu_tags(expected: Dict[str, Any], actual: Dict[str, Any], tag_key: str, expected_key_override: str = None) -> Dict[str, float]:
|
| 121 |
lookup_key = expected_key_override or tag_key
|
| 122 |
expected_raw = expected.get(lookup_key, [])
|