cursus.steps.configs.config_bedrock_prompt_template_generation_step

Bedrock Prompt Template Generation Step Configuration

This module implements the configuration class for the Bedrock Prompt Template Generation step using the three-tier design pattern for optimal user experience and maintainability.

class CategoryDefinition(*, name, description, conditions, key_indicators, exceptions=<factory>, examples=None, priority=1, aliases=None, validation_rules=None)[source]

Bases: BaseModel

Pydantic model for a single category definition used in classification tasks.

Based on the expected format from bedrock_prompt_template_generation.py script: - Required fields: name, description, conditions, key_indicators - Optional fields: exceptions, examples, priority - Additional fields: aliases, validation_rules (for future extensibility)

name: str
description: str
conditions: List[str]
key_indicators: List[str]
exceptions: List[str]
examples: List[str] | None
priority: int
aliases: List[str] | None
validation_rules: List[str] | None
classmethod name_must_not_be_empty(v)[source]

Validate that name is not just whitespace.

classmethod description_must_not_be_empty(v)[source]

Validate that description is not just whitespace.

classmethod conditions_must_not_be_empty(v)[source]

Validate that conditions list contains non-empty strings.

classmethod key_indicators_must_not_be_empty(v)[source]

Validate that key_indicators list contains non-empty strings.

classmethod exceptions_must_not_be_empty_strings(v)[source]

Validate that exceptions list doesn’t contain empty strings.

classmethod examples_must_not_be_empty_strings(v)[source]

Validate that examples list doesn’t contain empty strings.

to_script_format()[source]

Convert to the format expected by the bedrock_prompt_template_generation.py script.

Returns:

Dictionary in the format expected by the script

Return type:

Dict[str, Any]

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class CategoryDefinitionList(*, categories)[source]

Bases: BaseModel

Pydantic model for a list of category definitions with validation.

Ensures that category names are unique and provides utility methods for working with the category list.

categories: List[CategoryDefinition]
classmethod categories_must_have_unique_names(v)[source]

Validate that all category names are unique.

to_script_format()[source]

Convert all categories to the format expected by the script.

Returns:

List of dictionaries in the format expected by the script

Return type:

List[Dict[str, Any]]

to_json(**kwargs)[source]

Convert to JSON string in script format.

Parameters:

**kwargs – Additional arguments passed to json.dumps

Returns:

JSON string representation

Return type:

str

get_category_names()[source]

Get list of all category names.

get_category_by_name(name)[source]

Get category by name.

Parameters:

name (str) – Category name to search for

Returns:

CategoryDefinition if found, None otherwise

Return type:

CategoryDefinition | None

sort_by_priority()[source]

Return a new CategoryDefinitionList sorted by priority.

Returns:

New CategoryDefinitionList with categories sorted by priority (ascending)

Return type:

CategoryDefinitionList

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class SystemPromptConfig(*, role_definition='expert analyst', expertise_areas=['data analysis', 'classification', 'pattern recognition'], responsibilities=['analyze data accurately', 'classify content systematically', 'provide clear reasoning'], behavioral_guidelines=['be precise', 'be objective', 'be thorough', 'be consistent'], tone='professional', **extra_data)[source]

Bases: BaseModel

Configuration for system prompt generation with comprehensive defaults.

This model defines how the AI’s role, expertise, and behavioral guidelines are structured in the system prompt component of the template.

role_definition: str
expertise_areas: List[str]
responsibilities: List[str]
behavioral_guidelines: List[str]
tone: str
model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class OutputFormatConfig(*, format_type='structured_json', required_fields=['category', 'confidence', 'key_evidence', 'reasoning'], field_descriptions=<factory>, json_schema=None, validation_requirements=<factory>, evidence_validation_rules=<factory>, header_text=None, structured_text_sections=None, formatting_rules=None, example_output=None, **extra_data)[source]

Bases: BaseModel

Configuration for output format generation with comprehensive defaults.

This model defines the structure and validation requirements for the expected output format in the generated prompt template.

Supports both structured_json and structured_text formats with full customization.

format_type: str
required_fields: List[str]
field_descriptions: Dict[str, str]
json_schema: Dict[str, Any] | None
validation_requirements: List[str]
evidence_validation_rules: List[str]
header_text: str | None
structured_text_sections: List[Dict[str, Any]] | None
formatting_rules: List[str] | None
example_output: Any | None
model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class InstructionConfig(*, include_analysis_steps=True, include_decision_criteria=True, include_reasoning_requirements=True, step_by_step_format=True, include_evidence_validation=True, classification_guidelines=None, **extra_data)[source]

Bases: BaseModel

Configuration for instruction generation with comprehensive defaults.

This model defines which instruction components should be included in the generated prompt template to guide the AI’s analysis process.

Supports both basic boolean flags and detailed classification guidelines.

include_analysis_steps: bool
include_decision_criteria: bool
include_reasoning_requirements: bool
step_by_step_format: bool
include_evidence_validation: bool
classification_guidelines: Dict[str, Any] | None
model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

create_system_prompt_config_from_json(json_str)[source]

Create SystemPromptConfig from JSON string with robust fallback to “{}”.

Parameters:

json_str (str) – JSON string configuration (can be empty or invalid)

Returns:

SystemPromptConfig instance with defaults applied

Return type:

SystemPromptConfig

create_output_format_config_from_json(json_str)[source]

Create OutputFormatConfig from JSON string with robust fallback to “{}”.

Parameters:

json_str (str) – JSON string configuration (can be empty or invalid)

Returns:

OutputFormatConfig instance with defaults applied

Return type:

OutputFormatConfig

create_instruction_config_from_json(json_str)[source]

Create InstructionConfig from JSON string with robust fallback to “{}”.

Parameters:

json_str (str) – JSON string configuration (can be empty or invalid)

Returns:

InstructionConfig instance with defaults applied

Return type:

InstructionConfig

class BedrockPromptTemplateGenerationConfig(*, author, bucket, role, region, service_name, pipeline_version, model_class='xgboost', current_date=<factory>, framework_version='2.1.0', py_version='py310', source_dir=None, enable_caching=False, use_secure_pypi=False, max_runtime_seconds=172800, project_root_folder, processing_instance_count=1, processing_volume_size=500, processing_instance_type_large='ml.m5.4xlarge', processing_instance_type_small='ml.m5.2xlarge', use_large_processing_instance=False, skip_volume_kms=None, processing_source_dir=None, processing_entry_point='bedrock_prompt_template_generation.py', processing_script_arguments=None, processing_framework_version='1.2-1', input_placeholders, prompt_configs_path='prompt_configs', template_task_type='classification', template_style='structured', validation_level='standard', output_format_type='structured_json', required_output_fields=['category', 'confidence', 'key_evidence', 'reasoning'], include_examples=True, generate_validation_schema=True, template_version='1.0', system_prompt_settings=None, output_format_settings=None, instruction_settings=None, category_definitions=None, **extra_data)[source]

Bases: ProcessingStepConfigBase

Configuration for Bedrock Prompt Template Generation step using three-tier design.

This step generates structured prompt templates for classification tasks using the 5-component architecture pattern optimized for LLM performance.

Tier 1: Essential user inputs (required) Tier 2: System inputs with defaults (optional) Tier 3: Derived fields (private with property access)

input_placeholders: List[str]
prompt_configs_path: str
template_task_type: str
template_style: str
validation_level: str
output_format_type: str
required_output_fields: List[str]
include_examples: bool
generate_validation_schema: bool
template_version: str
system_prompt_settings: SystemPromptConfig | None
output_format_settings: OutputFormatConfig | None
instruction_settings: InstructionConfig | None
category_definitions: List[CategoryDefinition] | None
processing_entry_point: str
property effective_system_prompt_config: Dict[str, Any]

Get system prompt configuration from typed settings or defaults.

property effective_output_format_config: Dict[str, Any]

Get output format configuration from typed settings or defaults.

property effective_instruction_config: Dict[str, Any]

Get instruction configuration from typed settings or defaults.

property effective_categories: CategoryDefinitionList | None

Get effective category definitions from direct definitions.

property template_metadata: Dict[str, Any]

Get template generation metadata.

property environment_variables: Dict[str, str]

Get environment variables for the processing step (file-based approach).

property resolved_prompt_configs_path: str | None

Get resolved absolute path for prompt configurations with hybrid resolution.

Uses effective_source_dir from base class for consistency.

Returns:

Absolute path to prompt configs directory, or None if not configured

Raises:

ValueError – If prompt_configs_path is set but source directory cannot be resolved

generate_prompt_config_bundle()[source]

Generate complete prompt configuration bundle for the refactored file-based approach.

Creates JSON files needed by the script in the configured prompt_configs_path: - system_prompt.json (only if system_prompt_settings is provided) - output_format.json (only if output_format_settings is provided) - instruction.json (only if instruction_settings is provided) - category_definitions.json (only if category_definitions is provided)

All configuration files are optional - the script will use defaults when files are missing.

Raises:

ValueError – If prompt_configs_path is not configured

model_dump(**kwargs)[source]

Override model_dump to include derived properties.

initialize_derived_fields()[source]

Initialize all derived fields once after validation.

get_script_path(default_path=None)[source]

Get script path for the Bedrock prompt template generation step.

Parameters:

default_path (str | None) – Default script path to use if not found via other methods

Returns:

Script path resolved from processing_entry_point and source directories

Return type:

str | None

get_public_init_fields()[source]

Override get_public_init_fields to include template-specific fields. Gets a dictionary of public fields suitable for initializing a child config.

Returns:

Dictionary of field names to values for child initialization

Return type:

Dict[str, Any]

get_job_arguments()[source]

CLI args — config is the single source (FZ 31e1d3h). Boolean flags + template version.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'protected_namespaces': (), 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

processing_instance_count: int
processing_volume_size: int
processing_instance_type_large: str
processing_instance_type_small: str
use_large_processing_instance: bool
skip_volume_kms: bool | None
processing_source_dir: str | None
processing_script_arguments: List[str] | None
processing_framework_version: str
author: str
bucket: str
role: str
region: str
service_name: str
pipeline_version: str
model_class: str
current_date: str
framework_version: str
py_version: str
source_dir: str | None
enable_caching: bool
use_secure_pypi: bool
max_runtime_seconds: int
project_root_folder: str
load_categories_from_json(json_data)[source]

Load categories from JSON string with validation.

Parameters:

json_data (str) – JSON string containing category definitions

Returns:

Validated CategoryDefinitionList

Raises:
  • ValueError – If JSON is invalid or categories don’t validate

  • pydantic.ValidationError – If category data doesn’t match schema

Return type:

CategoryDefinitionList

load_categories_from_dict(data)[source]

Load categories from dictionary/list data with validation.

Parameters:

data (Any) – Dictionary or list containing category definitions

Returns:

Validated CategoryDefinitionList

Raises:

pydantic.ValidationError – If category data doesn’t match schema

Return type:

CategoryDefinitionList