@codeproxy/core 0.1.7 → 0.1.9
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.cjs +13 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1592,6 +1592,15 @@ async function* translateStream2(stream, options = {}) {
|
|
|
1592
1592
|
function isDoneMessage(msg) {
|
|
1593
1593
|
return msg.data.trim() === "[DONE]";
|
|
1594
1594
|
}
|
|
1595
|
+
function getToolCallKey(tc, ordinal) {
|
|
1596
|
+
if (typeof tc.index === "number") {
|
|
1597
|
+
return `index:${tc.index}`;
|
|
1598
|
+
}
|
|
1599
|
+
if (tc.id) {
|
|
1600
|
+
return `id:${tc.id}`;
|
|
1601
|
+
}
|
|
1602
|
+
return `ordinal:${ordinal}`;
|
|
1603
|
+
}
|
|
1595
1604
|
var StreamTranslator2 = class {
|
|
1596
1605
|
constructor(options) {
|
|
1597
1606
|
__publicField(this, "model");
|
|
@@ -1650,9 +1659,9 @@ var StreamTranslator2 = class {
|
|
|
1650
1659
|
return;
|
|
1651
1660
|
}
|
|
1652
1661
|
if (delta.tool_calls?.length) {
|
|
1653
|
-
for (const tc of delta.tool_calls) {
|
|
1654
|
-
const
|
|
1655
|
-
let state = this.toolCalls.get(
|
|
1662
|
+
for (const [ordinal, tc] of delta.tool_calls.entries()) {
|
|
1663
|
+
const key = getToolCallKey(tc, ordinal);
|
|
1664
|
+
let state = this.toolCalls.get(key);
|
|
1656
1665
|
if (!state) {
|
|
1657
1666
|
const outputIndex = this.outputCounter++;
|
|
1658
1667
|
const callId = tc.id ?? makeId("call");
|
|
@@ -1665,7 +1674,7 @@ var StreamTranslator2 = class {
|
|
|
1665
1674
|
call_id: callId
|
|
1666
1675
|
};
|
|
1667
1676
|
state = { outputIndex, item };
|
|
1668
|
-
this.toolCalls.set(
|
|
1677
|
+
this.toolCalls.set(key, state);
|
|
1669
1678
|
yield this.makeEvent("response.output_item.added", {
|
|
1670
1679
|
response_id: this.responseId,
|
|
1671
1680
|
output_index: outputIndex,
|