mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-19 06:30:10 +08:00
fix: resolve gpt-5-codex streaming response issue (#10781)
* fix: resolve gpt-5-codex streaming response issue - Add patch for @opeoginni/github-copilot-openai-compatible to fix text part ID mismatch - Fix text-end event to use currentTextId instead of value.item.id for proper ID matching - Add COPILOT_DEFAULT_HEADERS to OpenAI client for GitHub Copilot compatibility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * format code --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
33ce41704d
commit
c8ab0b9428
44
.yarn/patches/@opeoginni-github-copilot-openai-compatible-npm-0.1.18-3f65760532.patch
vendored
Normal file
44
.yarn/patches/@opeoginni-github-copilot-openai-compatible-npm-0.1.18-3f65760532.patch
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
diff --git a/dist/index.js b/dist/index.js
|
||||
index 53f411e55a4c9a06fd29bb4ab8161c4ad15980cd..71b91f196c8b886ed90dd237dec5625d79d5677e 100644
|
||||
--- a/dist/index.js
|
||||
+++ b/dist/index.js
|
||||
@@ -12676,10 +12676,13 @@ var OpenAIResponsesLanguageModel = class {
|
||||
}
|
||||
});
|
||||
} else if (value.item.type === "message") {
|
||||
- controller.enqueue({
|
||||
- type: "text-end",
|
||||
- id: value.item.id
|
||||
- });
|
||||
+ // Fix for gpt-5-codex: use currentTextId to ensure text-end matches text-start
|
||||
+ if (currentTextId) {
|
||||
+ controller.enqueue({
|
||||
+ type: "text-end",
|
||||
+ id: currentTextId
|
||||
+ });
|
||||
+ }
|
||||
currentTextId = null;
|
||||
} else if (isResponseOutputItemDoneReasoningChunk(value)) {
|
||||
const activeReasoningPart = activeReasoning[value.item.id];
|
||||
diff --git a/dist/index.mjs b/dist/index.mjs
|
||||
index 7719264da3c49a66c2626082f6ccaae6e3ef5e89..090fd8cf142674192a826148428ed6a0c4a54e35 100644
|
||||
--- a/dist/index.mjs
|
||||
+++ b/dist/index.mjs
|
||||
@@ -12670,10 +12670,13 @@ var OpenAIResponsesLanguageModel = class {
|
||||
}
|
||||
});
|
||||
} else if (value.item.type === "message") {
|
||||
- controller.enqueue({
|
||||
- type: "text-end",
|
||||
- id: value.item.id
|
||||
- });
|
||||
+ // Fix for gpt-5-codex: use currentTextId to ensure text-end matches text-start
|
||||
+ if (currentTextId) {
|
||||
+ controller.enqueue({
|
||||
+ type: "text-end",
|
||||
+ id: currentTextId
|
||||
+ });
|
||||
+ }
|
||||
currentTextId = null;
|
||||
} else if (isResponseOutputItemDoneReasoningChunk(value)) {
|
||||
const activeReasoningPart = activeReasoning[value.item.id];
|
||||
@ -154,7 +154,7 @@
|
||||
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
||||
"@opentelemetry/sdk-trace-node": "^2.0.0",
|
||||
"@opentelemetry/sdk-trace-web": "^2.0.0",
|
||||
"@opeoginni/github-copilot-openai-compatible": "0.1.18",
|
||||
"@opeoginni/github-copilot-openai-compatible": "patch:@opeoginni/github-copilot-openai-compatible@npm%3A0.1.18#~/.yarn/patches/@opeoginni-github-copilot-openai-compatible-npm-0.1.18-3f65760532.patch",
|
||||
"@playwright/test": "^1.52.0",
|
||||
"@radix-ui/react-context-menu": "^2.2.16",
|
||||
"@reduxjs/toolkit": "^2.2.5",
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { loggerService } from '@logger'
|
||||
import { COPILOT_DEFAULT_HEADERS } from '@renderer/aiCore/provider/constants'
|
||||
import {
|
||||
isClaudeReasoningModel,
|
||||
isOpenAIReasoningModel,
|
||||
@ -166,7 +167,8 @@ export abstract class OpenAIBaseClient<
|
||||
baseURL: this.getBaseURL(),
|
||||
defaultHeaders: {
|
||||
...this.defaultHeaders(),
|
||||
...this.provider.extra_headers
|
||||
...this.provider.extra_headers,
|
||||
...(this.provider.id === 'copilot' ? COPILOT_DEFAULT_HEADERS : {})
|
||||
}
|
||||
}) as TSdkInstance
|
||||
}
|
||||
|
||||
14
yarn.lock
14
yarn.lock
@ -7421,6 +7421,18 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@opeoginni/github-copilot-openai-compatible@patch:@opeoginni/github-copilot-openai-compatible@npm%3A0.1.18#~/.yarn/patches/@opeoginni-github-copilot-openai-compatible-npm-0.1.18-3f65760532.patch":
|
||||
version: 0.1.18
|
||||
resolution: "@opeoginni/github-copilot-openai-compatible@patch:@opeoginni/github-copilot-openai-compatible@npm%3A0.1.18#~/.yarn/patches/@opeoginni-github-copilot-openai-compatible-npm-0.1.18-3f65760532.patch::version=0.1.18&hash=1cf9d0"
|
||||
dependencies:
|
||||
"@ai-sdk/openai": "npm:^2.0.42"
|
||||
"@ai-sdk/openai-compatible": "npm:^1.0.19"
|
||||
"@ai-sdk/provider": "npm:^2.1.0-beta.4"
|
||||
"@ai-sdk/provider-utils": "npm:^3.0.10"
|
||||
checksum: 10c0/cfffc031d2742068d20baed0e0ade6e9182c29ee7a425fa64262c04023ae75220b8b944ad2c9554255681e325fa1a70ec5e1f961b5f7370c871e70cbaeac0e79
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@oxc-project/runtime@npm:0.71.0":
|
||||
version: 0.71.0
|
||||
resolution: "@oxc-project/runtime@npm:0.71.0"
|
||||
@ -13993,7 +14005,7 @@ __metadata:
|
||||
"@opentelemetry/sdk-trace-base": "npm:^2.0.0"
|
||||
"@opentelemetry/sdk-trace-node": "npm:^2.0.0"
|
||||
"@opentelemetry/sdk-trace-web": "npm:^2.0.0"
|
||||
"@opeoginni/github-copilot-openai-compatible": "npm:0.1.18"
|
||||
"@opeoginni/github-copilot-openai-compatible": "patch:@opeoginni/github-copilot-openai-compatible@npm%3A0.1.18#~/.yarn/patches/@opeoginni-github-copilot-openai-compatible-npm-0.1.18-3f65760532.patch"
|
||||
"@playwright/test": "npm:^1.52.0"
|
||||
"@radix-ui/react-context-menu": "npm:^2.2.16"
|
||||
"@reduxjs/toolkit": "npm:^2.2.5"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user