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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80d4e83aebef35639fab93ecc8711d64fa92dd37a08dc928a14ad4b032ebd2a4
|
|
| MD5 |
ec343e5be2fe24e33173e437ec9c2d20
|
|
| BLAKE2b-256 |
242347c497a0add1f5ed5a259b1afda77108fd56718d00531eee481c96bbeed7
|
File details
Details for the file pydantic_outputs-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pydantic_outputs-0.1.2-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abb655a00de17bcbcfe2ac2f8db3e604b3265954ae413e0f050380c411c3a330
|
|
| MD5 |
2de9df10481d5b4730238684868f207e
|
|
| BLAKE2b-256 |
0289ae3f19687970adffc42ffb5c9a74e102eb3a88bddee7f1f13a42a05fa306
|