Skip to content

Support Pydantic models as the output schema #1

Description

@Fakamoto

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.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions