|
|
|
|
@ -65,7 +65,7 @@ export default class AiSettingsWidget extends OptionsWidget {
|
|
|
|
|
|
|
|
|
|
// Core AI options
|
|
|
|
|
this.setupChangeHandler('.ai-enabled', 'aiEnabled', true, true);
|
|
|
|
|
this.setupChangeHandler('.ai-provider-precedence', 'aiProviderPrecedence', true);
|
|
|
|
|
this.setupChangeHandler('.ai-chat-provider', 'aiChatProvider', true);
|
|
|
|
|
this.setupChangeHandler('.ai-temperature', 'aiTemperature');
|
|
|
|
|
this.setupChangeHandler('.ai-system-prompt', 'aiSystemPrompt');
|
|
|
|
|
|
|
|
|
|
@ -132,7 +132,7 @@ export default class AiSettingsWidget extends OptionsWidget {
|
|
|
|
|
this.setupChangeHandler('.enable-automatic-indexing', 'enableAutomaticIndexing', false, true);
|
|
|
|
|
this.setupChangeHandler('.embedding-similarity-threshold', 'embeddingSimilarityThreshold');
|
|
|
|
|
this.setupChangeHandler('.max-notes-per-llm-query', 'maxNotesPerLlmQuery');
|
|
|
|
|
this.setupChangeHandler('.embedding-provider-precedence', 'embeddingProviderPrecedence', true);
|
|
|
|
|
this.setupChangeHandler('.ai-embedding-provider', 'aiEmbeddingProvider', true);
|
|
|
|
|
this.setupChangeHandler('.embedding-dimension-strategy', 'embeddingDimensionStrategy');
|
|
|
|
|
this.setupChangeHandler('.embedding-batch-size', 'embeddingBatchSize');
|
|
|
|
|
this.setupChangeHandler('.embedding-update-interval', 'embeddingUpdateInterval');
|
|
|
|
|
@ -194,42 +194,26 @@ export default class AiSettingsWidget extends OptionsWidget {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get provider precedence
|
|
|
|
|
const providerPrecedence = (this.$widget.find('.ai-provider-precedence').val() as string || '').split(',');
|
|
|
|
|
// Get selected chat provider
|
|
|
|
|
const selectedChatProvider = this.$widget.find('.ai-chat-provider').val() as string;
|
|
|
|
|
|
|
|
|
|
// Check for OpenAI configuration if it's in the precedence list
|
|
|
|
|
const openaiWarnings: string[] = [];
|
|
|
|
|
if (providerPrecedence.includes('openai')) {
|
|
|
|
|
// Check for configuration issues with the selected provider
|
|
|
|
|
const chatWarnings: string[] = [];
|
|
|
|
|
|
|
|
|
|
if (selectedChatProvider === 'openai') {
|
|
|
|
|
const openaiApiKey = this.$widget.find('.openai-api-key').val();
|
|
|
|
|
if (!openaiApiKey) {
|
|
|
|
|
openaiWarnings.push(t("ai_llm.empty_key_warning.openai"));
|
|
|
|
|
chatWarnings.push(t("ai_llm.empty_key_warning.openai"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check for Anthropic configuration if it's in the precedence list
|
|
|
|
|
const anthropicWarnings: string[] = [];
|
|
|
|
|
if (providerPrecedence.includes('anthropic')) {
|
|
|
|
|
} else if (selectedChatProvider === 'anthropic') {
|
|
|
|
|
const anthropicApiKey = this.$widget.find('.anthropic-api-key').val();
|
|
|
|
|
if (!anthropicApiKey) {
|
|
|
|
|
anthropicWarnings.push(t("ai_llm.empty_key_warning.anthropic"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check for Voyage configuration if it's in the precedence list
|
|
|
|
|
const voyageWarnings: string[] = [];
|
|
|
|
|
if (providerPrecedence.includes('voyage')) {
|
|
|
|
|
const voyageApiKey = this.$widget.find('.voyage-api-key').val();
|
|
|
|
|
if (!voyageApiKey) {
|
|
|
|
|
voyageWarnings.push(t("ai_llm.empty_key_warning.voyage"));
|
|
|
|
|
chatWarnings.push(t("ai_llm.empty_key_warning.anthropic"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check for Ollama configuration if it's in the precedence list
|
|
|
|
|
const ollamaWarnings: string[] = [];
|
|
|
|
|
if (providerPrecedence.includes('ollama')) {
|
|
|
|
|
} else if (selectedChatProvider === 'ollama') {
|
|
|
|
|
const ollamaBaseUrl = this.$widget.find('.ollama-base-url').val();
|
|
|
|
|
if (!ollamaBaseUrl) {
|
|
|
|
|
ollamaWarnings.push(t("ai_llm.ollama_no_url"));
|
|
|
|
|
chatWarnings.push(t("ai_llm.ollama_no_url"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -238,27 +222,20 @@ export default class AiSettingsWidget extends OptionsWidget {
|
|
|
|
|
const embeddingsEnabled = this.$widget.find('.enable-automatic-indexing').prop('checked');
|
|
|
|
|
|
|
|
|
|
if (embeddingsEnabled) {
|
|
|
|
|
const embeddingProviderPrecedence = (this.$widget.find('.embedding-provider-precedence').val() as string || '').split(',');
|
|
|
|
|
const selectedEmbeddingProvider = this.$widget.find('.ai-embedding-provider').val() as string;
|
|
|
|
|
|
|
|
|
|
if (embeddingProviderPrecedence.includes('openai') && !this.$widget.find('.openai-api-key').val()) {
|
|
|
|
|
if (selectedEmbeddingProvider === 'openai' && !this.$widget.find('.openai-api-key').val()) {
|
|
|
|
|
embeddingWarnings.push(t("ai_llm.empty_key_warning.openai"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (embeddingProviderPrecedence.includes('voyage') && !this.$widget.find('.voyage-api-key').val()) {
|
|
|
|
|
} else if (selectedEmbeddingProvider === 'voyage' && !this.$widget.find('.voyage-api-key').val()) {
|
|
|
|
|
embeddingWarnings.push(t("ai_llm.empty_key_warning.voyage"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (embeddingProviderPrecedence.includes('ollama') && !this.$widget.find('.ollama-base-url').val()) {
|
|
|
|
|
} else if (selectedEmbeddingProvider === 'ollama' && !this.$widget.find('.ollama-base-url').val()) {
|
|
|
|
|
embeddingWarnings.push(t("ai_llm.empty_key_warning.ollama"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Combine all warnings
|
|
|
|
|
const allWarnings = [
|
|
|
|
|
...openaiWarnings,
|
|
|
|
|
...anthropicWarnings,
|
|
|
|
|
...voyageWarnings,
|
|
|
|
|
...ollamaWarnings,
|
|
|
|
|
...chatWarnings,
|
|
|
|
|
...embeddingWarnings
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
@ -459,7 +436,7 @@ export default class AiSettingsWidget extends OptionsWidget {
|
|
|
|
|
this.$widget.find('.ai-enabled').prop('checked', options.aiEnabled !== 'false');
|
|
|
|
|
this.$widget.find('.ai-temperature').val(options.aiTemperature || '0.7');
|
|
|
|
|
this.$widget.find('.ai-system-prompt').val(options.aiSystemPrompt || '');
|
|
|
|
|
this.$widget.find('.ai-provider-precedence').val(options.aiProviderPrecedence || 'openai,anthropic,ollama');
|
|
|
|
|
this.$widget.find('.ai-chat-provider').val(options.aiChatProvider || '');
|
|
|
|
|
|
|
|
|
|
// OpenAI Section
|
|
|
|
|
this.$widget.find('.openai-api-key').val(options.openaiApiKey || '');
|
|
|
|
|
@ -482,7 +459,7 @@ export default class AiSettingsWidget extends OptionsWidget {
|
|
|
|
|
this.$widget.find('.ollama-embedding-model').val(options.ollamaEmbeddingModel || 'nomic-embed-text');
|
|
|
|
|
|
|
|
|
|
// Embedding Options
|
|
|
|
|
this.$widget.find('.embedding-provider-precedence').val(options.embeddingProviderPrecedence || 'openai,voyage,ollama,local');
|
|
|
|
|
this.$widget.find('.ai-embedding-provider').val(options.aiEmbeddingProvider || '');
|
|
|
|
|
this.$widget.find('.embedding-auto-update-enabled').prop('checked', options.embeddingAutoUpdateEnabled !== 'false');
|
|
|
|
|
this.$widget.find('.enable-automatic-indexing').prop('checked', options.enableAutomaticIndexing !== 'false');
|
|
|
|
|
this.$widget.find('.embedding-similarity-threshold').val(options.embeddingSimilarityThreshold || '0.75');
|
|
|
|
|
|