const response = await ollama.generate({
model: 'llama2',
prompt: 'Write a poem about the moon',
// Control randomness (0.0-1.0)
// Higher values make output more random, lower values more deterministic
temperature: 0.7,
// Nucleus sampling - consider tokens comprising the top_p probability mass (0.0-1.0)
// Higher values consider more tokens, making output more diverse
top_p: 0.9,
// Top-k sampling - consider top k most probable tokens (1-100)
// Lower values focus on most likely tokens
top_k: 40,
// Number of tokens to predict
num_predict: 100,
// Stop sequences - model will stop generating when it hits these strings
stop: ['END', '###'],
// System prompt to guide the model's behavior
system: 'You are a poet who writes in the style of Emily Dickinson',
// Custom template for prompt formatting
template: '{{.System}}\n\nUser: {{.Prompt}}\n\nAssistant:',
// Previous conversation context (token ids from previous interaction)
context: [123, 456, 789],
// Get raw model output instead of just the generated response
raw: true,
// Request output in specific format (json, md)
format: 'json',
});