make()
Generate text and structured outputs based on a given target, with the ability to create synthetic content.
API Reference
make()
Generate ('make') a value of the provided target type using
a model or Pydantic AI agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
TargetParam[Output]
|
The target type or value to generate. Defaults to str. |
str
|
context
|
ContextType | List[ContextType] | None
|
The context to use for the operation. Defaults to None. |
None
|
randomize
|
bool
|
Injects a simple randomization instruction for more diverse outputs. This is automatically added if no context or instructions are provided. Defaults to False. |
False
|
confidence
|
bool
|
Whether to include confidence scores in the result of the operation. This is currently only supported for OpenAI or OpenAI-like models. Defaults to False. |
False
|
model
|
ModelParam
|
The model to use for the operation. This can be a string, Pydantic AI model, or Pydantic AI agent. Defaults to "openai:gpt-4o-mini". |
'openai:gpt-4o-mini'
|
model_settings
|
PydanticAIModelSettings | None
|
The model settings to use for the operation. Defaults to None. |
None
|
attachments
|
AttachmentType | List[AttachmentType] | None
|
A single or list of attachment objects provided to the agent.
An attachment is a piece of content that is provided to the agent in a 'persistent' fashion,
where it is templated/placed specifically to avoid context rot or loss. Furthermore, attachments that
are |
None
|
instructions
|
PydanticAIInstructions | None
|
The instructions to use for the operation. Defaults to None. |
None
|
tools
|
ToolType | List[ToolType] | None
|
The tools to use for the operation. Defaults to None. |
None
|
deps
|
Deps | None
|
Reference to |
None
|
usage_limits
|
PydanticAIUsageLimits | None
|
The usage limits to use for the operation. Defaults to None. |
None
|
observe
|
bool | Observer | None
|
If True or provided, enables CLI observation output. |
None
|
stream
|
bool
|
Whether to stream the output of the operation. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
Result[Output] | Stream[Output]
|
Result[Output] | Stream[Output]: The result or stream of the operation. |
amake()
Asynchronously generate ('make') a value of the provided target type using
a model or Pydantic AI agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
TargetParam[Output]
|
The target type or value to generate. Defaults to str. |
str
|
context
|
ContextType | List[ContextType] | None
|
The context to use for the operation. Defaults to None. |
None
|
randomize
|
bool
|
Injects a simple randomization instruction for more diverse outputs. This is automatically added if no context or instructions are provided. Defaults to False. |
False
|
confidence
|
bool
|
Whether to include confidence scores in the result of the operation. This is currently only supported for OpenAI or OpenAI-like models. Defaults to False. |
False
|
model
|
ModelParam
|
The model to use for the operation. This can be a string, Pydantic AI model, or Pydantic AI agent. Defaults to "openai:gpt-4o-mini". |
'openai:gpt-4o-mini'
|
model_settings
|
PydanticAIModelSettings | None
|
The model settings to use for the operation. Defaults to None. |
None
|
attachments
|
AttachmentType | List[AttachmentType] | None
|
A single or list of attachment objects provided to the agent.
An attachment is a piece of content that is provided to the agent in a 'persistent' fashion,
where it is templated/placed specifically to avoid context rot or loss. Furthermore, attachments that
are |
None
|
instructions
|
PydanticAIInstructions | None
|
The instructions to use for the operation. Defaults to None. |
None
|
tools
|
ToolType | List[ToolType] | None
|
The tools to use for the operation. Defaults to None. |
None
|
deps
|
Deps | None
|
Reference to |
None
|
usage_limits
|
PydanticAIUsageLimits | None
|
The usage limits to use for the operation. Defaults to None. |
None
|
observe
|
bool | Observer | None
|
If True or provided, enables CLI observation output. |
None
|
stream
|
bool
|
Whether to stream the output of the operation. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
Result[Output] | Stream[Output]
|
Result[Output] | Stream[Output]: The result or stream of the operation. |
Overview
The make() semantic operation is used to generate content and structured outputs based on a given target type or value.
Did you know?
make() can be called with or without context allowing for model determined synthetic content generation.
- In this case, only the
targetwas provided.
Streaming
make() also supports streaming the output of the operation as it is generated.
from zyx import make
stream = make(
target=list[str],
context="Write a haiku about the weather.",
stream=True # (1)!
)
for chunk in stream.partial(): # (2)!
print(chunk)
"""
['Whispers of the breeze,', 'Clouds']
['Whispers of the breeze,', 'Clouds dance in the silver sky,']
['Whispers of the breeze,', 'Clouds dance in the silver sky,', 'Raindrops kiss the earth.']
['Whispers of the breeze,', 'Clouds dance in the silver sky,', 'Raindrops kiss the earth.']
['Whispers of the breeze,', 'Clouds dance in the silver sky,', 'Raindrops kiss the earth.']
"""
-
We set the
streamparameter to True to enable streaming. -
A stream can be iterated over using the
text()orpartial()methods. In this case, we are using a non-string structured output, so we usepartial().