mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
109 lines
2.3 KiB
TypeScript
109 lines
2.3 KiB
TypeScript
/**
|
|
* Configuration interfaces for LLM services
|
|
* These interfaces replace string parsing with proper typed objects
|
|
*/
|
|
|
|
/**
|
|
* Provider precedence configuration
|
|
*/
|
|
export interface ProviderPrecedenceConfig {
|
|
providers: ProviderType[];
|
|
defaultProvider?: ProviderType;
|
|
}
|
|
|
|
/**
|
|
* Model configuration with provider information
|
|
*/
|
|
export interface ModelConfig {
|
|
provider: ProviderType;
|
|
modelId: string;
|
|
displayName?: string;
|
|
capabilities?: ModelCapabilities;
|
|
}
|
|
|
|
/**
|
|
* Embedding provider precedence configuration
|
|
*/
|
|
export interface EmbeddingProviderPrecedenceConfig {
|
|
providers: EmbeddingProviderType[];
|
|
defaultProvider?: EmbeddingProviderType;
|
|
}
|
|
|
|
/**
|
|
* Model capabilities
|
|
*/
|
|
export interface ModelCapabilities {
|
|
contextWindow?: number;
|
|
supportsTools?: boolean;
|
|
supportsVision?: boolean;
|
|
supportsStreaming?: boolean;
|
|
maxTokens?: number;
|
|
temperature?: number;
|
|
}
|
|
|
|
/**
|
|
* Complete AI configuration
|
|
*/
|
|
export interface AIConfig {
|
|
enabled: boolean;
|
|
providerPrecedence: ProviderPrecedenceConfig;
|
|
embeddingProviderPrecedence: EmbeddingProviderPrecedenceConfig;
|
|
defaultModels: Record<ProviderType, string | undefined>;
|
|
providerSettings: ProviderSettings;
|
|
}
|
|
|
|
/**
|
|
* Provider-specific settings
|
|
*/
|
|
export interface ProviderSettings {
|
|
openai?: OpenAISettings;
|
|
anthropic?: AnthropicSettings;
|
|
ollama?: OllamaSettings;
|
|
}
|
|
|
|
export interface OpenAISettings {
|
|
apiKey?: string;
|
|
baseUrl?: string;
|
|
defaultModel?: string;
|
|
}
|
|
|
|
export interface AnthropicSettings {
|
|
apiKey?: string;
|
|
baseUrl?: string;
|
|
defaultModel?: string;
|
|
}
|
|
|
|
export interface OllamaSettings {
|
|
baseUrl?: string;
|
|
defaultModel?: string;
|
|
timeout?: number;
|
|
}
|
|
|
|
/**
|
|
* Valid provider types
|
|
*/
|
|
export type ProviderType = 'openai' | 'anthropic' | 'ollama';
|
|
|
|
/**
|
|
* Valid embedding provider types
|
|
*/
|
|
export type EmbeddingProviderType = 'openai' | 'ollama' | 'local';
|
|
|
|
/**
|
|
* Model identifier with provider prefix (e.g., "openai:gpt-4" or "ollama:llama2")
|
|
*/
|
|
export interface ModelIdentifier {
|
|
provider?: ProviderType;
|
|
modelId: string;
|
|
fullIdentifier: string; // The complete string representation
|
|
}
|
|
|
|
/**
|
|
* Validation result for configuration
|
|
*/
|
|
export interface ConfigValidationResult {
|
|
isValid: boolean;
|
|
errors: string[];
|
|
warnings: string[];
|
|
}
|