nat.agent.prompt_optimizer.register#

Classes#

PromptOptimizerConfig

Base configuration for functions.

PromptRecombinerConfig

Base configuration for functions.

Functions#

prompt_optimizer_function(config, builder)

Function to optimize prompts for LLMs.

prompt_recombiner_function(config, builder)

Function to recombine two parent prompts into a child prompt using the optimizer LLM.

Module Contents#

class PromptOptimizerConfig(/, **data: Any)#

Bases: nat.data_models.function.FunctionBaseConfig

Base configuration for functions.

Attributes:
name: Optional display name for this function. Used in tracing and observability.

If not provided, the function type will be used.

middleware: List of function middleware names to apply to this function.

These must match names defined in the middleware section of the YAML configuration.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

optimizer_llm: nat.data_models.component_ref.LLMRef = None#
optimizer_prompt: str = None#
system_objective: str = None#
async prompt_optimizer_function(
config: PromptOptimizerConfig,
builder: nat.builder.builder.Builder,
)#

Function to optimize prompts for LLMs.

class PromptRecombinerConfig(/, **data: Any)#

Bases: nat.data_models.function.FunctionBaseConfig

Base configuration for functions.

Attributes:
name: Optional display name for this function. Used in tracing and observability.

If not provided, the function type will be used.

middleware: List of function middleware names to apply to this function.

These must match names defined in the middleware section of the YAML configuration.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

optimizer_llm: nat.data_models.component_ref.LLMRef = None#
optimizer_prompt: str = None#
system_objective: str = None#
async prompt_recombiner_function(
config: PromptRecombinerConfig,
builder: nat.builder.builder.Builder,
)#

Function to recombine two parent prompts into a child prompt using the optimizer LLM. Uses the same base template and objective instructions.