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