ai-protocol-adapters 1.0.0-alpha.12 → 1.0.0-alpha.13
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/dist/index.d.mts +0 -12
- package/dist/index.d.ts +0 -12
- package/dist/index.js +38 -64
- package/dist/index.mjs +38 -64
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -6178,18 +6178,6 @@ interface O2ASSEAdapterConfig {
|
|
|
6178
6178
|
defaultRole: 'assistant' | 'user' | 'system';
|
|
6179
6179
|
/** 是否生成唯一消息ID */
|
|
6180
6180
|
generateUniqueMessageId: boolean;
|
|
6181
|
-
/**
|
|
6182
|
-
* 是否启用启发式thinking标记解析
|
|
6183
|
-
*
|
|
6184
|
-
* 当设置为true时,会检测content字段中的<thinking>...</thinking>标记
|
|
6185
|
-
* 并自动分离为thinking_delta事件。
|
|
6186
|
-
*
|
|
6187
|
-
* ⚠️ 警告:只在Provider确认会在content中返回thinking标记时启用!
|
|
6188
|
-
* 例如:iFlow的GLM-4.6等推理模型
|
|
6189
|
-
*
|
|
6190
|
-
* @default false - 默认禁用,需要显式启用
|
|
6191
|
-
*/
|
|
6192
|
-
enableThinkingTagParsing: boolean;
|
|
6193
6181
|
}
|
|
6194
6182
|
|
|
6195
6183
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -6178,18 +6178,6 @@ interface O2ASSEAdapterConfig {
|
|
|
6178
6178
|
defaultRole: 'assistant' | 'user' | 'system';
|
|
6179
6179
|
/** 是否生成唯一消息ID */
|
|
6180
6180
|
generateUniqueMessageId: boolean;
|
|
6181
|
-
/**
|
|
6182
|
-
* 是否启用启发式thinking标记解析
|
|
6183
|
-
*
|
|
6184
|
-
* 当设置为true时,会检测content字段中的<thinking>...</thinking>标记
|
|
6185
|
-
* 并自动分离为thinking_delta事件。
|
|
6186
|
-
*
|
|
6187
|
-
* ⚠️ 警告:只在Provider确认会在content中返回thinking标记时启用!
|
|
6188
|
-
* 例如:iFlow的GLM-4.6等推理模型
|
|
6189
|
-
*
|
|
6190
|
-
* @default false - 默认禁用,需要显式启用
|
|
6191
|
-
*/
|
|
6192
|
-
enableThinkingTagParsing: boolean;
|
|
6193
6181
|
}
|
|
6194
6182
|
|
|
6195
6183
|
/**
|
package/dist/index.js
CHANGED
|
@@ -3513,13 +3513,6 @@ var A2ORequestAdapter = class {
|
|
|
3513
3513
|
convertOpenAIResponseToClaude(openaiResponse) {
|
|
3514
3514
|
const claudeContent = [];
|
|
3515
3515
|
const message = openaiResponse.choices?.[0]?.message;
|
|
3516
|
-
const messageAny = message;
|
|
3517
|
-
if (messageAny?.reasoning_content && typeof messageAny.reasoning_content === "string") {
|
|
3518
|
-
claudeContent.push({
|
|
3519
|
-
type: "text",
|
|
3520
|
-
text: messageAny.reasoning_content
|
|
3521
|
-
});
|
|
3522
|
-
}
|
|
3523
3516
|
if (message?.content) {
|
|
3524
3517
|
claudeContent.push({
|
|
3525
3518
|
type: "text",
|
|
@@ -4043,6 +4036,14 @@ var StreamingProtocolAdapter = class {
|
|
|
4043
4036
|
if (!content) return;
|
|
4044
4037
|
state.reasoningContent += content;
|
|
4045
4038
|
if (!state.thinkingBlockStarted) {
|
|
4039
|
+
if (state.contentBlockStarted) {
|
|
4040
|
+
sseLines.push(
|
|
4041
|
+
"event: content_block_stop",
|
|
4042
|
+
'data: {"type":"content_block_stop","index":0}',
|
|
4043
|
+
""
|
|
4044
|
+
);
|
|
4045
|
+
state.contentBlockStarted = false;
|
|
4046
|
+
}
|
|
4046
4047
|
sseLines.push(
|
|
4047
4048
|
"event: content_block_start",
|
|
4048
4049
|
'data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":"<thinking>"}}',
|
|
@@ -4787,36 +4788,9 @@ var StreamingStateManager = class {
|
|
|
4787
4788
|
};
|
|
4788
4789
|
}
|
|
4789
4790
|
/**
|
|
4790
|
-
*
|
|
4791
|
-
*/
|
|
4792
|
-
static processTextContent(content, state, sseLines
|
|
4793
|
-
if (enableThinkingTagParsing) {
|
|
4794
|
-
const thinkingTagPattern = /<thinking>([\s\S]*?)(<\/thinking>|$)/i;
|
|
4795
|
-
const match = content.match(thinkingTagPattern);
|
|
4796
|
-
if (match) {
|
|
4797
|
-
const beforeThinking = content.substring(0, match.index);
|
|
4798
|
-
const thinkingContent = match[1];
|
|
4799
|
-
const afterThinking = match[2] === "</thinking>" ? content.substring(match.index + match[0].length) : "";
|
|
4800
|
-
if (beforeThinking.trim()) {
|
|
4801
|
-
if (!state.hasContent) {
|
|
4802
|
-
sseLines.push(...SSEEventGenerator.generateTextBlockStart(state.contentBlockIndex));
|
|
4803
|
-
state.hasContent = true;
|
|
4804
|
-
}
|
|
4805
|
-
sseLines.push(...SSEEventGenerator.generateTextDelta(state.contentBlockIndex, beforeThinking));
|
|
4806
|
-
}
|
|
4807
|
-
if (thinkingContent.trim()) {
|
|
4808
|
-
this.processReasoningContent(thinkingContent, state, sseLines);
|
|
4809
|
-
}
|
|
4810
|
-
if (afterThinking.trim()) {
|
|
4811
|
-
if (!state.hasContent) {
|
|
4812
|
-
sseLines.push(...SSEEventGenerator.generateTextBlockStart(state.contentBlockIndex));
|
|
4813
|
-
state.hasContent = true;
|
|
4814
|
-
}
|
|
4815
|
-
sseLines.push(...SSEEventGenerator.generateTextDelta(state.contentBlockIndex, afterThinking));
|
|
4816
|
-
}
|
|
4817
|
-
return;
|
|
4818
|
-
}
|
|
4819
|
-
}
|
|
4791
|
+
* 处理文本内容
|
|
4792
|
+
*/
|
|
4793
|
+
static processTextContent(content, state, sseLines) {
|
|
4820
4794
|
if (!state.hasContent) {
|
|
4821
4795
|
sseLines.push(...SSEEventGenerator.generateTextBlockStart(state.contentBlockIndex));
|
|
4822
4796
|
state.hasContent = true;
|
|
@@ -4904,9 +4878,7 @@ var DEFAULT_CONFIG2 = {
|
|
|
4904
4878
|
errorDataMaxLength: 100,
|
|
4905
4879
|
warningDataMaxLength: 50,
|
|
4906
4880
|
defaultRole: "assistant",
|
|
4907
|
-
generateUniqueMessageId: true
|
|
4908
|
-
enableThinkingTagParsing: false
|
|
4909
|
-
// 🔒 默认禁用
|
|
4881
|
+
generateUniqueMessageId: true
|
|
4910
4882
|
};
|
|
4911
4883
|
function generateMessageId() {
|
|
4912
4884
|
return `msg_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;
|
|
@@ -5324,6 +5296,17 @@ var O2ASSEAdapter = class {
|
|
|
5324
5296
|
}
|
|
5325
5297
|
try {
|
|
5326
5298
|
const data = JSON.parse(dataContent);
|
|
5299
|
+
if ((data.choices?.length === 0 || !data.choices) && data.prompt_filter_results) {
|
|
5300
|
+
if (this.debugMode) {
|
|
5301
|
+
console.warn("\u26A0\uFE0F [O2ASSEAdapter] \u68C0\u6D4B\u5230Azure\u5185\u5BB9\u8FC7\u6EE4\u5668\u54CD\u5E94:", data.prompt_filter_results);
|
|
5302
|
+
}
|
|
5303
|
+
StreamingStateManager.processTextContent(
|
|
5304
|
+
`\u9519\u8BEF\uFF1A\u5185\u5BB9\u8FC7\u6EE4\u5668\u62E6\u622A\u4E86\u8BF7\u6C42\u3002\u8BF7\u68C0\u67E5\u8F93\u5165\u5185\u5BB9\u662F\u5426\u7B26\u5408\u4F7F\u7528\u653F\u7B56\u3002`,
|
|
5305
|
+
state,
|
|
5306
|
+
sseLines
|
|
5307
|
+
);
|
|
5308
|
+
break;
|
|
5309
|
+
}
|
|
5327
5310
|
const choice = data.choices?.[0];
|
|
5328
5311
|
const delta = choice?.delta;
|
|
5329
5312
|
if (!delta) {
|
|
@@ -5335,11 +5318,8 @@ var O2ASSEAdapter = class {
|
|
|
5335
5318
|
}
|
|
5336
5319
|
continue;
|
|
5337
5320
|
}
|
|
5338
|
-
if (delta.reasoning_content) {
|
|
5339
|
-
StreamingStateManager.processReasoningContent(delta.reasoning_content, state, sseLines);
|
|
5340
|
-
}
|
|
5341
5321
|
if (delta.content) {
|
|
5342
|
-
StreamingStateManager.processTextContent(delta.content, state, sseLines
|
|
5322
|
+
StreamingStateManager.processTextContent(delta.content, state, sseLines);
|
|
5343
5323
|
}
|
|
5344
5324
|
if (delta.tool_calls) {
|
|
5345
5325
|
ToolCallProcessor.processBatchToolCalls(delta.tool_calls, state, sseLines);
|
|
@@ -5370,6 +5350,19 @@ var O2ASSEAdapter = class {
|
|
|
5370
5350
|
processNonStreamingResponse(data, state, sseLines) {
|
|
5371
5351
|
const choice = data.choices?.[0];
|
|
5372
5352
|
if (!choice) {
|
|
5353
|
+
if (data.prompt_filter_results || data.choices?.length === 0) {
|
|
5354
|
+
const errorMsg = "Azure\u5185\u5BB9\u8FC7\u6EE4\u5668\u62E6\u622A\u4E86\u8BF7\u6C42";
|
|
5355
|
+
const filterDetails = data.prompt_filter_results ? JSON.stringify(data.prompt_filter_results).substring(0, 500) : "choices\u4E3A\u7A7A";
|
|
5356
|
+
if (this.debugMode) {
|
|
5357
|
+
console.warn(`\u26A0\uFE0F [O2ASSEAdapter] ${errorMsg}:`, filterDetails);
|
|
5358
|
+
}
|
|
5359
|
+
StreamingStateManager.processTextContent(
|
|
5360
|
+
`\u9519\u8BEF\uFF1A\u5185\u5BB9\u8FC7\u6EE4\u5668\u62E6\u622A\u4E86\u8BF7\u6C42\u3002\u8BF7\u68C0\u67E5\u8F93\u5165\u5185\u5BB9\u662F\u5426\u7B26\u5408\u4F7F\u7528\u653F\u7B56\u3002`,
|
|
5361
|
+
state,
|
|
5362
|
+
sseLines
|
|
5363
|
+
);
|
|
5364
|
+
return;
|
|
5365
|
+
}
|
|
5373
5366
|
if (this.debugMode) {
|
|
5374
5367
|
console.warn("\u26A0\uFE0F [O2ASSEAdapter] \u975E\u6D41\u5F0F\u54CD\u5E94\u6CA1\u6709choices\u6570\u636E");
|
|
5375
5368
|
}
|
|
@@ -5383,7 +5376,7 @@ var O2ASSEAdapter = class {
|
|
|
5383
5376
|
}
|
|
5384
5377
|
const message = choice.message;
|
|
5385
5378
|
if (message?.content) {
|
|
5386
|
-
StreamingStateManager.processTextContent(message.content, state, sseLines
|
|
5379
|
+
StreamingStateManager.processTextContent(message.content, state, sseLines);
|
|
5387
5380
|
if (this.debugMode) {
|
|
5388
5381
|
console.log("\u{1F50D} [O2ASSEAdapter] \u975E\u6D41\u5F0F\u54CD\u5E94content:", message.content);
|
|
5389
5382
|
}
|
|
@@ -5699,7 +5692,6 @@ var StandardProtocolAdapter = class {
|
|
|
5699
5692
|
}
|
|
5700
5693
|
};
|
|
5701
5694
|
let currentTextContent = "";
|
|
5702
|
-
let currentThinkingContent = "";
|
|
5703
5695
|
const toolCalls = /* @__PURE__ */ new Map();
|
|
5704
5696
|
const toolInputBuffers = /* @__PURE__ */ new Map();
|
|
5705
5697
|
const indexToToolId = /* @__PURE__ */ new Map();
|
|
@@ -5739,12 +5731,6 @@ var StandardProtocolAdapter = class {
|
|
|
5739
5731
|
this.logDebug(`\u{1F4DD} [StandardProtocolAdapter] \u7D2F\u79EF\u6587\u672C\u5185\u5BB9 (${currentTextContent.length}\u5B57\u7B26)`, currentTextContent.substring(currentTextContent.length - 20));
|
|
5740
5732
|
}
|
|
5741
5733
|
}
|
|
5742
|
-
if (data.type === "content_block_delta" && data.delta?.type === "thinking_delta") {
|
|
5743
|
-
currentThinkingContent += data.delta.thinking;
|
|
5744
|
-
if (this.debugMode && currentThinkingContent.length % 50 === 0) {
|
|
5745
|
-
this.logDebug(`\u{1F4AD} [StandardProtocolAdapter] \u7D2F\u79EFthinking\u5185\u5BB9 (${currentThinkingContent.length}\u5B57\u7B26)`, currentThinkingContent.substring(currentThinkingContent.length - 20));
|
|
5746
|
-
}
|
|
5747
|
-
}
|
|
5748
5734
|
if (data.type === "content_block_delta" && data.delta?.type === "input_json_delta") {
|
|
5749
5735
|
const toolIndex = data.index;
|
|
5750
5736
|
const toolId = indexToToolId.get(toolIndex);
|
|
@@ -5809,17 +5795,6 @@ var StandardProtocolAdapter = class {
|
|
|
5809
5795
|
}
|
|
5810
5796
|
}
|
|
5811
5797
|
}
|
|
5812
|
-
if (currentThinkingContent.trim()) {
|
|
5813
|
-
response.content.push({
|
|
5814
|
-
type: "text",
|
|
5815
|
-
text: currentThinkingContent.trim()
|
|
5816
|
-
});
|
|
5817
|
-
if (this.debugMode) {
|
|
5818
|
-
this.logDebug("\u{1F4AD} [StandardProtocolAdapter] \u6DFB\u52A0thinking\u5185\u5BB9:", {
|
|
5819
|
-
thinkingLength: currentThinkingContent.length
|
|
5820
|
-
});
|
|
5821
|
-
}
|
|
5822
|
-
}
|
|
5823
5798
|
if (currentTextContent.trim()) {
|
|
5824
5799
|
response.content.push({
|
|
5825
5800
|
type: "text",
|
|
@@ -5831,7 +5806,6 @@ var StandardProtocolAdapter = class {
|
|
|
5831
5806
|
this.logDebug("\u2705 [StandardProtocolAdapter] \u6807\u51C6\u54CD\u5E94\u6784\u5EFA\u5B8C\u6210:", {
|
|
5832
5807
|
contentCount: response.content.length,
|
|
5833
5808
|
textLength: currentTextContent.length,
|
|
5834
|
-
thinkingLength: currentThinkingContent.length,
|
|
5835
5809
|
toolCallsCount: toolCalls.size,
|
|
5836
5810
|
finalUsage: response.usage,
|
|
5837
5811
|
stopReason: response.stop_reason
|
package/dist/index.mjs
CHANGED
|
@@ -3406,13 +3406,6 @@ var A2ORequestAdapter = class {
|
|
|
3406
3406
|
convertOpenAIResponseToClaude(openaiResponse) {
|
|
3407
3407
|
const claudeContent = [];
|
|
3408
3408
|
const message = openaiResponse.choices?.[0]?.message;
|
|
3409
|
-
const messageAny = message;
|
|
3410
|
-
if (messageAny?.reasoning_content && typeof messageAny.reasoning_content === "string") {
|
|
3411
|
-
claudeContent.push({
|
|
3412
|
-
type: "text",
|
|
3413
|
-
text: messageAny.reasoning_content
|
|
3414
|
-
});
|
|
3415
|
-
}
|
|
3416
3409
|
if (message?.content) {
|
|
3417
3410
|
claudeContent.push({
|
|
3418
3411
|
type: "text",
|
|
@@ -3936,6 +3929,14 @@ var StreamingProtocolAdapter = class {
|
|
|
3936
3929
|
if (!content) return;
|
|
3937
3930
|
state.reasoningContent += content;
|
|
3938
3931
|
if (!state.thinkingBlockStarted) {
|
|
3932
|
+
if (state.contentBlockStarted) {
|
|
3933
|
+
sseLines.push(
|
|
3934
|
+
"event: content_block_stop",
|
|
3935
|
+
'data: {"type":"content_block_stop","index":0}',
|
|
3936
|
+
""
|
|
3937
|
+
);
|
|
3938
|
+
state.contentBlockStarted = false;
|
|
3939
|
+
}
|
|
3939
3940
|
sseLines.push(
|
|
3940
3941
|
"event: content_block_start",
|
|
3941
3942
|
'data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":"<thinking>"}}',
|
|
@@ -4680,36 +4681,9 @@ var StreamingStateManager = class {
|
|
|
4680
4681
|
};
|
|
4681
4682
|
}
|
|
4682
4683
|
/**
|
|
4683
|
-
*
|
|
4684
|
-
*/
|
|
4685
|
-
static processTextContent(content, state, sseLines
|
|
4686
|
-
if (enableThinkingTagParsing) {
|
|
4687
|
-
const thinkingTagPattern = /<thinking>([\s\S]*?)(<\/thinking>|$)/i;
|
|
4688
|
-
const match = content.match(thinkingTagPattern);
|
|
4689
|
-
if (match) {
|
|
4690
|
-
const beforeThinking = content.substring(0, match.index);
|
|
4691
|
-
const thinkingContent = match[1];
|
|
4692
|
-
const afterThinking = match[2] === "</thinking>" ? content.substring(match.index + match[0].length) : "";
|
|
4693
|
-
if (beforeThinking.trim()) {
|
|
4694
|
-
if (!state.hasContent) {
|
|
4695
|
-
sseLines.push(...SSEEventGenerator.generateTextBlockStart(state.contentBlockIndex));
|
|
4696
|
-
state.hasContent = true;
|
|
4697
|
-
}
|
|
4698
|
-
sseLines.push(...SSEEventGenerator.generateTextDelta(state.contentBlockIndex, beforeThinking));
|
|
4699
|
-
}
|
|
4700
|
-
if (thinkingContent.trim()) {
|
|
4701
|
-
this.processReasoningContent(thinkingContent, state, sseLines);
|
|
4702
|
-
}
|
|
4703
|
-
if (afterThinking.trim()) {
|
|
4704
|
-
if (!state.hasContent) {
|
|
4705
|
-
sseLines.push(...SSEEventGenerator.generateTextBlockStart(state.contentBlockIndex));
|
|
4706
|
-
state.hasContent = true;
|
|
4707
|
-
}
|
|
4708
|
-
sseLines.push(...SSEEventGenerator.generateTextDelta(state.contentBlockIndex, afterThinking));
|
|
4709
|
-
}
|
|
4710
|
-
return;
|
|
4711
|
-
}
|
|
4712
|
-
}
|
|
4684
|
+
* 处理文本内容
|
|
4685
|
+
*/
|
|
4686
|
+
static processTextContent(content, state, sseLines) {
|
|
4713
4687
|
if (!state.hasContent) {
|
|
4714
4688
|
sseLines.push(...SSEEventGenerator.generateTextBlockStart(state.contentBlockIndex));
|
|
4715
4689
|
state.hasContent = true;
|
|
@@ -4797,9 +4771,7 @@ var DEFAULT_CONFIG2 = {
|
|
|
4797
4771
|
errorDataMaxLength: 100,
|
|
4798
4772
|
warningDataMaxLength: 50,
|
|
4799
4773
|
defaultRole: "assistant",
|
|
4800
|
-
generateUniqueMessageId: true
|
|
4801
|
-
enableThinkingTagParsing: false
|
|
4802
|
-
// 🔒 默认禁用
|
|
4774
|
+
generateUniqueMessageId: true
|
|
4803
4775
|
};
|
|
4804
4776
|
function generateMessageId() {
|
|
4805
4777
|
return `msg_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;
|
|
@@ -5217,6 +5189,17 @@ var O2ASSEAdapter = class {
|
|
|
5217
5189
|
}
|
|
5218
5190
|
try {
|
|
5219
5191
|
const data = JSON.parse(dataContent);
|
|
5192
|
+
if ((data.choices?.length === 0 || !data.choices) && data.prompt_filter_results) {
|
|
5193
|
+
if (this.debugMode) {
|
|
5194
|
+
console.warn("\u26A0\uFE0F [O2ASSEAdapter] \u68C0\u6D4B\u5230Azure\u5185\u5BB9\u8FC7\u6EE4\u5668\u54CD\u5E94:", data.prompt_filter_results);
|
|
5195
|
+
}
|
|
5196
|
+
StreamingStateManager.processTextContent(
|
|
5197
|
+
`\u9519\u8BEF\uFF1A\u5185\u5BB9\u8FC7\u6EE4\u5668\u62E6\u622A\u4E86\u8BF7\u6C42\u3002\u8BF7\u68C0\u67E5\u8F93\u5165\u5185\u5BB9\u662F\u5426\u7B26\u5408\u4F7F\u7528\u653F\u7B56\u3002`,
|
|
5198
|
+
state,
|
|
5199
|
+
sseLines
|
|
5200
|
+
);
|
|
5201
|
+
break;
|
|
5202
|
+
}
|
|
5220
5203
|
const choice = data.choices?.[0];
|
|
5221
5204
|
const delta = choice?.delta;
|
|
5222
5205
|
if (!delta) {
|
|
@@ -5228,11 +5211,8 @@ var O2ASSEAdapter = class {
|
|
|
5228
5211
|
}
|
|
5229
5212
|
continue;
|
|
5230
5213
|
}
|
|
5231
|
-
if (delta.reasoning_content) {
|
|
5232
|
-
StreamingStateManager.processReasoningContent(delta.reasoning_content, state, sseLines);
|
|
5233
|
-
}
|
|
5234
5214
|
if (delta.content) {
|
|
5235
|
-
StreamingStateManager.processTextContent(delta.content, state, sseLines
|
|
5215
|
+
StreamingStateManager.processTextContent(delta.content, state, sseLines);
|
|
5236
5216
|
}
|
|
5237
5217
|
if (delta.tool_calls) {
|
|
5238
5218
|
ToolCallProcessor.processBatchToolCalls(delta.tool_calls, state, sseLines);
|
|
@@ -5263,6 +5243,19 @@ var O2ASSEAdapter = class {
|
|
|
5263
5243
|
processNonStreamingResponse(data, state, sseLines) {
|
|
5264
5244
|
const choice = data.choices?.[0];
|
|
5265
5245
|
if (!choice) {
|
|
5246
|
+
if (data.prompt_filter_results || data.choices?.length === 0) {
|
|
5247
|
+
const errorMsg = "Azure\u5185\u5BB9\u8FC7\u6EE4\u5668\u62E6\u622A\u4E86\u8BF7\u6C42";
|
|
5248
|
+
const filterDetails = data.prompt_filter_results ? JSON.stringify(data.prompt_filter_results).substring(0, 500) : "choices\u4E3A\u7A7A";
|
|
5249
|
+
if (this.debugMode) {
|
|
5250
|
+
console.warn(`\u26A0\uFE0F [O2ASSEAdapter] ${errorMsg}:`, filterDetails);
|
|
5251
|
+
}
|
|
5252
|
+
StreamingStateManager.processTextContent(
|
|
5253
|
+
`\u9519\u8BEF\uFF1A\u5185\u5BB9\u8FC7\u6EE4\u5668\u62E6\u622A\u4E86\u8BF7\u6C42\u3002\u8BF7\u68C0\u67E5\u8F93\u5165\u5185\u5BB9\u662F\u5426\u7B26\u5408\u4F7F\u7528\u653F\u7B56\u3002`,
|
|
5254
|
+
state,
|
|
5255
|
+
sseLines
|
|
5256
|
+
);
|
|
5257
|
+
return;
|
|
5258
|
+
}
|
|
5266
5259
|
if (this.debugMode) {
|
|
5267
5260
|
console.warn("\u26A0\uFE0F [O2ASSEAdapter] \u975E\u6D41\u5F0F\u54CD\u5E94\u6CA1\u6709choices\u6570\u636E");
|
|
5268
5261
|
}
|
|
@@ -5276,7 +5269,7 @@ var O2ASSEAdapter = class {
|
|
|
5276
5269
|
}
|
|
5277
5270
|
const message = choice.message;
|
|
5278
5271
|
if (message?.content) {
|
|
5279
|
-
StreamingStateManager.processTextContent(message.content, state, sseLines
|
|
5272
|
+
StreamingStateManager.processTextContent(message.content, state, sseLines);
|
|
5280
5273
|
if (this.debugMode) {
|
|
5281
5274
|
console.log("\u{1F50D} [O2ASSEAdapter] \u975E\u6D41\u5F0F\u54CD\u5E94content:", message.content);
|
|
5282
5275
|
}
|
|
@@ -5592,7 +5585,6 @@ var StandardProtocolAdapter = class {
|
|
|
5592
5585
|
}
|
|
5593
5586
|
};
|
|
5594
5587
|
let currentTextContent = "";
|
|
5595
|
-
let currentThinkingContent = "";
|
|
5596
5588
|
const toolCalls = /* @__PURE__ */ new Map();
|
|
5597
5589
|
const toolInputBuffers = /* @__PURE__ */ new Map();
|
|
5598
5590
|
const indexToToolId = /* @__PURE__ */ new Map();
|
|
@@ -5632,12 +5624,6 @@ var StandardProtocolAdapter = class {
|
|
|
5632
5624
|
this.logDebug(`\u{1F4DD} [StandardProtocolAdapter] \u7D2F\u79EF\u6587\u672C\u5185\u5BB9 (${currentTextContent.length}\u5B57\u7B26)`, currentTextContent.substring(currentTextContent.length - 20));
|
|
5633
5625
|
}
|
|
5634
5626
|
}
|
|
5635
|
-
if (data.type === "content_block_delta" && data.delta?.type === "thinking_delta") {
|
|
5636
|
-
currentThinkingContent += data.delta.thinking;
|
|
5637
|
-
if (this.debugMode && currentThinkingContent.length % 50 === 0) {
|
|
5638
|
-
this.logDebug(`\u{1F4AD} [StandardProtocolAdapter] \u7D2F\u79EFthinking\u5185\u5BB9 (${currentThinkingContent.length}\u5B57\u7B26)`, currentThinkingContent.substring(currentThinkingContent.length - 20));
|
|
5639
|
-
}
|
|
5640
|
-
}
|
|
5641
5627
|
if (data.type === "content_block_delta" && data.delta?.type === "input_json_delta") {
|
|
5642
5628
|
const toolIndex = data.index;
|
|
5643
5629
|
const toolId = indexToToolId.get(toolIndex);
|
|
@@ -5702,17 +5688,6 @@ var StandardProtocolAdapter = class {
|
|
|
5702
5688
|
}
|
|
5703
5689
|
}
|
|
5704
5690
|
}
|
|
5705
|
-
if (currentThinkingContent.trim()) {
|
|
5706
|
-
response.content.push({
|
|
5707
|
-
type: "text",
|
|
5708
|
-
text: currentThinkingContent.trim()
|
|
5709
|
-
});
|
|
5710
|
-
if (this.debugMode) {
|
|
5711
|
-
this.logDebug("\u{1F4AD} [StandardProtocolAdapter] \u6DFB\u52A0thinking\u5185\u5BB9:", {
|
|
5712
|
-
thinkingLength: currentThinkingContent.length
|
|
5713
|
-
});
|
|
5714
|
-
}
|
|
5715
|
-
}
|
|
5716
5691
|
if (currentTextContent.trim()) {
|
|
5717
5692
|
response.content.push({
|
|
5718
5693
|
type: "text",
|
|
@@ -5724,7 +5699,6 @@ var StandardProtocolAdapter = class {
|
|
|
5724
5699
|
this.logDebug("\u2705 [StandardProtocolAdapter] \u6807\u51C6\u54CD\u5E94\u6784\u5EFA\u5B8C\u6210:", {
|
|
5725
5700
|
contentCount: response.content.length,
|
|
5726
5701
|
textLength: currentTextContent.length,
|
|
5727
|
-
thinkingLength: currentThinkingContent.length,
|
|
5728
5702
|
toolCallsCount: toolCalls.size,
|
|
5729
5703
|
finalUsage: response.usage,
|
|
5730
5704
|
stopReason: response.stop_reason
|
package/package.json
CHANGED