|
9 | 9 | from ldai.judge.evaluation_schema_builder import EvaluationSchemaBuilder |
10 | 10 | from ldai.models import AIJudgeConfig, LDMessage |
11 | 11 | from ldai.providers.ai_provider import AIProvider |
12 | | -from ldai.providers.types import (ChatResponse, EvalScore, JudgeResponse, |
13 | | - StructuredResponse) |
| 12 | +from ldai.providers.types import ChatResponse, EvalScore, JudgeResponse |
14 | 13 | from ldai.tracker import LDAIConfigTracker |
15 | 14 |
|
16 | 15 |
|
@@ -70,8 +69,8 @@ async def evaluate( |
70 | 69 | return None |
71 | 70 |
|
72 | 71 | messages = self._construct_evaluation_messages(input_text, output_text) |
| 72 | + assert self._evaluation_response_structure is not None |
73 | 73 |
|
74 | | - # Track metrics of the structured model invocation |
75 | 74 | response = await self._ai_config_tracker.track_metrics_of( |
76 | 75 | lambda: self._ai_provider.invoke_structured_model(messages, self._evaluation_response_structure), |
77 | 76 | lambda result: result.metrics, |
@@ -190,6 +189,10 @@ def _parse_evaluation_response(self, data: Dict[str, Any]) -> Dict[str, EvalScor |
190 | 189 | evaluations = data['evaluations'] |
191 | 190 |
|
192 | 191 | metric_key = self._ai_config.evaluation_metric_key |
| 192 | + if not metric_key: |
| 193 | + log.warn('Evaluation metric key is missing') |
| 194 | + return results |
| 195 | + |
193 | 196 | evaluation = evaluations.get(metric_key) |
194 | 197 |
|
195 | 198 | if not evaluation or not isinstance(evaluation, dict): |
|
0 commit comments