Citations
Track sources in agent responses
Agents can cite their sources – show where information comes from.
Quick Start
- Simple Usage
typescript import { Agent } from 'praisonai'; const agent = new Agent({ instructions: 'Answer using the provided documents', knowledge: './docs/', citations: true }); const result = await agent.chat('What is the return policy?'); console.log(result.content); // "You can return items within 30 days [1]" console.log(result.citations); // [{ id: 1, source: 'returns.md', text: '...' }] - With Configuration
typescript const agent = new Agent({ citations: { format: 'inline', // or 'footnote', 'endnotes' includePageNumbers: true } });
User Interaction Flow
Configuration Levels
// Level 1: Bool - Enable citations
const agent = new Agent({
citations: true
});
// Level 2: String - Citation style
const agent = new Agent({
citations: 'inline' // 'inline', 'footnote', 'endnotes'
});
// Level 3: Dict - Full options
const agent = new Agent({
citations: {
format: 'footnote',
includePageNumbers: true,
maxCitations: 5,
minRelevanceScore: 0.7
}
});Citation Formats
| Format | Example |
|---|---|
inline | “Returns within 30 days [1]” |
footnote | “Returns within 30 days¹” |
endnotes | Citations listed at end |
API Reference
Knowledge ModuleKnowledge and citation support
Best Practices
Use with knowledge base
Citations work best when agent has documents to reference.
Set relevance threshold
Use minRelevanceScore to ensure quality citations.
Limit citation count
Too many citations can clutter responses.