AI Study Assistant
The AI study assistant provides LLM-powered scripture study features that go beyond surface-level summaries. It is citational, scholarly, and context-aware -- designed to deepen understanding rather than replace it.
Overview
The AI assistant is available as both a sidebar widget and a dedicated pane. It operates in the context of whatever passage the user is currently reading, providing three primary capabilities:
| Capability | Description | Endpoint |
|---|---|---|
| Passage Explanation | Scholarly, citational explanation of a scripture passage | POST /ai/explain |
| Study Questions | AI-generated discussion and reflection questions for personal or group study | POST /ai/questions |
| Cross-Reference Suggestions | AI-discovered connections between passages that may not exist in the manual cross-reference index | POST /ai/connections |
All AI responses include tappable citations that link back to specific passages and lexicon entries in the knowledge graph.
How It Works
When a user asks the AI about a passage:
- The AI service receives the request with the current passage context
- It fetches the full passage data (text, cross-references, word alignments) from the content service
- Jinja2 prompt templates combine the passage context with the user's question
- The request goes to Anthropic Claude (primary) or OpenAI (fallback)
- The response is parsed, citations are linked to graph nodes, and the result is cached in Redis
Semantic Caching
To minimize API costs, the AI service implements Redis-based semantic caching by prompt hash. If a similar question about the same passage has been asked recently, the cached response is returned without an LLM call. Cache TTL defaults to 3600 seconds (1 hour).
Access and Rate Limits
AI features require the ai_features entitlement, available on Scholar and Academic plans:
| Plan | AI Requests | Notes |
|---|---|---|
| Reader (free) | 5/hour | Limited taste of AI capabilities |
| Scholar | 50/hour | Full access for personal study |
| Academic | 200/hour | Higher limits for research workflows |
Session-level counting tracks usage in Redis. When a user exhausts their hourly quota, the AI panel shows a clear message with the reset time rather than a generic error.
User Interface
Sidebar Widget
The core.ai plugin contributes a sidebar widget that provides quick access to AI features without leaving the reading flow. The widget shows a text input and preset prompt buttons ("Explain this passage", "What does the original language reveal?", "Generate study questions").
Dedicated Pane
For deeper AI interaction, users can open the AI assistant as a full pane. The pane provides conversation history, longer responses, and the ability to ask follow-up questions in context.
Entry Points
Cmd+Enterfrom any passage to ask the AI about the current selection- "Study This Verse" from the verse action sheet
- Sidebar widget always accessible in the right dock zone
- Hover card Layer 2 tab shows AI-generated insights for the hovered verse
Phased Rollout
| Phase | Capabilities |
|---|---|
| Phase 1 (current) | Passage explanation, study questions, cross-reference suggestions |
| Phase 2 | Semantic search over graph embeddings, AI-guided exploration, personalized study plans |
| Phase 3 | Fine-tuned models on LDS scholarship corpus for higher-quality denominational responses |
Deep Dive: Provider Abstraction
The AI service uses an abstract LLMClient interface with concrete implementations for Anthropic and OpenAI. This allows:
- Provider fallback -- If Anthropic is unavailable, requests automatically fall through to OpenAI
- Model flexibility -- The Anthropic model is configurable via
GOSPELIB_AI_ANTHROPIC_MODEL(defaults toclaude-sonnet-4-20250514) - Cost optimization -- Different models can be used for different request types (e.g., a smaller model for study questions, a larger model for detailed explanations)
The service is implemented in Python with FastAPI at services/ai/, running on port 8400.
Related Pages
- Services > AI -- Technical documentation for the AI service
- Knowledge Graph -- The graph data that provides AI context
- Subscriptions -- AI feature entitlements by plan tier
- Architecture > Security > Entitlements -- How AI rate limits are enforced