ChatBot.preset
Apply a pre-configured behavior template to instantly specialize the chatbot.
USAGE
ChatBot.preset(preset_name)
Presets are professionally crafted behavior templates that instantly configure multiple aspects of the chatbot including conversational tone, expertise areas, response verbosity, operational constraints, and system prompts. This provides a quick way to create specialized chatbots for specific domains without manually configuring each parameter.
The preset system includes a curated library of templates covering common use cases like customer support, technical advisory, creative writing, data analysis, and legal information. Each preset is designed by experts to provide optimal performance for its intended domain while maintaining flexibility for customization.
When a preset is applied, it sets default values for various configuration parameters. You can still override individual settings after applying a preset, allowing for both rapid deployment and fine-tuned customization.
Parameters
preset_name : Union[str, PresetNames]
-
The name of the behavior preset to apply. You can use either a string or a constant from
PresetNames
for better autocomplete and type safety. Using PresetNames constants (recommended):python import talk_box as tb bot = tb.ChatBot().preset(tb.PresetNames.TECHNICAL_ADVISOR)
See the “Available Presets” section below for a complete list of available presets and their descriptions.
Returns
ChatBot
-
Returns self to enable method chaining, allowing you to combine preset application with other configuration methods.
Raises
: ValueError
-
If the preset name is not found in the available preset library. The method fails gracefully and continues if preset loading encounters issues.
Available Presets
The Talk Box framework includes professionally crafted presets for common use cases:
Business and Support:
PresetNames.CUSTOMER_SUPPORT
or"customer_support"
: polite, professional customer service interactions with concise responses and helpful guidancePresetNames.LEGAL_ADVISOR
or"legal_advisor"
: professional legal information with appropriate disclaimers and thorough, well-sourced responses
Technical and Development:
PresetNames.TECHNICAL_ADVISOR
or"technical_advisor"
: authoritative technical guidance with detailed explanations, code examples, and best practicesPresetNames.DATA_ANALYST
or"data_analyst"
: analytical, evidence-based responses for data science and statistical analysis tasks
Creative and Content:
PresetNames.CREATIVE_WRITER
or"creative_writer"
: imaginative storytelling and creative content generation with descriptive, engaging responses
Additional presets may be available through custom preset libraries or organizational preset collections.
Examples
Using default presets for common scenarios
Apply presets for different types of interactions:
import talk_box as tb
# Customer support chatbot
= (
support_bot
tb.ChatBot()"customer_support")
.preset("gpt-3.5-turbo") # Fast, cost-effective for support
.model(
)
# Technical advisor for development questions
= (
tech_bot
tb.ChatBot()"technical_advisor")
.preset("gpt-4-turbo") # Powerful model for complex technical questions
.model(
)
# Creative writing assistant
= (
writer_bot
tb.ChatBot()"creative_writer")
.preset("claude-3-opus-20240229") # Excellent for creative tasks
.model( )
Combining presets with custom configuration
Start with a preset and customize specific aspects:
# Start with technical advisor preset, then customize
= (
specialized_bot
tb.ChatBot()"technical_advisor")
.preset("Senior Python developer specializing in web frameworks")
.persona(0.1) # Very low randomness for precise technical answers
.temperature("code_executor", "documentation_search"])
.tools(["deprecated_practices", "insecure_patterns"])
.avoid([
)
# Customer support with custom personality
= (
friendly_support
tb.ChatBot()"customer_support")
.preset("Enthusiastic and empathetic customer advocate")
.persona(True) # Detailed explanations for complex issues
.verbose( )
Preset-specific optimizations
Different presets work better with specific models and settings:
# Data analyst with analytical model and settings
= (
analyst_bot
tb.ChatBot()"data_analyst")
.preset("gpt-4-turbo") # Strong reasoning capabilities
.model(0.2) # Low creativity, high accuracy
.temperature(2000) # Allow detailed analysis
.max_tokens(
)
# Creative writer with creative model and settings
= (
creative_bot
tb.ChatBot()"creative_writer")
.preset("claude-3-opus-20240229") # Excellent creative capabilities
.model(0.8) # High creativity
.temperature(3000) # Allow longer creative outputs
.max_tokens( )
Inspecting preset configuration
View what a preset configures before applying it:
# Get preset details
= tb.PresetManager()
manager = manager.get_preset("technical_advisor")
tech_preset
if tech_preset:
print(f"Tone: {tech_preset.tone}")
print(f"Expertise: {tech_preset.expertise}")
print(f"Verbosity: {tech_preset.verbosity}")
print(f"Constraints: {', '.join(tech_preset.constraints)}")
# Apply preset and check final configuration
= tb.ChatBot().preset("technical_advisor")
bot = bot.get_config()
config print(f"Final config: {config}")
Dynamic preset switching
Change presets based on conversation context:
# Start with customer support
= tb.ChatBot().preset("customer_support")
bot
# Handle general customer inquiry
= bot.chat("I need help with my order")
response1
# Switch to technical advisor for technical questions
"technical_advisor")
bot.preset(= bot.chat("How do I integrate your API?")
response2
# Switch to data analyst for analytics questions
"data_analyst")
bot.preset(= bot.chat("What patterns do you see in our user data?") response3
Preset Customization
Individual Override: all preset settings can be overridden by calling the corresponding configuration methods after applying the preset.
Custom Presets: organizations can create custom presets using the PresetManager
to add domain-specific behavior templates.
Preset Inheritance: advanced implementations can create preset hierarchies where specialized presets extend base presets with additional configuration.
Context Awareness: some presets include conditional logic in their system prompts that adapts behavior based on conversation context.
Notes
Preset Loading: presets are loaded from the PresetManager
which initializes with a default library and can be extended with custom presets.
Graceful Failure: if a preset is not found or fails to load, the method continues without error, allowing the chatbot to function with default settings.
System Prompts: each preset includes carefully crafted system prompts that provide detailed behavioral instructions to the underlying language model.
Best Practices: choose presets that match your intended use case, then fine-tune with additional configuration methods as needed.
See Also
PresetManager : Manage and create custom behavior presets persona : Add custom personality traits on top of preset behavior model : Choose models that work well with specific presets temperature : Adjust creativity levels appropriate for the preset domain