88from ldai import log
99from ldai .judge .evaluation_schema_builder import EvaluationSchemaBuilder
1010from ldai .models import AIJudgeConfig , LDMessage
11- from ldai .providers .model_runner import ModelRunner
12- from ldai .providers .types import JudgeResult , ModelResponse
11+ from ldai .providers .runner import Runner
12+ from ldai .providers .types import JudgeResult , RunnerResult
1313
1414
1515class Judge :
@@ -23,13 +23,13 @@ class Judge:
2323 def __init__ (
2424 self ,
2525 ai_config : AIJudgeConfig ,
26- model_runner : ModelRunner ,
26+ model_runner : Runner ,
2727 ):
2828 """
2929 Initialize the Judge.
3030
3131 :param ai_config: The judge AI configuration
32- :param model_runner: The model runner to use for evaluation
32+ :param model_runner: The runner to use for evaluation
3333 """
3434 self ._ai_config = ai_config
3535 self ._model_runner = model_runner
@@ -76,10 +76,10 @@ async def evaluate(
7676
7777 response = await tracker .track_metrics_of_async (
7878 lambda result : result .metrics ,
79- lambda : self ._model_runner .invoke_structured_model (messages , self ._evaluation_response_structure ),
79+ lambda : self ._model_runner .run (messages , output_type = self ._evaluation_response_structure ),
8080 )
8181
82- parsed = self ._parse_evaluation_response (response .data )
82+ parsed = self ._parse_evaluation_response (response .parsed )
8383
8484 if parsed is None :
8585 log .warning ('Judge evaluation did not return the expected evaluation' )
@@ -99,7 +99,7 @@ async def evaluate(
9999 async def evaluate_messages (
100100 self ,
101101 messages : list [LDMessage ],
102- response : ModelResponse ,
102+ response : RunnerResult ,
103103 sampling_ratio : float = 1.0 ,
104104 ) -> JudgeResult :
105105 """
@@ -111,7 +111,7 @@ async def evaluate_messages(
111111 :return: The result of the judge evaluation.
112112 """
113113 input_text = '\r \n ' .join ([msg .content for msg in messages ]) if messages else ''
114- output_text = response .message . content
114+ output_text = response .content
115115
116116 return await self .evaluate (input_text , output_text , sampling_ratio )
117117
@@ -123,11 +123,11 @@ def get_ai_config(self) -> AIJudgeConfig:
123123 """
124124 return self ._ai_config
125125
126- def get_model_runner (self ) -> ModelRunner :
126+ def get_model_runner (self ) -> Runner :
127127 """
128- Returns the model runner used by this judge.
128+ Returns the runner used by this judge.
129129
130- :return: The model runner
130+ :return: The runner
131131 """
132132 return self ._model_runner
133133
@@ -164,7 +164,7 @@ def _interpolate_message(self, content: str, variables: Dict[str, str]) -> str:
164164 # Use chevron (Mustache) for templating, with no escaping
165165 return chevron .render (content , variables )
166166
167- def _parse_evaluation_response (self , data : Dict [str , Any ]) -> Optional [Tuple [float , str ]]:
167+ def _parse_evaluation_response (self , data : Optional [ Dict [str , Any ] ]) -> Optional [Tuple [float , str ]]:
168168 """
169169 Parses the structured evaluation response. Expects {"score": n, "reasoning": "..."}.
170170
0 commit comments