BuilderTypes
Predefined builder types for autocomplete and type safety when using prompt builders.
USAGE
BuilderTypes()
This class provides constants for all available prompt builder types, enabling IDE autocomplete support and preventing typos when calling the prompt_builder()
method. Using these constants instead of string literals improves code maintainability and provides a better developer experience through IDE features like auto-completion and type checking.
The builder types represent different pre-configured prompt engineering templates optimized for specific use cases. Each type includes specialized attention patterns, section structures, and formatting guidelines based on the intended domain.
Attributes
GENERAL :
-
Basic attention-optimized builder for general-purpose prompts. Provides fundamental prompt engineering structure without domain-specific optimizations. Best for: Custom prompts, exploratory use cases, general AI interactions.
ARCHITECTURAL :
-
Pre-configured builder for software architecture analysis and documentation. Includes specialized sections for system design, patterns, dependencies, and architectural recommendations. Best for: Code architecture reviews, system design documentation, technical debt analysis.
CODE_REVIEW :
-
Pre-configured builder for comprehensive code review tasks. Optimized for identifying issues, suggesting improvements, and providing constructive feedback with proper prioritization of concerns. Best for: Pull request reviews, code quality assessment, mentoring feedback.
DEBUGGING :
-
Pre-configured builder for debugging assistance and troubleshooting. Structured to systematically identify problems, analyze root causes, and provide step-by-step debugging guidance. Best for: Error analysis, troubleshooting guides, debugging workflows.
Examples
Using BuilderTypes constants for type safety
Recommended approach with autocomplete and type checking:
import talk_box as tb
# Type-safe builder selection with IDE support
= tb.ChatBot().model("gpt-4-turbo")
bot
# Architectural analysis builder
= bot.prompt_builder(tb.BuilderTypes.ARCHITECTURAL)
arch_builder = arch_builder.focus_on("identifying design patterns")._build()
arch_prompt
# Code review builder
= bot.prompt_builder(tb.BuilderTypes.CODE_REVIEW)
review_builder = review_builder.avoid_topics(["personal criticism"])._build()
review_prompt
# Debugging builder
= bot.prompt_builder(tb.BuilderTypes.DEBUGGING)
debug_builder = debug_builder.focus_on("systematic problem solving")._build() debug_prompt
Comparing with string literals
While string literals work, constants provide better development experience:
import talk_box as tb
= tb.ChatBot().model("gpt-4-turbo")
bot
# Using string literals (works but less maintainable)
= bot.prompt_builder("architectural") # No autocomplete, typo-prone
builder1
# Using constants (recommended)
= bot.prompt_builder(tb.BuilderTypes.ARCHITECTURAL) # IDE support builder2
Dynamic builder type selection
Use constants in conditional logic and configuration:
import talk_box as tb
def create_specialized_bot(task_type: str) -> tb.ChatBot:
= tb.ChatBot().model("gpt-4-turbo")
bot
if task_type == "architecture":
= tb.BuilderTypes.ARCHITECTURAL
builder_type elif task_type == "review":
= tb.BuilderTypes.CODE_REVIEW
builder_type elif task_type == "debug":
= tb.BuilderTypes.DEBUGGING
builder_type else:
= tb.BuilderTypes.GENERAL
builder_type
= bot.prompt_builder(builder_type)._build()
prompt return bot.system_prompt(prompt)
# Usage
= create_specialized_bot("architecture")
arch_bot = create_specialized_bot("review") review_bot
Integration with configuration systems
Use constants in configuration files and team standards:
import talk_box as tb
# Team configuration using constants
= {
TEAM_BOT_CONFIGS "code_reviewer": {
"model": "gpt-4-turbo",
"builder_type": tb.BuilderTypes.CODE_REVIEW,
"temperature": 0.3
},"architect": {
"model": "gpt-4-turbo",
"builder_type": tb.BuilderTypes.ARCHITECTURAL,
"temperature": 0.2
}
}
def create_team_bot(role: str) -> tb.ChatBot:
= TEAM_BOT_CONFIGS[role]
config = tb.ChatBot().model(config["model"]).temperature(config["temperature"])
bot = bot.prompt_builder(config["builder_type"])._build()
prompt return bot.system_prompt(prompt)
Builder Type Selection Guide
GENERAL: choose when you need maximum flexibility and plan to define custom prompt structure. Provides basic attention optimization without domain constraints.
ARCHITECTURAL: select for system design tasks, architecture documentation, technical debt analysis, and design pattern identification.
CODE_REVIEW: use for pull request reviews, code quality assessment, mentoring feedback, and development best practices guidance.
DEBUGGING: apply for error analysis, troubleshooting workflows, systematic problem solving, and debugging assistance.
Notes
IDE Support: using these constants enables autocomplete, type checking, and refactoring support in most modern IDEs and editors.
Maintainability: constants prevent typos and make code more maintainable when builder types change or new types are added.
Consistency: using constants ensures consistent builder type names across different parts of your application.
Extensibility: new builder types can be added to this class while maintaining backward compatibility.
See Also
ChatBot.prompt_builder : Create attention-optimized prompt builders PromptBuilder : The prompt builder class for structured prompt creation