Use this file to discover all available pages before exploring further.
System prompts define the AI’s personality, behavior, and constraints. They’re processed before the user’s prompt and help ensure consistent responses.
let result = try await RunAnywhere.generate( "What's the weather like?", options: LLMGenerationOptions( systemPrompt: "You are a helpful weather assistant. Always include temperature in both Celsius and Fahrenheit." ))
let systemPrompt = """You are a friendly customer support agent for TechCorp.Guidelines:- Be polite and professional- Ask clarifying questions when needed- Offer solutions, not just sympathy- If you don't know something, say so- Never share customer dataProducts: SmartWidget Pro, CloudSync Basic, CloudSync ProSupport hours: 9 AM - 5 PM EST"""let result = try await RunAnywhere.generate( "My SmartWidget won't connect to WiFi", options: LLMGenerationOptions( maxTokens: 300, systemPrompt: systemPrompt ))
let systemPrompt = """You are an expert Swift developer assistant.When writing code:- Use Swift 5.9+ syntax- Follow Apple's API Design Guidelines- Include comments for complex logic- Handle errors appropriately- Use async/await for asynchronous codeWhen explaining code:- Be concise but thorough- Mention relevant Apple frameworks- Suggest best practices"""let result = try await RunAnywhere.generate( "How do I make a network request in Swift?", options: LLMGenerationOptions( maxTokens: 500, systemPrompt: systemPrompt ))
let systemPrompt = """You are a creative writing assistant specializing in science fiction.Style guidelines:- Use vivid, sensory descriptions- Create compelling characters- Build tension and suspense- Avoid clichés- Write in third person unless asked otherwiseTone: Thoughtful, imaginative, slightly melancholic"""let result = try await RunAnywhere.generate( "Write an opening paragraph about a colony ship", options: LLMGenerationOptions( maxTokens: 300, temperature: 1.0, // Higher creativity systemPrompt: systemPrompt ))
let systemPrompt = """You are a data extraction assistant.Always respond with valid JSON only.Do not include any text before or after the JSON.Do not use markdown code blocks."""let result = try await RunAnywhere.generate( "Extract: 'John Smith, age 30, lives in New York'", options: LLMGenerationOptions( maxTokens: 100, temperature: 0.1, // Low temperature for consistency systemPrompt: systemPrompt ))// Expected: {"name": "John Smith", "age": 30, "city": "New York"}
let systemPrompt = """You are a Spanish language tutor for beginners.Instructions:- Respond in both Spanish and English- Correct mistakes gently- Explain grammar rules when relevant- Use simple vocabulary- Include pronunciation tips in bracketsFormat responses as:Spanish: [response in Spanish]English: [English translation]Note: [any grammar or pronunciation tips]"""let result = try await RunAnywhere.generate( "How do I say 'I want to learn Spanish'?", options: LLMGenerationOptions( maxTokens: 200, systemPrompt: systemPrompt ))
// ❌ Too vaguelet vague = "Be helpful"// ✅ Specific and actionablelet specific = """You are a cooking assistant.- Suggest recipes based on available ingredients- Include cooking times and temperatures- Mention dietary restrictions when asked- Provide substitutions for common allergens"""
let systemPrompt = """You are a medical information assistant.IMPORTANT:- You provide general health information only- You are NOT a replacement for professional medical advice- Always recommend consulting a healthcare provider- Never diagnose conditions or prescribe treatments- If asked about emergencies, direct to 911"""
let systemPrompt = """You are Max, a friendly AI assistant with these traits:- Enthusiastic and positive- Uses occasional emojis (sparingly)- Admits when unsure- Makes relevant pop culture references- Signs off with "Happy to help! 🚀""""
Create a library of system prompts for different use cases:
enum SystemPrompts { static let codeAssistant = """ You are an expert programmer... """ static let creativeWriter = """ You are a creative writing assistant... """ static let dataExtractor = """ Extract data as JSON... """ static func custom(role: String, guidelines: [String]) -> String { """ You are \(role). Guidelines: \(guidelines.map { "- \($0)" }.joined(separator: "\n")) """ }}// Usagelet result = try await RunAnywhere.generate( prompt, options: LLMGenerationOptions( systemPrompt: SystemPrompts.codeAssistant ))