fix: Chat does not work properly when configuring multiple API keys (#7385)

* refactor(openai): 使用getApiKey方法替代直接访问apiKey属性

* refactor(openai): 使用getApiKey方法替代直接访问provider.apiKey

* refactor(api客户端): 直接使用apiKey属性替代getApiKey方法
This commit is contained in:
Wang Jiyuan 2025-06-20 17:46:45 +08:00 committed by GitHub
parent 1915ba5bfb
commit a813df993c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 3 deletions

View File

@ -90,7 +90,7 @@ export class AnthropicAPIClient extends BaseApiClient<
return this.sdkInstance return this.sdkInstance
} }
this.sdkInstance = new Anthropic({ this.sdkInstance = new Anthropic({
apiKey: this.getApiKey(), apiKey: this.apiKey,
baseURL: this.getBaseURL(), baseURL: this.getBaseURL(),
dangerouslyAllowBrowser: true, dangerouslyAllowBrowser: true,
defaultHeaders: { defaultHeaders: {

View File

@ -135,7 +135,7 @@ export abstract class OpenAIBaseClient<
return this.sdkInstance return this.sdkInstance
} }
let apiKeyForSdkInstance = this.provider.apiKey let apiKeyForSdkInstance = this.apiKey
if (this.provider.id === 'copilot') { if (this.provider.id === 'copilot') {
const defaultHeaders = store.getState().copilot.defaultHeaders const defaultHeaders = store.getState().copilot.defaultHeaders

View File

@ -78,7 +78,7 @@ export class OpenAIResponseAPIClient extends OpenAIBaseClient<
return new OpenAI({ return new OpenAI({
dangerouslyAllowBrowser: true, dangerouslyAllowBrowser: true,
apiKey: this.provider.apiKey, apiKey: this.apiKey,
baseURL: this.getBaseURL(), baseURL: this.getBaseURL(),
defaultHeaders: { defaultHeaders: {
...this.defaultHeaders() ...this.defaultHeaders()