UNPKG

@aituber-onair/core

Version:

Core library for AITuber OnAir providing voice synthesis and chat processing

69 lines (68 loc) 2.45 kB
import { ChatService } from '../../ChatService'; import { Message, MessageWithVision } from '../../../../types'; /** * Claude implementation of ChatService */ export declare class ClaudeChatService implements ChatService { private apiKey; private model; private visionModel; /** Provider name */ readonly provider: string; /** * Constructor * @param apiKey Anthropic API key * @param model Name of the model to use * @param visionModel Name of the vision model */ constructor(apiKey: string, model?: string, visionModel?: string); /** * Get the current model name * @returns Model name */ getModel(): string; /** * Get the current vision model name * @returns Vision model name */ getVisionModel(): string; /** * Process chat messages * @param messages Array of messages to send * @param onPartialResponse Callback to receive each part of streaming response * @param onCompleteResponse Callback to execute when response is complete */ processChat(messages: Message[], onPartialResponse: (text: string) => void, onCompleteResponse: (text: string) => Promise<void>): Promise<void>; /** * Process chat messages with images * @param messages Array of messages to send (including images) * @param onPartialResponse Callback to receive each part of streaming response * @param onCompleteResponse Callback to execute when response is complete * @throws Error if the selected model doesn't support vision */ processVisionChat(messages: MessageWithVision[], onPartialResponse: (text: string) => void, onCompleteResponse: (text: string) => Promise<void>): Promise<void>; /** * Convert AITuber OnAir messages to Claude format * @param messages Array of messages * @returns Claude formatted messages */ private convertMessagesToClaudeFormat; /** * Convert AITuber OnAir vision messages to Claude format * @param messages Array of vision messages * @returns Claude formatted vision messages */ private convertVisionMessagesToClaudeFormat; /** * Map AITuber OnAir roles to Claude roles * @param role AITuber OnAir role * @returns Claude role */ private mapRoleToClaude; /** * Get MIME type from URL * @param url Image URL * @returns MIME type */ private getMimeTypeFromUrl; }