Skip to main content

Structured output support for Pydantic models.

Project description

A factory type that enables structured output behavior in Pydantic models.

Example usage:

from pydantic_ai import Agent
from pydantic import BaseModel
from pydantic_outputs import structured, StructuredOutput

# structured is a type alias for StructuredOutput
# StructuredOutput(Model) is equivalent to @structured <ModelDef>

@structured
class FooBar(BaseModel):
    foo: str
    bar: int

class BarBaz(BaseModel):
    bar: str
    baz: int

agent = Agent('test')
result = agent.run_sync(
    "Generate a sample object",
    output_type=[FooBar, StructuredOutput(BarBaz)]
)

assert isinstance(result.output, dict)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_outputs-0.1.2.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_outputs-0.1.2-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_outputs-0.1.2.tar.gz.

File metadata

  • Download URL: pydantic_outputs-0.1.2.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for pydantic_outputs-0.1.2.tar.gz
Algorithm Hash digest
SHA256 80d4e83aebef35639fab93ecc8711d64fa92dd37a08dc928a14ad4b032ebd2a4
MD5 ec343e5be2fe24e33173e437ec9c2d20
BLAKE2b-256 242347c497a0add1f5ed5a259b1afda77108fd56718d00531eee481c96bbeed7

See more details on using hashes here.

File details

Details for the file pydantic_outputs-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_outputs-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 abb655a00de17bcbcfe2ac2f8db3e604b3265954ae413e0f050380c411c3a330
MD5 2de9df10481d5b4730238684868f207e
BLAKE2b-256 0289ae3f19687970adffc42ffb5c9a74e102eb3a88bddee7f1f13a42a05fa306

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page