@myassis/gateway 1.0.60 → 1.0.61
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.
|
@@ -525,6 +525,9 @@ class LLMClient {
|
|
|
525
525
|
// 系统模式 /api/v1/llm/invoke 返回格式
|
|
526
526
|
if (data.success === true && data.data) {
|
|
527
527
|
const d = data.data;
|
|
528
|
+
if (d.finish_reason === 'length' && !d.content) {
|
|
529
|
+
throw Error('exceed max message tokens');
|
|
530
|
+
}
|
|
528
531
|
const toolCalls = d.toolCalls?.map((tc) => ({
|
|
529
532
|
id: tc.id || '',
|
|
530
533
|
toolName: tc.function?.name || '',
|
|
@@ -537,18 +540,12 @@ class LLMClient {
|
|
|
537
540
|
modelName: data.quota?.modelName || modelName,
|
|
538
541
|
};
|
|
539
542
|
}
|
|
540
|
-
// Coze 格式
|
|
541
|
-
if (data.type === 'conversation_message.completed' || data.message) {
|
|
542
|
-
const messageData = data.message || {};
|
|
543
|
-
return {
|
|
544
|
-
content: messageData.content?.[0]?.text || '',
|
|
545
|
-
reasoningContent: messageData.thinking || undefined,
|
|
546
|
-
modelName
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
543
|
// OpenAI/DeepSeek 格式
|
|
550
544
|
if (data.choices?.[0]?.message) {
|
|
551
545
|
const messageData = data.choices[0].message;
|
|
546
|
+
if (messageData.finish_reason === 'length' && !messageData.content) {
|
|
547
|
+
throw Error('exceed max message tokens');
|
|
548
|
+
}
|
|
552
549
|
return {
|
|
553
550
|
content: messageData.content || '',
|
|
554
551
|
reasoningContent: messageData.reasoning_content || undefined,
|
|
@@ -561,34 +558,6 @@ class LLMClient {
|
|
|
561
558
|
modelName
|
|
562
559
|
};
|
|
563
560
|
}
|
|
564
|
-
// Claude 格式
|
|
565
|
-
if (data.content) {
|
|
566
|
-
const toolCalls = [];
|
|
567
|
-
let content = '';
|
|
568
|
-
let reasoningContent = '';
|
|
569
|
-
for (const block of data.content) {
|
|
570
|
-
if (block.type === 'text') {
|
|
571
|
-
content += block.text;
|
|
572
|
-
}
|
|
573
|
-
else if (block.type === 'thinking') {
|
|
574
|
-
reasoningContent += block.thinking;
|
|
575
|
-
}
|
|
576
|
-
else if (block.type === 'tool_use') {
|
|
577
|
-
toolCalls.push({
|
|
578
|
-
id: block.id,
|
|
579
|
-
toolName: block.name,
|
|
580
|
-
input: typeof block.input === 'string' ? block.input : JSON.stringify(block.input),
|
|
581
|
-
actionName: this.getActionName(typeof block.input === 'string' ? block.input : JSON.stringify(block.input))
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
return {
|
|
586
|
-
content,
|
|
587
|
-
reasoningContent: reasoningContent || undefined,
|
|
588
|
-
toolCalls: toolCalls.length > 0 ? toolCalls : undefined,
|
|
589
|
-
modelName
|
|
590
|
-
};
|
|
591
|
-
}
|
|
592
561
|
return { content: '', modelName };
|
|
593
562
|
}
|
|
594
563
|
/**
|