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:
BaseModelPydantic 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)
- 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.
- 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:
BaseModelPydantic 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_json(**kwargs)[source]¶
Convert to JSON string in script format.
- Parameters:
**kwargs – Additional arguments passed to json.dumps
- Returns:
JSON string representation
- Return type:
- 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:
- 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:
BaseModelConfiguration 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.
- 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:
BaseModelConfiguration 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.
- 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:
BaseModelConfiguration 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.
- 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:
- 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:
- 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:
- 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:
ProcessingStepConfigBaseConfiguration 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)
- system_prompt_settings: SystemPromptConfig | None¶
- output_format_settings: OutputFormatConfig | None¶
- instruction_settings: InstructionConfig | None¶
- category_definitions: List[CategoryDefinition] | None¶
- 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 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
- get_script_path(default_path=None)[source]¶
Get script path for the Bedrock prompt template generation step.
- 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.
- 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:
- 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: