Prompt with Citations
User Intent
"How do I get AI responses with source citations and page references?"
Operation
SDK Method: promptConversation()
Use Case: Q&A with source attribution (synchronous, not streaming)
Complete Code Example (TypeScript)
import { Graphlit } from 'graphlit-client';
const graphlit = new Graphlit();
const response = await graphlit.promptConversation(
'What are the key findings from the research papers?',
conversationId // Optional: undefined for new conversation
);
// Extract conversation ID
const convId = response.promptConversation?.conversation?.id;
// Extract message
const message = response.promptConversation?.message?.message;
// Extract citations with page numbers
const citations = response.promptConversation?.message?.citations;
console.log('Answer:', message);
console.log('\nSources:');
citations?.forEach((citation, i) => {
console.log(`[${i + 1}] ${citation.content?.name}`);
console.log(` Type: ${citation.content?.type}`);
console.log(` Page: ${citation.startPage || 'N/A'}`);
console.log(` Relevance: ${citation.score?.toFixed(2)}`);
});Response Structure
Multi-Turn Conversation with Citations
Display Citations
Output:
Filter Citations by Type
Sort Citations by Relevance
Link to Source Content
Use Custom Model
Filter by Collection
Key Differences: promptConversation vs streamAgent
Citations
✅ Returns citations
❌ No citations
Streaming
❌ Waits for complete
✅ Real-time chunks
Tool calling
❌ Not supported
✅ Supported
Page numbers
✅ Exact page refs
❌ N/A
Use case
Q&A with sources
Chat UI streaming
When to use promptConversation:
Need source citations
Need exact page numbers
Don't need streaming
Simple Q&A
When to use streamAgent:
Building chat UI with streaming
Need tool/function calling
Don't need citations
Common Issues
Issue: No citations returned Solution: Citations depend on retrieval quality. Check that:
Content is ingested and indexed
Search query matches content
Specification supports retrieval
Issue: Page numbers missing Solution: Page numbers only available for:
PDFs with page structure
Documents (not web pages or emails)
Issue: Too many citations Solution: Filter by relevance score or limit count:
Issue: Citations from wrong collection
Solution: Pass collection filter in filter parameter.
Issue: Want streaming with citations
Solution: Not possible. Citations only work with synchronous promptConversation. Use streamAgent for streaming (no citations) or promptConversation for citations (no streaming).
Last updated
Was this helpful?