Through options
Through a message
A.system message in a conversation becomes options.systemPrompt automatically:
options.systemPrompt is
what the model receives.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Control model behaviour with a system prompt
let result = try await RunAnywhere.llm.generate(
prompt: "How do I reverse a string?",
options: LlmOptions(
systemPrompt: "You are a Swift expert. Answer with code, then one sentence."
)
)
.system message in a conversation becomes options.systemPrompt automatically:
let messages = [
ChatMessage(role: .system, content: "You are a Swift expert."),
ChatMessage(role: .user, content: "How do I reverse a string?"),
]
let result = try await RunAnywhere.llm.generate(messages: messages)
options.systemPrompt is
what the model receives.
// Works
"You are a terse assistant. Answer in one sentence. No preamble."
// Works less well on a 0.6B model
"You are an extremely helpful, knowledgeable, and friendly AI assistant who always
strives to provide the most comprehensive and detailed responses possible while
maintaining a warm and approachable tone…"
let options = LlmOptions(
systemPrompt: """
You are a classifier. Reply with exactly one word: positive, negative, or neutral.
""",
temperature: 0.1
)
enum Prompts {
static let summarizer = LlmOptions(
systemPrompt: "Summarize in three bullet points. No introduction.",
maxOutputTokens: 150,
temperature: 0.3
)
static let coder = LlmOptions(
systemPrompt: "You are a Swift expert. Answer with code first.",
temperature: 0.2
)
}
let summary = try await RunAnywhere.llm.generate(prompt: article, options: Prompts.summarizer)