Fix Pydantic version error

This commit is contained in:
Daniel Balcells 2025-06-04 16:28:04 -04:00
parent b4b8e8b0c3
commit 3d3dfe17c1
1 changed files with 8 additions and 4 deletions

View File

@ -1,7 +1,7 @@
import datetime
from typing import Annotated
from pydantic import BaseModel, ConfigDict, Field, computed_field, field_validator
from pydantic import BaseModel, ConfigDict, Field, computed_field, field_validator, ValidationInfo
class AppBase(BaseModel):
@ -306,9 +306,13 @@ class DialecticOptions(BaseModel):
return v
@field_validator("include_trace")
def validate_stream_and_trace(cls, v, values):
# Ensure stream is False when include_trace is True
if v and values.get("stream", False):
def validate_stream_and_trace(cls, v, info: ValidationInfo):
"""Disallow include_trace together with stream=True.
Pydantic v2 passes a ValidationInfo object rather than the old *values* dict.
We can access already-validated fields via ``info.data``.
"""
if v and info.data.get("stream", False):
raise ValueError("Streaming is not supported when include_trace=True")
return v