fix: support Kimi Coding Plan and third-party SSE without space after…#303
Open
404805854 wants to merge 1 commit into
Open
fix: support Kimi Coding Plan and third-party SSE without space after…#303404805854 wants to merge 1 commit into
404805854 wants to merge 1 commit into
Conversation
… data:
Kimi Coding Plan (api.kimi.com/coding) returns SSE events like
`data:{"type":...}` without a space after the colon. The existing
parsers (parseOpenAiLine, parseAnthropicLine, parseGoogleLine) strictly
checked for `startsWith("data: ")` with a trailing space, causing
every event to be silently discarded and the stream to produce empty
content.
Changes:
- Relax all three SSE prefix checks to `startsWith("data:")` and use
`slice(5).trim()` so both `data: {...}` and `data:{...}` work.
- Enhance parseAnthropicLine to handle:
- content_block_delta with bare `text` field (no `type` inside delta)
- complete `message` events (single-shot SSE)
- OpenAI-shaped `choices[0].delta.content` fallback
- Add Kimi Coding Plan and Moonshot to requiresBearerAuth so they get
`Authorization: Bearer` instead of `x-api-key`.
- Move `anthropic-version` to base headers so all Anthropic wires
(including Bearer-auth ones) receive it.
- Add `kimi-coding-plan` preset to the settings UI.
- Add unit tests for new parsing paths and auth behavior.
Fixes nashsu#302
Author
|
使用 kimi coding plan 以及 minimax coding plan完成相关测试确定修改可行,可以提供 kimi coding plan 的 key 用于测试 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… data:
Kimi Coding Plan (api.kimi.com/coding) returns SSE events like
data:{"type":...}without a space after the colon. The existing parsers (parseOpenAiLine, parseAnthropicLine, parseGoogleLine) strictly checked forstartsWith("data: ")with a trailing space, causing every event to be silently discarded and the stream to produce empty content.Changes:
startsWith("data:")and useslice(5).trim()so bothdata: {...}anddata:{...}work.textfield (notypeinside delta)messageevents (single-shot SSE)choices[0].delta.contentfallbackAuthorization: Bearerinstead ofx-api-key.anthropic-versionto base headers so all Anthropic wires (including Bearer-auth ones) receive it.kimi-coding-planpreset to the settings UI.Fixes #302