cursus.steps.scripts.bedrock_prompt_template_generation

Bedrock Prompt Template Generation Script

Generates structured prompt templates for categorization and classification tasks following the 5-component architecture pattern for optimal LLM performance.

class PlaceholderResolver(categories, schema=None)[source]

Bases: object

Resolves placeholders marked with ${} syntax from various data sources. Tracks placeholder resolution and validates completion.

Connects category definitions to output format through schema enrichment.

resolve_placeholder(placeholder, field_name, source_hint=None)[source]

Resolve a placeholder marked with ${} syntax.

Parameters:
  • placeholder (str) – Placeholder text (e.g., “${category_enum}”)

  • field_name (str) – Field this placeholder is for (e.g., “category”)

  • source_hint (str | None) – Optional hint about data source

Returns:

Resolved placeholder text

Return type:

str

validate_all_resolved()[source]

Validate that all registered placeholders were successfully resolved.

Returns:

Validation report with any failures

Return type:

Dict[str, Any]

class PromptTemplateGenerator(config, schema_template=None)[source]

Bases: object

Generates structured prompt templates for classification tasks using the 5-component architecture pattern.

generate_template()[source]

Generate complete prompt template with 5-component structure.

class TemplateValidator(validation_level='standard')[source]

Bases: object

Validates generated prompt templates for quality and completeness.

validate_template(template)[source]

Validate template and return validation results.

load_config_from_json_file(config_path, config_name, default_config, log)[source]

Load configuration from JSON file with fallback to defaults.

load_category_definitions(prompt_configs_path, log)[source]

Load category definitions from prompt configs directory.

main(input_paths, output_paths, environ_vars, job_args, logger=None)[source]

Main logic for prompt template generation, refactored for testability.

Parameters:
  • input_paths (Dict[str, str]) – Dictionary of input paths with logical names

  • output_paths (Dict[str, str]) – Dictionary of output paths with logical names

  • environ_vars (Dict[str, str]) – Dictionary of environment variables

  • job_args (Namespace) – Command line arguments

  • logger (Callable[[str], None] | None) – Optional logger object (defaults to print if None)

Returns:

Dictionary containing generation results and statistics

Return type:

Dict[str, Any]