Skip to content

@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.

Terminal window
npm install @presencelearning/ai
  • @angular/core >= 18.0.0
  • @angular/common >= 18.0.0
  • @ai-sdk/angular ^2.0.0
  • ai ^6.0.0
  • rxjs ^7.0.0
  • marked ^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(),
},
}),
},
],
});
FeatureDescription
ChatPresenceChatFactory for streaming chat with tool call tracking
JobsAIJobManager for background AI job polling and status tracking
SessionsAISessionService for managing chat session lifecycle
FeedbackAIFeedbackService for collecting user feedback on AI responses
ComponentDescription
AIMarkdownComponentRenders AI-generated markdown safely via marked (bold, italic, code, lists, links, blockquotes, tables)
AIToolStatusComponentDisplays tool invocation status during streaming
AIToolProgressComponentStreaming tool progress with step descriptions and summaries
SparkleLoaderComponentAnimated loading indicator with therapy-themed status messages
UserPromptDialogComponentMaterial dialog for chiron ask_user tool prompts (radio options + optional free text)
ExportDescription
createAskUserHandlerCreates a reactive handler for the ask_user tool lifecycle — provides a pendingPrompt signal and a respond() method
TypeDescription
PresenceChatChat instance with Angular signals for messages, status, streaming, and tool calls
ChironToolResultTool result from the chiron SSE stream
UserPromptPending ask_user prompt data (question, options, allowCustom, toolCallId)
UserPromptDialogDataInput data for UserPromptDialogComponent (adds optional title)
UserPromptDialogResultDialog return value (response string + isCustom flag)
ToolDescriptionMapMaps tool names to user-friendly descriptions for AIToolProgressComponent
ToolSummarizerFunction that extracts a summary string from a ChironToolResult