From e7775e102e3cd5976aeb95f03b051785ca5ce0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=9D=83?= <327779727@qq.com> Date: Fri, 28 Feb 2025 19:28:25 +0800 Subject: [PATCH] feat: enhance API config loading with model info requests --- src/core/webview/CoolClineProvider.ts | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/core/webview/CoolClineProvider.ts b/src/core/webview/CoolClineProvider.ts index 6a569a32..48486858 100644 --- a/src/core/webview/CoolClineProvider.ts +++ b/src/core/webview/CoolClineProvider.ts @@ -1277,15 +1277,32 @@ export class CoolClineProvider implements vscode.WebviewViewProvider { case "loadApiConfiguration": if (message.text) { try { + // 1. 先加载配置 const apiConfig = await this.configManager.loadConfig(message.text) const listApiConfig = await this.configManager.listConfig() - await Promise.all([ - this.updateGlobalState("listApiConfigMeta", listApiConfig), - this.updateGlobalState("currentApiConfigName", message.text), - this.updateApiConfiguration(apiConfig), - ]) + // 2. 更新配置元数据 + await this.updateGlobalState("listApiConfigMeta", listApiConfig) + await this.updateGlobalState("currentApiConfigName", message.text) + + // 3. 更新具体配置前先请求模型信息 + if (apiConfig.llmProvider) { + switch (apiConfig.llmProvider) { + case "ollama": + // 直接调用请求模型的方法 + await this.getOllamaModels(apiConfig.ollamaBaseUrl) + break + case "lmstudio": + await this.getLmStudioModels(apiConfig.lmStudioBaseUrl) + break + case "vscode-lm": + await this.getVsCodeLmModels() + break + } + } + // 4. 更新配置并通知UI + await this.updateApiConfiguration(apiConfig) await this.postStateToWebview() } catch (error) { this.outputChannel.appendLine(