Skip to content

Commit 5d77379

Browse files
committed
Merge branch 'feature/chat-completions-reasoning' into all
2 parents e43fe4c + 8191930 commit 5d77379

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/lib/api-config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ const USER_AGENT = `GitHubCopilotChat/${COPILOT_VERSION}`
1414
const API_VERSION = "2025-10-01"
1515

1616
export const copilotBaseUrl = (state: State) =>
17-
`https://api.${state.accountType}.githubcopilot.com`
18-
17+
state.accountType === "individual" ?
18+
"https://api.githubcopilot.com"
19+
: `https://api.${state.accountType}.githubcopilot.com`
1920
export const copilotHeaders = (state: State, vision: boolean = false) => {
2021
const headers: Record<string, string> = {
2122
Authorization: `Bearer ${state.copilotToken}`,

src/routes/messages/stream-translation.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ function handleContent(
218218
delta.content === ""
219219
&& delta.reasoning_opaque
220220
&& delta.reasoning_opaque.length > 0
221+
&& state.thinkingBlockOpen
221222
) {
222223
events.push(
223224
{
@@ -317,6 +318,15 @@ function handleThinkingText(
317318
events: Array<AnthropicStreamEventData>,
318319
) {
319320
if (delta.reasoning_text && delta.reasoning_text.length > 0) {
321+
// compatible with copilot API returning content->reasoning_text->reasoning_opaque in different deltas
322+
// this is an extremely abnormal situation, probably a server-side bug
323+
// only occurs in the claude model, with a very low probability of occurrence
324+
if (state.contentBlockOpen) {
325+
delta.content = delta.reasoning_text
326+
delta.reasoning_text = undefined
327+
return
328+
}
329+
320330
if (!state.thinkingBlockOpen) {
321331
events.push({
322332
type: "content_block_start",

0 commit comments

Comments
 (0)