bingocode 1.0.40 → 1.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@ export function anthropicToOpenaiChat(body: AnthropicRequest): OpenAIChatRequest
|
|
|
33
33
|
|
|
34
34
|
// Convert messages
|
|
35
35
|
for (const msg of body.messages) {
|
|
36
|
-
convertMessage(msg, messages)
|
|
36
|
+
convertMessage(msg, messages, body.model)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// Build request
|
|
@@ -90,7 +90,7 @@ export function anthropicToOpenaiChat(body: AnthropicRequest): OpenAIChatRequest
|
|
|
90
90
|
return result
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
function convertMessage(msg: AnthropicMessage, output: OpenAIChatMessage[]): void {
|
|
93
|
+
function convertMessage(msg: AnthropicMessage, output: OpenAIChatMessage[], model: string = ''): void {
|
|
94
94
|
const content = msg.content
|
|
95
95
|
|
|
96
96
|
// Simple string content
|
|
@@ -108,7 +108,7 @@ function convertMessage(msg: AnthropicMessage, output: OpenAIChatMessage[]): voi
|
|
|
108
108
|
if (msg.role === 'user') {
|
|
109
109
|
convertUserMessage(content, output)
|
|
110
110
|
} else {
|
|
111
|
-
convertAssistantMessage(content, output)
|
|
111
|
+
convertAssistantMessage(content, output, model)
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -147,13 +147,16 @@ function convertUserMessage(blocks: AnthropicContentBlock[], output: OpenAIChatM
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
function convertAssistantMessage(blocks: AnthropicContentBlock[], output: OpenAIChatMessage[]): void {
|
|
150
|
+
function convertAssistantMessage(blocks: AnthropicContentBlock[], output: OpenAIChatMessage[], model: string = ''): void {
|
|
151
151
|
let textContent = ''
|
|
152
|
+
let reasoningContent = ''
|
|
152
153
|
const toolCalls: OpenAIToolCall[] = []
|
|
153
154
|
|
|
154
155
|
for (const block of blocks) {
|
|
155
156
|
if (block.type === 'text') {
|
|
156
157
|
textContent += block.text
|
|
158
|
+
} else if (block.type === 'thinking') {
|
|
159
|
+
reasoningContent += block.thinking
|
|
157
160
|
} else if (block.type === 'tool_use') {
|
|
158
161
|
toolCalls.push({
|
|
159
162
|
id: block.id,
|
|
@@ -164,7 +167,6 @@ function convertAssistantMessage(blocks: AnthropicContentBlock[], output: OpenAI
|
|
|
164
167
|
},
|
|
165
168
|
})
|
|
166
169
|
}
|
|
167
|
-
// Skip thinking blocks — no OpenAI equivalent
|
|
168
170
|
}
|
|
169
171
|
|
|
170
172
|
const msg: OpenAIChatMessage = {
|
|
@@ -172,6 +174,11 @@ function convertAssistantMessage(blocks: AnthropicContentBlock[], output: OpenAI
|
|
|
172
174
|
content: textContent || null,
|
|
173
175
|
}
|
|
174
176
|
|
|
177
|
+
// Only pass reasoning_content back for DeepSeek models to satisfy their mandatory back-transmission rule
|
|
178
|
+
if (reasoningContent && model.toLowerCase().includes('deepseek')) {
|
|
179
|
+
(msg as any).reasoning_content = reasoningContent
|
|
180
|
+
}
|
|
181
|
+
|
|
175
182
|
if (toolCalls.length > 0) {
|
|
176
183
|
msg.tool_calls = toolCalls
|
|
177
184
|
}
|