update test settings

This commit is contained in:
duanfuxiang 2025-06-18 09:05:54 +08:00
parent 9b4bfe97b4
commit 34d0f1f70c
5 changed files with 43 additions and 19 deletions

View File

@ -104,13 +104,13 @@ const CustomProviderSettings: React.FC<CustomProviderSettingsProps> = ({ plugin,
newSettings.chatModelProvider = selectedProvider;
newSettings.chatModelId = defaultModels.chat;
hasUpdates = true;
console.log(t("settings.ModelProvider.chatModelConfigured", { provider: selectedProvider, model: defaultModels.chat }));
console.debug(t("settings.ModelProvider.chatModelConfigured", { provider: selectedProvider, model: defaultModels.chat }));
}
if (defaultModels.autoComplete) {
newSettings.applyModelProvider = selectedProvider;
newSettings.applyModelId = defaultModels.autoComplete;
hasUpdates = true;
console.log(t("settings.ModelProvider.autocompleteModelConfigured", { provider: selectedProvider, model: defaultModels.autoComplete }));
console.debug(t("settings.ModelProvider.autocompleteModelConfigured", { provider: selectedProvider, model: defaultModels.autoComplete }));
}
}
@ -122,7 +122,7 @@ const CustomProviderSettings: React.FC<CustomProviderSettingsProps> = ({ plugin,
newSettings.embeddingModelProvider = embeddingProvider;
newSettings.embeddingModelId = embeddingDefaultModels.embedding;
hasUpdates = true;
console.log(t("settings.ModelProvider.embeddingModelConfigured", { provider: embeddingProvider, model: embeddingDefaultModels.embedding }));
console.debug(t("settings.ModelProvider.embeddingModelConfigured", { provider: embeddingProvider, model: embeddingDefaultModels.embedding }));
}
}
@ -172,7 +172,7 @@ const CustomProviderSettings: React.FC<CustomProviderSettingsProps> = ({ plugin,
};
const testApiConnection = async (provider: ApiProvider, modelId?: string) => {
console.log(`Testing connection for ${provider}...`);
console.debug(`Testing connection for ${provider}...`);
try {
// 动态导入LLMManager以避免循环依赖
@ -231,7 +231,7 @@ const CustomProviderSettings: React.FC<CustomProviderSettingsProps> = ({ plugin,
// 检查响应是否有效
if (response && response.choices && response.choices.length > 0) {
console.log(`${provider} connection test successful:`, response.choices[0]?.message?.content);
console.debug(`${provider} connection test successful:`, response.choices[0]?.message?.content);
// ApiKeyComponent expects no return value on success, just no thrown error
return;
} else {
@ -290,7 +290,7 @@ const CustomProviderSettings: React.FC<CustomProviderSettingsProps> = ({ plugin,
modelId: string,
isCustom: boolean = false
) => {
console.log(`updateChatModelId: ${provider} -> ${modelId}, isCustom: ${isCustom}`)
console.debug(`updateChatModelId: ${provider} -> ${modelId}, isCustom: ${isCustom}`)
const providerSettingKey = getProviderSettingKey(provider);
const providerSettings = settings[providerSettingKey] || {};
const currentModels = providerSettings.models || [];
@ -312,7 +312,7 @@ const CustomProviderSettings: React.FC<CustomProviderSettingsProps> = ({ plugin,
};
const updateApplyModelId = (provider: ApiProvider, modelId: string, isCustom: boolean = false) => {
console.log(`updateApplyModelId: ${provider} -> ${modelId}, isCustom: ${isCustom}`)
console.debug(`updateApplyModelId: ${provider} -> ${modelId}, isCustom: ${isCustom}`)
const providerSettingKey = getProviderSettingKey(provider);
const providerSettings = settings[providerSettingKey] || {};
const currentModels = providerSettings.models || [];
@ -334,7 +334,7 @@ const CustomProviderSettings: React.FC<CustomProviderSettingsProps> = ({ plugin,
};
const updateEmbeddingModelId = (provider: ApiProvider, modelId: string, isCustom: boolean = false) => {
console.log(`updateEmbeddingModelId: ${provider} -> ${modelId}, isCustom: ${isCustom}`)
console.debug(`updateEmbeddingModelId: ${provider} -> ${modelId}, isCustom: ${isCustom}`)
const providerSettingKey = getProviderSettingKey(provider);
const providerSettings = settings[providerSettingKey] || {};
const currentModels = providerSettings.models || [];

View File

@ -183,7 +183,7 @@ export const ComboBoxComponent: React.FC<ComboBoxComponentProps> = ({
// 统一处理模型选择和保存
const handleModelSelect = (provider: ApiProvider, modelId: string, isCustom?: boolean) => {
console.log(`handleModelSelect: ${provider} -> ${modelId}`)
console.debug(`handleModelSelect: ${provider} -> ${modelId}`)
// 检查是否是自定义模型(不在官方模型列表中)
// const isCustomModel = !modelIds.includes(modelId);
@ -197,7 +197,7 @@ export const ComboBoxComponent: React.FC<ComboBoxComponentProps> = ({
const ids = isEmbedding
? GetEmbeddingProviderModelIds(modelProvider)
: await GetProviderModelIds(modelProvider, settings);
console.log(`📝 Fetched ${ids.length} official models for ${modelProvider}:`, ids);
console.debug(`📝 Fetched ${ids.length} official models for ${modelProvider}:`, ids);
setModelIds(ids);
};
@ -207,14 +207,14 @@ export const ComboBoxComponent: React.FC<ComboBoxComponentProps> = ({
const combinedModelIds = useMemo(() => {
const providerKey = getProviderSettingKey(modelProvider);
const providerModels = settings?.[providerKey]?.models;
console.log(`🔍 Custom models in settings for ${modelProvider}:`, providerModels || 'none')
console.debug(`🔍 Custom models in settings for ${modelProvider}:`, providerModels || 'none')
// Ensure providerModels is an array of strings
if (!providerModels || !Array.isArray(providerModels)) {
console.log(`📋 Using only official models (${modelIds.length}):`, modelIds);
console.debug(`📋 Using only official models (${modelIds.length}):`, modelIds);
return modelIds;
}
const additionalModels = providerModels.filter((model): model is string => typeof model === 'string');
console.log(`📋 Combined models: ${modelIds.length} official + ${additionalModels.length} custom`);
console.debug(`📋 Combined models: ${modelIds.length} official + ${additionalModels.length} custom`);
return [...modelIds, ...additionalModels];
}, [modelIds, settings, modelProvider]);

View File

@ -64,12 +64,14 @@ describe('parseSmartCopilotSettings', () => {
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
anthropicProvider: {
name: 'Anthropic',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
ollamaChatModel: {
baseUrl: '',
@ -141,60 +143,70 @@ describe('parseSmartCopilotSettings', () => {
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
googleProvider: {
name: 'Google',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
groqProvider: {
name: 'Groq',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
grokProvider: {
name: 'Grok',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
infioProvider: {
name: 'Infio',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
ollamaProvider: {
apiKey: 'ollama',
baseUrl: '',
name: 'Ollama',
useCustomUrl: true,
models: [],
},
openaiProvider: {
name: 'OpenAI',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
openaicompatibleProvider: {
name: 'OpenAICompatible',
apiKey: '',
baseUrl: '',
useCustomUrl: true,
models: [],
},
openrouterProvider: {
name: 'OpenRouter',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
siliconflowProvider: {
name: 'SiliconFlow',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
})
})
@ -277,12 +289,14 @@ describe('settings migration', () => {
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
anthropicProvider: {
name: 'Anthropic',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
ollamaChatModel: {
baseUrl: '',
@ -354,60 +368,70 @@ describe('settings migration', () => {
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
googleProvider: {
name: 'Google',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
groqProvider: {
name: 'Groq',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
grokProvider: {
name: 'Grok',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
infioProvider: {
name: 'Infio',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
ollamaProvider: {
apiKey: 'ollama',
baseUrl: '',
name: 'Ollama',
useCustomUrl: true,
models: [],
},
openaiProvider: {
name: 'OpenAI',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
openaicompatibleProvider: {
name: 'OpenAICompatible',
apiKey: '',
baseUrl: '',
useCustomUrl: true,
models: [],
},
openrouterProvider: {
name: 'OpenRouter',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
siliconflowProvider: {
name: 'SiliconFlow',
apiKey: '',
baseUrl: '',
useCustomUrl: false,
models: [],
},
})
})

View File

@ -433,7 +433,7 @@ function migrateSettings(
currentVersion < migration.toVersion &&
migration.toVersion <= SETTINGS_SCHEMA_VERSION
) {
console.log(
console.debug(
`Migrating settings from ${migration.fromVersion} to ${migration.toVersion}`,
)
currentData = migration.migrate(currentData)

View File

@ -665,7 +665,7 @@ export class PromptGenerator {
}
}
if (isOverThreshold) {
console.log("isOverThreshold", isOverThreshold)
console.debug("isOverThreshold", isOverThreshold)
fileContentsPrompts = files.map((file) => {
return `<file_content path="${file.path}">\n(Content omitted due to token limit. Relevant sections will be provided by semantic search below.)\n</file_content>`
}).join('\n')
@ -1017,7 +1017,7 @@ ${transcript.map((t) => `${t.offset}: ${t.text}`).join('\n')}`,
// 首先检查缓存
const cachedData = await this.convertDataManager.findBySource(url)
if (cachedData) {
console.log(`Using cached video conversion for: ${url}`)
console.debug(`Using cached video conversion for: ${url}`)
return [cachedData.content, cachedData.contentPath]
}
@ -1059,7 +1059,7 @@ ${transcript.map((t) => `${t.offset}: ${t.text}`).join('\n')}`,
// 首先检查缓存
const cachedData = await this.convertDataManager.findBySource(file.path)
if (cachedData) {
console.log(`Using cached document conversion for: ${file.path}`)
console.debug(`Using cached document conversion for: ${file.path}`)
return [cachedData.content, cachedData.contentPath]
}
@ -1294,7 +1294,7 @@ ${transcript.map((t) => `${t.offset}: ${t.text}`).join('\n')}`,
content,
})
console.log(`Saved conversion data to cache: ${source}`)
console.debug(`Saved conversion data to cache: ${source}`)
} catch (error) {
console.error('Failed to save conversion data to cache:', error)
throw error
@ -1326,7 +1326,7 @@ ${transcript.map((t) => `${t.offset}: ${t.text}`).join('\n')}`,
// 创建图片文件
await this.app.vault.createBinary(targetPath, bytes.buffer)
console.log(`Image saved: ${targetPath}`)
console.debug(`Image saved: ${targetPath}`)
return targetPath
} catch (error) {
console.error(`Failed to save image to ${targetPath}:`, error)