11from typing import Any , Dict , Generator , Iterable , List , Optional , Tuple , Union , cast
22
3-
43from guardrails import validator_service
54from guardrails .classes .history import Call , Inputs , Iteration , Outputs
65from guardrails .classes .output_type import OT , OutputTypes
7- from guardrails .classes .validation .validation_summary import ValidationSummary
86from guardrails .classes .validation_outcome import ValidationOutcome
97from guardrails .llm_providers import (
108 LiteLLMCallable ,
@@ -178,9 +176,7 @@ def prepare_chunk_generator(stream) -> Iterable[Tuple[Any, bool]]:
178176 "$" ,
179177 validate_subschema = True ,
180178 )
181- # Not sure I like adding all this info to every chunk
182- # maybe move last chunk?
183- validator_logs = iteration .validator_logs
179+
184180 for res in gen :
185181 chunk = res .chunk
186182 original_text = res .original_text
@@ -199,19 +195,13 @@ def prepare_chunk_generator(stream) -> Iterable[Tuple[Any, bool]]:
199195 )
200196 # 5. Convert validated fragment to a pretty JSON string
201197 validation_response += cast (str , chunk )
202- validator_logs = call_log .iterations .last .validator_logs
203-
204- validation_summaries = ValidationSummary .from_validator_logs (
205- validator_logs
206- )
207198 passed = call_log .status == pass_status
208199 yield ValidationOutcome (
209200 call_id = call_log .id , # type: ignore
210201 # The chunk or the whole output?
211202 raw_llm_output = original_text ,
212203 validated_output = chunk ,
213204 validation_passed = passed ,
214- validation_summaries = validation_summaries ,
215205 )
216206
217207 # handle non string schema
@@ -256,17 +246,11 @@ def prepare_chunk_generator(stream) -> Iterable[Tuple[Any, bool]]:
256246 else :
257247 validation_response = cast (dict , validated_fragment )
258248 # 5. Convert validated fragment to a pretty JSON string
259-
260- validator_logs = iteration .validator_logs
261- validation_summaries = ValidationSummary .from_validator_logs (
262- validator_logs
263- )
264249 yield ValidationOutcome (
265250 call_id = call_log .id , # type: ignore
266251 raw_llm_output = fragment ,
267252 validated_output = validated_fragment ,
268253 validation_passed = validated_fragment is not None ,
269- validation_summaries = validation_summaries ,
270254 )
271255
272256 # # Finally, add to logs
0 commit comments