Notes/apps/server/src/services/llm/base_ai_service.ts

27 lines
864 B
TypeScript
Raw Normal View History

2025-03-02 19:39:10 -08:00
import options from '../options.js';
import type { AIService, ChatCompletionOptions, ChatResponse, Message } from './ai_interface.js';
import { DEFAULT_SYSTEM_PROMPT } from './constants/llm_prompt_constants.js';
2025-03-02 19:39:10 -08:00
export abstract class BaseAIService implements AIService {
protected name: string;
constructor(name: string) {
this.name = name;
}
abstract generateChatCompletion(messages: Message[], options?: ChatCompletionOptions): Promise<ChatResponse>;
isAvailable(): boolean {
2025-03-08 22:02:47 +00:00
return options.getOptionBool('aiEnabled'); // Base check if AI is enabled globally
2025-03-02 19:39:10 -08:00
}
getName(): string {
return this.name;
}
protected getSystemPrompt(customPrompt?: string): string {
2025-03-20 00:06:56 +00:00
// Use prompt from constants file if no custom prompt is provided
return customPrompt || DEFAULT_SYSTEM_PROMPT;
2025-03-02 19:39:10 -08:00
}
}