mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-22 00:13:09 +08:00
chore: update @opeoginni/github-copilot-openai-compatible to support gpt5.1 (#11299)
* chore: update @opeoginni/github-copilot-openai-compatible to version 0.1.21 - Updated package version in package.json and yarn.lock. - Refactored OpenAIBaseClient to enhance getBaseURL method and improve header management for SDK instances. * format
This commit is contained in:
parent
d2be450906
commit
a29b2bb3d6
@ -165,7 +165,7 @@
|
|||||||
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
||||||
"@opentelemetry/sdk-trace-node": "^2.0.0",
|
"@opentelemetry/sdk-trace-node": "^2.0.0",
|
||||||
"@opentelemetry/sdk-trace-web": "^2.0.0",
|
"@opentelemetry/sdk-trace-web": "^2.0.0",
|
||||||
"@opeoginni/github-copilot-openai-compatible": "0.1.19",
|
"@opeoginni/github-copilot-openai-compatible": "0.1.21",
|
||||||
"@playwright/test": "^1.52.0",
|
"@playwright/test": "^1.52.0",
|
||||||
"@radix-ui/react-context-menu": "^2.2.16",
|
"@radix-ui/react-context-menu": "^2.2.16",
|
||||||
"@reduxjs/toolkit": "^2.2.5",
|
"@reduxjs/toolkit": "^2.2.5",
|
||||||
|
|||||||
@ -48,9 +48,8 @@ export abstract class OpenAIBaseClient<
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 仅适用于openai
|
// 仅适用于openai
|
||||||
override getBaseURL(): string {
|
override getBaseURL(isSupportedAPIVerion: boolean = true): string {
|
||||||
const host = this.provider.apiHost
|
return formatApiHost(this.provider.apiHost, isSupportedAPIVerion)
|
||||||
return formatApiHost(host)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override async generateImage({
|
override async generateImage({
|
||||||
@ -144,6 +143,11 @@ export abstract class OpenAIBaseClient<
|
|||||||
}
|
}
|
||||||
|
|
||||||
let apiKeyForSdkInstance = this.apiKey
|
let apiKeyForSdkInstance = this.apiKey
|
||||||
|
let baseURLForSdkInstance = this.getBaseURL()
|
||||||
|
let headersForSdkInstance = {
|
||||||
|
...this.defaultHeaders(),
|
||||||
|
...this.provider.extra_headers
|
||||||
|
}
|
||||||
|
|
||||||
if (this.provider.id === 'copilot') {
|
if (this.provider.id === 'copilot') {
|
||||||
const defaultHeaders = store.getState().copilot.defaultHeaders
|
const defaultHeaders = store.getState().copilot.defaultHeaders
|
||||||
@ -151,6 +155,11 @@ export abstract class OpenAIBaseClient<
|
|||||||
// this.provider.apiKey不允许修改
|
// this.provider.apiKey不允许修改
|
||||||
// this.provider.apiKey = token
|
// this.provider.apiKey = token
|
||||||
apiKeyForSdkInstance = token
|
apiKeyForSdkInstance = token
|
||||||
|
baseURLForSdkInstance = this.getBaseURL(false)
|
||||||
|
headersForSdkInstance = {
|
||||||
|
...headersForSdkInstance,
|
||||||
|
...COPILOT_DEFAULT_HEADERS
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.provider.id === 'azure-openai' || this.provider.type === 'azure-openai') {
|
if (this.provider.id === 'azure-openai' || this.provider.type === 'azure-openai') {
|
||||||
@ -164,12 +173,8 @@ export abstract class OpenAIBaseClient<
|
|||||||
this.sdkInstance = new OpenAI({
|
this.sdkInstance = new OpenAI({
|
||||||
dangerouslyAllowBrowser: true,
|
dangerouslyAllowBrowser: true,
|
||||||
apiKey: apiKeyForSdkInstance,
|
apiKey: apiKeyForSdkInstance,
|
||||||
baseURL: this.getBaseURL(),
|
baseURL: baseURLForSdkInstance,
|
||||||
defaultHeaders: {
|
defaultHeaders: headersForSdkInstance
|
||||||
...this.defaultHeaders(),
|
|
||||||
...this.provider.extra_headers,
|
|
||||||
...(this.provider.id === 'copilot' ? COPILOT_DEFAULT_HEADERS : {})
|
|
||||||
}
|
|
||||||
}) as TSdkInstance
|
}) as TSdkInstance
|
||||||
}
|
}
|
||||||
return this.sdkInstance
|
return this.sdkInstance
|
||||||
|
|||||||
10
yarn.lock
10
yarn.lock
@ -5169,15 +5169,15 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@opeoginni/github-copilot-openai-compatible@npm:0.1.19":
|
"@opeoginni/github-copilot-openai-compatible@npm:0.1.21":
|
||||||
version: 0.1.19
|
version: 0.1.21
|
||||||
resolution: "@opeoginni/github-copilot-openai-compatible@npm:0.1.19"
|
resolution: "@opeoginni/github-copilot-openai-compatible@npm:0.1.21"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@ai-sdk/openai": "npm:^2.0.42"
|
"@ai-sdk/openai": "npm:^2.0.42"
|
||||||
"@ai-sdk/openai-compatible": "npm:^1.0.19"
|
"@ai-sdk/openai-compatible": "npm:^1.0.19"
|
||||||
"@ai-sdk/provider": "npm:^2.1.0-beta.4"
|
"@ai-sdk/provider": "npm:^2.1.0-beta.4"
|
||||||
"@ai-sdk/provider-utils": "npm:^3.0.10"
|
"@ai-sdk/provider-utils": "npm:^3.0.10"
|
||||||
checksum: 10c0/dfb01832d7c704b2eb080fc09d31b07fc26e5ac4e648ce219dc0d80cf044ef3cae504427781ec2ce3c5a2459c9c81d043046a255642108d5b3de0f83f4a9f20a
|
checksum: 10c0/05b73d935dc7f24123330ade919698b486ac2a25a7d607c1d3789471f782ead4c803ce6ffd3d97b9ca3f1aadaf6b5c1ea52363c9d24b36894fcfc403fda9cef3
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@ -9952,7 +9952,7 @@ __metadata:
|
|||||||
"@opentelemetry/sdk-trace-base": "npm:^2.0.0"
|
"@opentelemetry/sdk-trace-base": "npm:^2.0.0"
|
||||||
"@opentelemetry/sdk-trace-node": "npm:^2.0.0"
|
"@opentelemetry/sdk-trace-node": "npm:^2.0.0"
|
||||||
"@opentelemetry/sdk-trace-web": "npm:^2.0.0"
|
"@opentelemetry/sdk-trace-web": "npm:^2.0.0"
|
||||||
"@opeoginni/github-copilot-openai-compatible": "npm:0.1.19"
|
"@opeoginni/github-copilot-openai-compatible": "npm:0.1.21"
|
||||||
"@paymoapp/electron-shutdown-handler": "npm:^1.1.2"
|
"@paymoapp/electron-shutdown-handler": "npm:^1.1.2"
|
||||||
"@playwright/test": "npm:^1.52.0"
|
"@playwright/test": "npm:^1.52.0"
|
||||||
"@radix-ui/react-context-menu": "npm:^2.2.16"
|
"@radix-ui/react-context-menu": "npm:^2.2.16"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user