@xapp/stentor-service-generative-ai
v2.0.1
Published
Generative AI Service
Readme
@xapp/stentor-service-generative-ai
Generative AI service for LLM-backed features: analyzing leads, inbound emails, chat transcripts, and websites, plus summarizing conversations. It defines a common LLMService interface with implementations for Anthropic's Claude API (ClaudeService), AWS Bedrock (AWSBedrockService), and OpenAI (OpenAIService), plus a FallbackLLMService that retries against a secondary provider when the primary returns a rate-limit/throttling error.
Usage
import { GenerativeAIService, ClaudeService } from "@xapp/stentor-service-generative-ai";
const llmService = new ClaudeService({
keyGetter: () => process.env.ANTHROPIC_API_KEY || "",
// Required. There is no default model: providers retire versions on a schedule and a
// hardcoded fallback outlives them silently.
model: "claude-haiku-4-5-20251001"
});
const generativeAIService = new GenerativeAIService(llmService);
const leadAnalysis = await generativeAIService.analyzeLead(lead, {
businessDescription: "A local plumbing company"
});Required Environment Variables
None are required. API keys and AWS credentials are passed to each LLMService constructor (keyGetter for ClaudeService/OpenAIService; optional region, defaulting to us-east-1, and credentials for AWSBedrockService, which otherwise uses the AWS SDK default credential chain), so the caller decides where they come from.
STUDIO_APP_ID- optional; when lead and transcript analysis render a chat transcript into the prompt, messages from this id (or"bot") are labelled as the agent
