Skip to content

Managing Prompts

Learn how to create, edit, version, and organize your prompts in Mandatum.

Creating a Prompt

Via Dashboard

  1. Click New Prompt in the sidebar

  2. Fill in the prompt details:

    • Name: Unique identifier (e.g., customer-classifier)
    • Description: What this prompt does
    • Model: Choose your LLM provider and model
    • Template: Your prompt text with variables
  3. Click Save

Create Prompt

Via API

Python

python
from mandatum import Mandatum

client = Mandatum(api_key="your-api-key")

prompt = client.prompts.create(
    name="customer-classifier",
    description="Classifies customer support tickets",
    model="gpt-4",
    template="""
    Classify the following customer message into one of these categories:
    - billing
    - technical
    - general

    Message: {message}

    Return only the category name.
    """
)

TypeScript

Coming Soon

A TypeScript/JavaScript SDK is in development. For now, use the REST API directly.

Template Variables

Use {variable_name} syntax to create dynamic prompts:

text
You are a {role} assistant. Help the user with {task}.

User question: {question}

When running the prompt, provide values for all variables:

python
response = client.prompts.run(
    prompt_name="assistant-prompt",
    input_variables={
        "role": "technical support",
        "task": "troubleshooting",
        "question": "Why won't my app connect?"
    }
)

Variable Defaults

Set default values for optional variables:

python
prompt = client.prompts.create(
    name="greeting",
    template="Hello {name}! {optional_message}",
    defaults={
        "optional_message": "How can I help you today?"
    }
)

Model Configuration

Supported Providers

ProviderModels
OpenAIgpt-4, gpt-4-turbo, gpt-3.5-turbo
Anthropicclaude-3-opus, claude-3-sonnet, claude-3-haiku
Googlegemini-pro, gemini-pro-vision
CustomAny OpenAI-compatible API

Model Parameters

Configure temperature, max tokens, and other parameters:

python
prompt = client.prompts.create(
    name="creative-writer",
    model="gpt-4",
    parameters={
        "temperature": 0.9,
        "max_tokens": 2000,
        "top_p": 0.95,
        "frequency_penalty": 0.5
    }
)

Switching Providers

Change the model without modifying your code:

python
# Update via API
client.prompts.update(
    prompt_name="customer-classifier",
    model="claude-3-sonnet"  # Switch from GPT-4 to Claude
)

Versioning

Every prompt change creates a new version. Access version history in the dashboard.

Creating Versions

Versions are created automatically on every update:

python
# Version 1
client.prompts.create(name="greet", template="Hello {name}")

# Version 2 (auto-created)
client.prompts.update(name="greet", template="Hi {name}!")

# Version 3 (auto-created)
client.prompts.update(name="greet", template="Hey {name}!")

Running Specific Versions

python
# Run latest version (default)
response = client.prompts.run(
    prompt_name="greet",
    input_variables={"name": "Alice"}
)

# Run specific version
response = client.prompts.run(
    prompt_name="greet",
    version=2,
    input_variables={"name": "Alice"}
)

Comparing Versions

Use the dashboard to compare versions side-by-side:

  1. Navigate to your prompt
  2. Click Version History
  3. Select two versions to compare
  4. View diff highlighting

Version Comparison

Learn more about versioning.

Organization

Tags

Organize prompts with tags:

python
prompt = client.prompts.create(
    name="support-classifier",
    tags=["support", "classification", "production"]
)

# Find prompts by tag
prompts = client.prompts.list(tags=["production"])

Folders

Group related prompts in folders:

python
prompt = client.prompts.create(
    name="support-classifier",
    folder="/customer-support/classifiers"
)

Search prompts by name, description, or content:

python
results = client.prompts.search(query="customer support")

A/B Testing

Test multiple prompt variations simultaneously:

python
# Create variants
client.prompts.create_variant(
    prompt_name="greeting",
    variant_name="formal",
    template="Good day, {name}. How may I assist you?"
)

client.prompts.create_variant(
    prompt_name="greeting",
    variant_name="casual",
    template="Hey {name}! What's up?"
)

# Run A/B test
test = client.evaluations.create_ab_test(
    prompt_name="greeting",
    variants=["formal", "casual"],
    traffic_split=[0.5, 0.5]  # 50/50 split
)

# View results
results = client.evaluations.get_results(test_id=test.id)

Best Practices

Naming Conventions

Use descriptive, hierarchical names:

✓ customer-support/ticket-classifier
✓ content/blog-post-writer
✓ data/json-extractor

✗ prompt1
✗ test
✗ new_prompt

Template Structure

Structure prompts for clarity:

text
# System Role
You are an expert {role}.

# Task
{task_description}

# Input
{user_input}

# Output Format
{output_format}

# Examples (optional)
{examples}

Testing

Test prompts before deploying:

  1. Use test API keys in development
  2. Test with edge cases and unusual inputs
  3. Verify output format consistency
  4. Check token usage and costs

Documentation

Document your prompts:

python
prompt = client.prompts.create(
    name="legal-summarizer",
    description="""
    Summarizes legal documents into plain English.

    Input: Full legal document text
    Output: 3-5 sentence summary

    Model: GPT-4 (required for accuracy)
    Cost: ~$0.15 per document
    """,
    template="..."
)

Next Steps