@presencelearning/ai
AI integration library for Presence Learning. Provides chat functionality, background job management, and UI components for AI-powered features using the Vercel AI SDK.
Install
Section titled “Install”npm install @presencelearning/aiPeer Dependencies
Section titled “Peer Dependencies”@angular/core>= 18.0.0@angular/common>= 18.0.0@ai-sdk/angular^2.0.0ai^6.0.0rxjs^7.0.0marked^15.0.0
Configure the AI module in your application:
import { PRESENCE_AI_CONFIG } from '@presencelearning/ai';
bootstrapApplication(AppComponent, { providers: [ { provide: PRESENCE_AI_CONFIG, useFactory: () => ({ chiron: { baseUrl: environment.apps.chiron.url }, workplace: { baseUrl: environment.apps.apiWorkplace.url }, auth: { getToken: () => inject(AuthStore).getCurrentToken(), }, }), }, ],});Features
Section titled “Features”| Feature | Description |
|---|---|
| Chat | PresenceChatFactory for streaming chat with tool call tracking |
| Jobs | AIJobManager for background AI job polling and status tracking |
| Sessions | AISessionService for managing chat session lifecycle |
| Feedback | AIFeedbackService for collecting user feedback on AI responses |
Components
Section titled “Components”| Component | Description |
|---|---|
AIMarkdownComponent | Renders AI-generated markdown safely via marked (bold, italic, code, lists, links, blockquotes, tables) |
AIToolStatusComponent | Displays tool invocation status during streaming |
AIToolProgressComponent | Streaming tool progress with step descriptions and summaries |
SparkleLoaderComponent | Animated loading indicator with therapy-themed status messages |
UserPromptDialogComponent | Material dialog for chiron ask_user tool prompts (radio options + optional free text) |
Utilities
Section titled “Utilities”| Export | Description |
|---|---|
createAskUserHandler | Creates a reactive handler for the ask_user tool lifecycle — provides a pendingPrompt signal and a respond() method |
Key Types
Section titled “Key Types”| Type | Description |
|---|---|
PresenceChat | Chat instance with Angular signals for messages, status, streaming, and tool calls |
ChironToolResult | Tool result from the chiron SSE stream |
UserPrompt | Pending ask_user prompt data (question, options, allowCustom, toolCallId) |
UserPromptDialogData | Input data for UserPromptDialogComponent (adds optional title) |
UserPromptDialogResult | Dialog return value (response string + isCustom flag) |
ToolDescriptionMap | Maps tool names to user-friendly descriptions for AIToolProgressComponent |
ToolSummarizer | Function that extracts a summary string from a ChironToolResult |