-
Notifications
You must be signed in to change notification settings - Fork 153
Open
Description
Python -VV
Python 3.13.7 (main, Aug 15 2025, 22:06:01) [GCC 14.2.0]Pip Freeze
annotated-types==0.7.0
anyio==4.11.0
certifi==2025.10.5
click==8.3.0
distro==1.9.0
eval_type_backport==0.2.2
fastapi==0.117.1
h11==0.16.0
httpcore==1.0.9
httptools==0.6.4
httpx==0.28.1
idna==3.10
invoke==2.2.0
jiter==0.11.0
mistralai==1.9.11
openai==1.108.1
pydantic==2.12.0
pydantic-settings==2.11.0
pydantic_core==2.41.1
python-dateutil==2.9.0.post0
python-dotenv==1.1.1
PyYAML==6.0.3
six==1.17.0
sniffio==1.3.1
starlette==0.48.0
tqdm==4.67.1
typing-inspection==0.4.2
typing_extensions==4.15.0
uvicorn==0.36.0
uvloop==0.21.0
watchfiles==1.1.0
websockets==15.0.1Reproduction Steps
- Create a Pydantic model that uses conlist, conset or anything similar.
- Use the created model as structured output
Basic (semi-pseudo) example:
import annotated_types
from typing import Annotated
from pydantic import BaseModel, conlist
from mistralai import Mistral, UserMessage
class ExampleModel(BaseModel):
words: conlist(
str,
min_length=3,
max_length=3
) # pyright: ignore[reportInvalidTypeForm]
mistral = Mistral(api_key='your_mistral_api_key')
result = mistral.chat.parse_async(
model='mistral-medium-2508',
messages=[
UserMessage(content='Write three interesting words')
],
response_format=ExampleModel
)Resulting error:
File "/usr/local/lib/python3.13/site-packages/mistralai/extra/utils/_pydantic_helper.py", line 20, in rec_strict_json_schema
raise ValueError(f"Unexpected type: {schema_node}")
ValueError: Unexpected type: 3
Expected Behavior
No error and correct parsing of the Pydantic model.
Additional Context
No response
Suggested Solutions
No response
Metadata
Metadata
Assignees
Labels
No labels