mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 14:29:15 +08:00
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:
parent
1915ba5bfb
commit
a813df993c
@ -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: {
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user