i'd like to define the output as a Pydantic model, pass it to the SDK, and get a validated instance back.
right now, i have to define the questions separately and access results through keys like response.choices["category"].choice. i'd rather define the fields, types, and descriptions once in a model and use result.category.
for example, something like this:
from typing import Literal
from pydantic import BaseModel, Field
class TicketClassification(BaseModel):
category: Literal["billing", "technical", "other"] = Field(
description="What is this ticket about?"
)
# proposed interface, not current SDK syntax
result = client.system_one(
input="I was charged twice.",
response_model=TicketClassification,
)
print(result.category)
this is the contract and API i'd like: clear input, one clear output, defined in good old Pydantic that we all know and love.
pass input and a response_model, get a validated instance of that model back. field types and descriptions define what i'm asking for, without a separate question dictionary or manual response mapping.
the exact parameter names are open for discussion, but that's the developer experience i'm after.
i'm looking for the familiar typed output workflow i use with libraries like LangChain, DSPy, Instructor, and the OpenAI SDK. support could start with fields that map to Jev's existing primitives, with clear errors for unsupported types.
this doesn't require replacing the SDK's internal models. an optional Pydantic interface would work too.
Implementation: Pydantic output models PR. The PR is hosted in my fork because this repository currently limits PR creation to collaborators.
i'd like to define the output as a Pydantic model, pass it to the SDK, and get a validated instance back.
right now, i have to define the questions separately and access results through keys like
response.choices["category"].choice. i'd rather define the fields, types, and descriptions once in a model and useresult.category.for example, something like this:
this is the contract and API i'd like: clear input, one clear output, defined in good old Pydantic that we all know and love.
pass
inputand aresponse_model, get a validated instance of that model back. field types and descriptions define what i'm asking for, without a separate question dictionary or manual response mapping.the exact parameter names are open for discussion, but that's the developer experience i'm after.
i'm looking for the familiar typed output workflow i use with libraries like LangChain, DSPy, Instructor, and the OpenAI SDK. support could start with fields that map to Jev's existing primitives, with clear errors for unsupported types.
this doesn't require replacing the SDK's internal models. an optional Pydantic interface would work too.
Implementation: Pydantic output models PR. The PR is hosted in my fork because this repository currently limits PR creation to collaborators.