haive.core.contracts.enhanced_prompt_config¶

Enhanced prompt configuration with full feature parity to AugLLMConfig.

This module provides complete prompt management including few-shot learning, messages placeholders, format instructions, and dynamic template creation.

Classes¶

EnhancedPromptConfig

Complete prompt configuration with full AugLLMConfig feature parity.

FewShotConfig

Configuration for few-shot prompting.

FormatInstructionsConfig

Configuration for format instructions.

MessagesConfig

Configuration for messages placeholder handling.

TemplateManager

Manages multiple prompt templates.

Module Contents¶

class haive.core.contracts.enhanced_prompt_config.EnhancedPromptConfig(/, **data)[source]¶

Bases: pydantic.BaseModel

Complete prompt configuration with full AugLLMConfig feature parity.

This provides all prompt management features from AugLLMConfig: - Few-shot prompting with examples - Messages placeholder management - Dynamic template creation - Format instructions integration - Template storage and switching - Input variable management

Parameters:

data (Any)

prompt_template¶

Main prompt template.

system_message¶

System message for chat models.

few_shot¶

Few-shot configuration.

messages¶

Messages configuration.

format_instructions¶

Format instructions config.

template_manager¶

Template management.

input_variables¶

Required input variables.

optional_variables¶

Optional input variables.

partial_variables¶

Partial variables.

contracts¶

Prompt contracts.

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.

class Config[source]¶

Pydantic configuration.

add_format_instructions(model, as_tool=False)[source]¶

Add format instructions for structured output.

Parameters:
  • model (type[pydantic.BaseModel]) – Pydantic model for output.

  • as_tool (bool) – Whether to use tool-based approach.

Return type:

None

apply_partial_variables()[source]¶

Apply partial variables to template.

Return type:

None

compute_input_variables()[source]¶

Compute required input variables.

Returns:

List of required variables.

Return type:

List[str]

create_template()[source]¶

Create appropriate template based on configuration.

Returns:

Created template or None.

Return type:

Optional[langchain_core.prompts.BasePromptTemplate]

ensure_messages_placeholder()[source]¶

Ensure messages placeholder exists in template.

Return type:

None

list_templates()[source]¶

List all stored template names.

Returns:

List of template names.

Return type:

List[str]

remove_template(name=None)[source]¶

Remove a stored template.

Parameters:

name (Optional[str]) – Template to remove (current if None).

Returns:

True if removed successfully.

Return type:

bool

store_template(name, template)[source]¶

Store a template for later use.

Parameters:
  • name (str) – Template name.

  • template (langchain_core.prompts.BasePromptTemplate) – Template to store.

Return type:

None

to_dict()[source]¶

Convert to dictionary.

Returns:

Configuration as dictionary.

Return type:

Dict[str, Any]

use_template(name)[source]¶

Switch to a stored template.

Parameters:

name (str) – Template name to use.

Returns:

True if switched successfully.

Return type:

bool

validate_configuration()[source]¶

Validate the configuration.

Returns:

Dictionary of validation errors.

Return type:

Dict[str, str]

class haive.core.contracts.enhanced_prompt_config.FewShotConfig(/, **data)[source]¶

Bases: pydantic.BaseModel

Configuration for few-shot prompting.

Parameters:

data (Any)

examples¶

List of example input-output pairs.

example_prompt¶

Template for formatting examples.

prefix¶

Text before examples.

suffix¶

Text after examples.

example_separator¶

Separator between examples.

example_selector¶

Optional selector for dynamic examples.

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.

class Config[source]¶

Pydantic configuration.

class haive.core.contracts.enhanced_prompt_config.FormatInstructionsConfig(/, **data)[source]¶

Bases: pydantic.BaseModel

Configuration for format instructions.

Parameters:

data (Any)

include_format_instructions¶

Whether to include instructions.

format_instructions_key¶

Variable name for instructions.

use_tool_for_format_instructions¶

Use tool-based approach.

format_instructions_text¶

Cached instruction text.

auto_generate¶

Auto-generate from structured model.

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.

class haive.core.contracts.enhanced_prompt_config.MessagesConfig(/, **data)[source]¶

Bases: pydantic.BaseModel

Configuration for messages placeholder handling.

Parameters:

data (Any)

add_messages_placeholder¶

Whether to add placeholder.

messages_placeholder_name¶

Variable name for messages.

force_messages_optional¶

Force optional messages.

uses_messages_field¶

Whether template uses messages.

messages_position¶

Where to insert placeholder.

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.

class haive.core.contracts.enhanced_prompt_config.TemplateManager(/, **data)[source]¶

Bases: pydantic.BaseModel

Manages multiple prompt templates.

Parameters:

data (Any)

stored_templates¶

Named templates.

active_template¶

Currently active template.

template_history¶

History of used templates.

fallback_template¶

Fallback if main fails.

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.

class Config[source]¶

Pydantic configuration.