Prompts
Understanding prompts and prompt engineering in PromptKit.
What is a Prompt?
Section titled “What is a Prompt?”A prompt is the text input sent to an LLM. It tells the model what to do and provides context for generating a response.
Basic Example
Section titled “Basic Example”User: What's the capital of France?
LLM Response: The capital of France is Paris.Structured Prompt
Section titled “Structured Prompt”System: You are a helpful assistant. Be concise.
User: What's the capital of France?
LLM Response: Paris.Prompt Components
Section titled “Prompt Components”Messages
Section titled “Messages”Prompts consist of messages with different roles:
- System: Instructions for the AI’s behavior
- User: Input from the end user
- Assistant: Previous AI responses (for context)
- Tool: Results from function calls
Example in PromptKit:
messages := []types.Message{ {Role: "system", Content: "You are a helpful assistant"}, {Role: "user", Content: "Hello"}, {Role: "assistant", Content: "Hi! How can I help?"}, {Role: "user", Content: "What's 2+2?"},}System Prompts
Section titled “System Prompts”System prompts set the AI’s behavior:
Good system prompt:
You are a customer support agent for TechCorp.
Guidelines:- Be professional and empathetic- Keep responses under 100 words- Reference documentation when possible- Escalate complex issues to human agents
Available resources:- Help docs: https://help.techcorp.com- Status page: https://status.techcorp.comPoor system prompt:
Be helpful.Prompt Engineering Techniques
Section titled “Prompt Engineering Techniques”1. Clear Instructions
Section titled “1. Clear Instructions”Bad:
Write something about dogs.Good:
Write a 3-sentence summary about Golden Retrievers.Include: origin, temperament, and typical uses.2. Few-Shot Examples
Section titled “2. Few-Shot Examples”Provide examples to guide the model:
Convert user questions to support ticket categories.
Examples:Q: "I can't log in" → Category: AuthenticationQ: "My credit card was declined" → Category: BillingQ: "The app crashed" → Category: Technical
Q: "I forgot my password" → Category: ?3. Chain-of-Thought
Section titled “3. Chain-of-Thought”Ask the model to explain its reasoning:
Solve this math problem step-by-step:If Alice has 3 apples and Bob gives her 5 more, how many does Alice have?
Let's solve this step by step:1. Alice starts with: 3 apples2. Bob gives her: 5 apples3. Total: 3 + 5 = 8 apples
Answer: 8 apples4. Role-Based
Section titled “4. Role-Based”Assign a specific role:
You are an experienced software architect reviewing code.Focus on:- Design patterns- Scalability- Maintainability
Review this code:[code here]Prompts in PromptKit
Section titled “Prompts in PromptKit”Runtime
Section titled “Runtime”Runtime uses prompts with templates:
templates := template.NewRegistry()templates.RegisterTemplate("support", &template.PromptTemplate{ SystemPrompt: "You are a support agent. Be helpful.", Variables: map[string]string{ "company": "TechCorp", },})
pipe := pipeline.NewPipeline( middleware.TemplateMiddleware(templates, nil), middleware.ProviderMiddleware(provider, nil, nil, nil),)
result, _ := pipe.Execute(ctx, "user", "Help me")SDK simplifies prompt management:
conv := sdk.NewConversation(provider, &sdk.ConversationConfig{ SystemPrompt: "You are a helpful assistant", Model: "gpt-4o-mini",})
response, _ := conv.Send(ctx, "Hello")PackC packages prompts for distribution:
# support.promptsystem: | You are a for . Be professional and concise.
user: |Pack and use:
packc pack prompts/ -o support.packpack, _ := packc.LoadPack("support.pack")template := pack.Templates["support"]PromptArena
Section titled “PromptArena”PromptArena tests prompts:
tests: - name: Support Query prompt: "How do I reset my password?" assertions: - type: contains value: "password reset" - type: max_length value: 200Best Practices
Section titled “Best Practices”✅ Be specific - Clear instructions get better results
✅ Provide context - Give the model relevant information
✅ Use examples - Show what you want
✅ Set constraints - Specify format, length, tone
✅ Test variations - Try different phrasings
✅ Version prompts - Track changes over time
Don’ts
Section titled “Don’ts”❌ Don’t be vague - “Be helpful” isn’t enough
❌ Don’t assume knowledge - Provide necessary context
❌ Don’t skip system prompts - They guide behavior
❌ Don’t ignore length - Longer ≠ better
❌ Don’t forget to test - Use PromptArena
Common Patterns
Section titled “Common Patterns”Task-Oriented
Section titled “Task-Oriented”Task: Extract customer email from support ticket
Input: "Hi, my email is john@example.com and I need help"Output: john@example.com
Input: "Please contact me at support@company.com"Output:Conversational
Section titled “Conversational”You are a friendly chatbot. Maintain context across messages.
Be:- Conversational and warm- Helpful and informative- Concise (under 50 words per response)Analytical
Section titled “Analytical”Analyze the following text and provide:1. Main topic2. Sentiment (positive/negative/neutral)3. Key entities mentioned4. Confidence score (0-1)
Text: [input]Creative
Section titled “Creative”Write a creative product description for:
Product:Features:Target audience:
Style: Engaging and persuasiveLength: 50-100 wordsPrompt Management
Section titled “Prompt Management”Development
Section titled “Development”- Store prompts in version control
- Use meaningful names
- Document prompt purpose
- Track performance metrics
Testing
Section titled “Testing”- Test with PromptArena
- Try edge cases
- Measure quality
- Compare variations
Production
Section titled “Production”- Load from PackC files
- Use templates for flexibility
- Monitor performance
- Version prompts
Troubleshooting
Section titled “Troubleshooting”Problem: Inconsistent Responses
Section titled “Problem: Inconsistent Responses”Solution: Add more specific instructions and examples
Problem: Wrong Format
Section titled “Problem: Wrong Format”Solution: Specify exact format in prompt
Before:
List the items.After:
List the items in JSON format:{"items": ["item1", "item2"]}Problem: Ignoring Instructions
Section titled “Problem: Ignoring Instructions”Solution: Emphasize important instructions
IMPORTANT: Always include sources.NEVER make up information.
[rest of prompt]Problem: Too Verbose
Section titled “Problem: Too Verbose”Solution: Set length constraints
Answer in exactly 2 sentences. Be concise.Summary
Section titled “Summary”Prompts are the foundation of LLM applications. Good prompts:
- Provide clear instructions
- Include relevant context
- Use examples when helpful
- Set appropriate constraints
- Are tested and versioned
Related Documentation
Section titled “Related Documentation”- Templates - Organizing prompts
- Validation - Content safety
- Runtime Templates - Implementation
- PackC - Prompt packaging