Documentation Index
Fetch the complete documentation index at: https://docs.dartantic.ai/llms.txt
Use this file to discover all available pages before exploring further.
Google’s DotPrompt specification allows
you to define prompts as files with metadata, templates, and validation. These
files can be executed by dartantic.
Quick Start
You can use the DotPrompt class to parse .prompt files:
import 'package:dotprompt_dart/dotprompt_dart.dart';
final dotPrompt = DotPrompt('''
---
model: openai
input:
default:
length: 3
text: "The quick brown fox jumps over the lazy dog."
---
Summarize this in {{length}} words: {{text}}
''');
// Extract model and render prompt
final prompt = dotPrompt.render();
final agent = Agent(dotPrompt.frontMatter.model!);
final result = await agent.send(prompt);
print(result.output); // "Fox jumps dog."
With Variables
You can pass variables to the render method:
final dotPrompt = DotPrompt('''
---
model: anthropic
---
Translate "{{phrase}}" to {{language}}
''');
final prompt = dotPrompt.render({
'phrase': 'Hello world',
'language': 'Spanish',
});
final agent = Agent(dotPrompt.frontMatter.model!);
await agent.send(prompt);
From Files
You can also read prompts from files:
final file = File('prompts/summarize.prompt');
final content = await file.readAsString();
final dotPrompt = DotPrompt(content);
final agent = Agent(dotPrompt.frontMatter.model!);
await agent.send(dotPrompt.render());
Examples
Next Steps