Skip to content

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 Resources provide the agent with an ability to interact with/modify them, like artifacts. Defaults to None.

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 deps in pydantic_ai.RunContext, that can be passed to messages, tools and instructions. Defaults to None.

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 Resources provide the agent with an ability to interact with/modify them, like artifacts. Defaults to None.

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 deps in pydantic_ai.RunContext, that can be passed to messages, tools and instructions. Defaults to None.

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.

Generating a Structured Output
from zyx import make
from pydantic import BaseModel


class User(BaseModel):
    name : str
    age : int


result = make(
    target=User,
    context="John is 25 years old."
)


print(result.output)
"""
User(name="John", age=25)
"""
Generating a Structured Output
from zyx import amake
from pydantic import BaseModel


class User(BaseModel):
    name : str
    age : int


async def main():
    result = await amake(
        target=User,
        context="John is 25 years old."
    )
Did you know?

make() can be called with or without context allowing for model determined synthetic content generation.

result = make(User) # (1)!

print(result.output)
"""
name='Leona Frost' age=28
"""
  1. In this case, only the target was provided.

Streaming

make() also supports streaming the output of the operation as it is generated.

Streaming the Output
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.']
"""
  1. We set the stream parameter to True to enable streaming.

  2. A stream can be iterated over using the text() or partial() methods. In this case, we are using a non-string structured output, so we use partial().