open-agents-ai 0.187.520 → 0.187.521
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.js +91 -4
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -539,6 +539,89 @@ var init_normalizeUrl = __esm({
|
|
|
539
539
|
}
|
|
540
540
|
});
|
|
541
541
|
|
|
542
|
+
// packages/backend-vllm/dist/messageNormalize.js
|
|
543
|
+
function normalizeMessagesForStrictOpenAI(messages2, stats) {
|
|
544
|
+
if (stats) {
|
|
545
|
+
stats.inputSystemCount = 0;
|
|
546
|
+
stats.mergedLeading = 0;
|
|
547
|
+
stats.convertedToUser = 0;
|
|
548
|
+
stats.changed = false;
|
|
549
|
+
}
|
|
550
|
+
if (!Array.isArray(messages2) || messages2.length === 0)
|
|
551
|
+
return [];
|
|
552
|
+
const leading = [];
|
|
553
|
+
let i2 = 0;
|
|
554
|
+
while (i2 < messages2.length && messages2[i2].role === "system") {
|
|
555
|
+
leading.push(messages2[i2]);
|
|
556
|
+
i2++;
|
|
557
|
+
}
|
|
558
|
+
if (stats) {
|
|
559
|
+
stats.inputSystemCount += leading.length;
|
|
560
|
+
stats.mergedLeading = leading.length;
|
|
561
|
+
}
|
|
562
|
+
const out = [];
|
|
563
|
+
if (leading.length > 0) {
|
|
564
|
+
if (leading.length === 1) {
|
|
565
|
+
out.push(leading[0]);
|
|
566
|
+
} else {
|
|
567
|
+
const allStrings = leading.every((m2) => typeof m2.content === "string");
|
|
568
|
+
if (allStrings) {
|
|
569
|
+
const merged = leading.map((m2) => m2.content ?? "").filter((s2) => s2.length > 0).join(SYSTEM_MERGE_SEP);
|
|
570
|
+
out.push({ ...leading[0], content: merged });
|
|
571
|
+
} else {
|
|
572
|
+
out.push(leading[0]);
|
|
573
|
+
for (let k = 1; k < leading.length; k++) {
|
|
574
|
+
const c9 = leading[k].content;
|
|
575
|
+
const cs = typeof c9 === "string" ? c9 : "";
|
|
576
|
+
if (cs.length > 0) {
|
|
577
|
+
out.push({ ...leading[k], role: "user", content: `${SYSTEM_AS_USER_PREFIX}${cs}` });
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
if (stats)
|
|
582
|
+
stats.changed = true;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
for (; i2 < messages2.length; i2++) {
|
|
586
|
+
const m2 = messages2[i2];
|
|
587
|
+
if (m2.role === "system") {
|
|
588
|
+
if (stats) {
|
|
589
|
+
stats.inputSystemCount += 1;
|
|
590
|
+
stats.convertedToUser += 1;
|
|
591
|
+
stats.changed = true;
|
|
592
|
+
}
|
|
593
|
+
const c9 = m2.content;
|
|
594
|
+
const cs = typeof c9 === "string" ? c9 : "";
|
|
595
|
+
if (cs.length > 0) {
|
|
596
|
+
out.push({ ...m2, role: "user", content: `${SYSTEM_AS_USER_PREFIX}${cs}` });
|
|
597
|
+
}
|
|
598
|
+
} else {
|
|
599
|
+
out.push(m2);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
if (stats && !stats.changed) {
|
|
603
|
+
if (out.length !== messages2.length)
|
|
604
|
+
stats.changed = true;
|
|
605
|
+
else {
|
|
606
|
+
for (let k = 0; k < out.length; k++) {
|
|
607
|
+
if (out[k] !== messages2[k]) {
|
|
608
|
+
stats.changed = true;
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return out;
|
|
615
|
+
}
|
|
616
|
+
var SYSTEM_MERGE_SEP, SYSTEM_AS_USER_PREFIX;
|
|
617
|
+
var init_messageNormalize = __esm({
|
|
618
|
+
"packages/backend-vllm/dist/messageNormalize.js"() {
|
|
619
|
+
"use strict";
|
|
620
|
+
SYSTEM_MERGE_SEP = "\n\n---\n\n";
|
|
621
|
+
SYSTEM_AS_USER_PREFIX = "[SYSTEM]: ";
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
|
|
542
625
|
// packages/backend-vllm/dist/VllmBackend.js
|
|
543
626
|
function agentMessageToChatMessage(msg) {
|
|
544
627
|
return {
|
|
@@ -555,6 +638,7 @@ var init_VllmBackend = __esm({
|
|
|
555
638
|
"use strict";
|
|
556
639
|
init_sleep();
|
|
557
640
|
init_normalizeUrl();
|
|
641
|
+
init_messageNormalize();
|
|
558
642
|
VllmBackend = class {
|
|
559
643
|
baseUrl;
|
|
560
644
|
model;
|
|
@@ -594,7 +678,8 @@ var init_VllmBackend = __esm({
|
|
|
594
678
|
// LLMBackend — complete
|
|
595
679
|
// -------------------------------------------------------------------------
|
|
596
680
|
async complete(request) {
|
|
597
|
-
const
|
|
681
|
+
const rawMessages = request.messages.map(agentMessageToChatMessage);
|
|
682
|
+
const messages2 = normalizeMessagesForStrictOpenAI(rawMessages);
|
|
598
683
|
const body = {
|
|
599
684
|
model: this.model,
|
|
600
685
|
messages: messages2,
|
|
@@ -709,6 +794,7 @@ var init_OllamaBackend = __esm({
|
|
|
709
794
|
"packages/backend-vllm/dist/OllamaBackend.js"() {
|
|
710
795
|
"use strict";
|
|
711
796
|
init_normalizeUrl();
|
|
797
|
+
init_messageNormalize();
|
|
712
798
|
OllamaBackend = class _OllamaBackend {
|
|
713
799
|
baseUrl;
|
|
714
800
|
model;
|
|
@@ -744,7 +830,7 @@ var init_OllamaBackend = __esm({
|
|
|
744
830
|
// LLMBackend — complete
|
|
745
831
|
// -------------------------------------------------------------------------
|
|
746
832
|
async complete(request) {
|
|
747
|
-
const messages2 = request.messages.map(agentMessageToChatMessage2);
|
|
833
|
+
const messages2 = normalizeMessagesForStrictOpenAI(request.messages.map(agentMessageToChatMessage2));
|
|
748
834
|
const body = {
|
|
749
835
|
model: this.model,
|
|
750
836
|
messages: messages2,
|
|
@@ -1140,6 +1226,7 @@ var init_dist = __esm({
|
|
|
1140
1226
|
init_sleep();
|
|
1141
1227
|
init_routing();
|
|
1142
1228
|
init_normalizeUrl();
|
|
1229
|
+
init_messageNormalize();
|
|
1143
1230
|
}
|
|
1144
1231
|
});
|
|
1145
1232
|
|
|
@@ -535544,7 +535631,7 @@ ${description}`
|
|
|
535544
535631
|
if (this._isAnthropic) {
|
|
535545
535632
|
return this._anthropicChatCompletion(request);
|
|
535546
535633
|
}
|
|
535547
|
-
const cleanedMessages = sanitizeHistoryThink(request.messages);
|
|
535634
|
+
const cleanedMessages = normalizeMessagesForStrictOpenAI(sanitizeHistoryThink(request.messages));
|
|
535548
535635
|
const effectiveThink = computeEffectiveThink({
|
|
535549
535636
|
requestThink: request.think,
|
|
535550
535637
|
defaultThink: this.thinking,
|
|
@@ -535784,7 +535871,7 @@ ${description}`
|
|
|
535784
535871
|
* The existing chatCompletion() method is completely unmodified.
|
|
535785
535872
|
*/
|
|
535786
535873
|
async *chatCompletionStream(request) {
|
|
535787
|
-
const cleanedMessages = request.messages.map((m2) => m2.role === "assistant" && typeof m2.content === "string" ? { ...m2, content: stripThinkBlocks(m2.content) } : m2);
|
|
535874
|
+
const cleanedMessages = normalizeMessagesForStrictOpenAI(request.messages.map((m2) => m2.role === "assistant" && typeof m2.content === "string" ? { ...m2, content: stripThinkBlocks(m2.content) } : m2));
|
|
535788
535875
|
const effectiveThink = computeEffectiveThink({
|
|
535789
535876
|
requestThink: request.think,
|
|
535790
535877
|
defaultThink: this.thinking,
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-agents-ai",
|
|
3
|
-
"version": "0.187.
|
|
3
|
+
"version": "0.187.521",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "open-agents-ai",
|
|
9
|
-
"version": "0.187.
|
|
9
|
+
"version": "0.187.521",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "CC-BY-NC-4.0",
|
|
12
12
|
"dependencies": {
|
package/package.json
CHANGED