mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-12 20:02:28 +08:00
27 lines
864 B
TypeScript
27 lines
864 B
TypeScript
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';
|
|
|
|
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 {
|
|
return options.getOptionBool('aiEnabled'); // Base check if AI is enabled globally
|
|
}
|
|
|
|
getName(): string {
|
|
return this.name;
|
|
}
|
|
|
|
protected getSystemPrompt(customPrompt?: string): string {
|
|
// Use prompt from constants file if no custom prompt is provided
|
|
return customPrompt || DEFAULT_SYSTEM_PROMPT;
|
|
}
|
|
}
|