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 guidance
  • PresetNames.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 practices
  • PresetNames.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()
    .preset("customer_support")
    .model("gpt-3.5-turbo")  # Fast, cost-effective for support
)

# Technical advisor for development questions
tech_bot = (
    tb.ChatBot()
    .preset("technical_advisor")
    .model("gpt-4-turbo")  # Powerful model for complex technical questions
)

# Creative writing assistant
writer_bot = (
    tb.ChatBot()
    .preset("creative_writer")
    .model("claude-3-opus-20240229")  # Excellent for creative tasks
)

Combining presets with custom configuration

Start with a preset and customize specific aspects:

# Start with technical advisor preset, then customize
specialized_bot = (
    tb.ChatBot()
    .preset("technical_advisor")
    .persona("Senior Python developer specializing in web frameworks")
    .temperature(0.1)  # Very low randomness for precise technical answers
    .tools(["code_executor", "documentation_search"])
    .avoid(["deprecated_practices", "insecure_patterns"])
)

# Customer support with custom personality
friendly_support = (
    tb.ChatBot()
    .preset("customer_support")
    .persona("Enthusiastic and empathetic customer advocate")
    .verbose(True)  # Detailed explanations for complex issues
)

Preset-specific optimizations

Different presets work better with specific models and settings:

# Data analyst with analytical model and settings
analyst_bot = (
    tb.ChatBot()
    .preset("data_analyst")
    .model("gpt-4-turbo")  # Strong reasoning capabilities
    .temperature(0.2)  # Low creativity, high accuracy
    .max_tokens(2000)  # Allow detailed analysis
)

# Creative writer with creative model and settings
creative_bot = (
    tb.ChatBot()
    .preset("creative_writer")
    .model("claude-3-opus-20240229")  # Excellent creative capabilities
    .temperature(0.8)  # High creativity
    .max_tokens(3000)  # Allow longer creative outputs
)

Inspecting preset configuration

View what a preset configures before applying it:

# Get preset details
manager = tb.PresetManager()
tech_preset = manager.get_preset("technical_advisor")

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
bot = tb.ChatBot().preset("technical_advisor")
config = bot.get_config()
print(f"Final config: {config}")

Dynamic preset switching

Change presets based on conversation context:

# Start with customer support
bot = tb.ChatBot().preset("customer_support")

# Handle general customer inquiry
response1 = bot.chat("I need help with my order")

# Switch to technical advisor for technical questions
bot.preset("technical_advisor")
response2 = bot.chat("How do I integrate your API?")

# Switch to data analyst for analytics questions
bot.preset("data_analyst")
response3 = bot.chat("What patterns do you see in our user data?")

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