Skip to content

Commit cf1f4bb

Browse files
committed
validate final text with partial=false
1 parent 17cfaf6 commit cf1f4bb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pydantic_ai_slim/pydantic_ai/result.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,17 @@ async def stream_text(self, *, delta: bool = False, debounce_by: float | None =
114114
async for text in self._stream_response_text(delta=True, debounce_by=debounce_by):
115115
yield text
116116
else:
117+
text: str | None = None
117118
async for text in self._stream_response_text(delta=False, debounce_by=debounce_by):
118119
for validator in self._output_validators:
119120
text = await validator.validate(text, self._run_ctx, partial=True) # pragma: no cover
120121
yield text
121122

123+
if text is not None:
124+
for validator in self._output_validators:
125+
text = await validator.validate(text, self._run_ctx)
126+
yield text
127+
122128
# TODO (v2): Drop in favor of `response` property
123129
def get(self) -> _messages.ModelResponse:
124130
"""Get the current state of the response."""

0 commit comments

Comments
 (0)