@alpic80/rivet-ai-sdk-provider 2.0.2 → 2.0.3

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.mjs CHANGED
@@ -1076,7 +1076,7 @@ prepare tools input:${printObject(tools)}`);
1076
1076
  }
1077
1077
 
1078
1078
  // src/version.ts
1079
- var VERSION = true ? "2.0.2" : "0.0.0-test";
1079
+ var VERSION = true ? "2.0.3" : "0.0.0-test";
1080
1080
 
1081
1081
  // src/post-to-api.ts
1082
1082
  var getOriginalFetch = () => globalThis.fetch;
@@ -1728,7 +1728,7 @@ function createRivetEventSourceResponseHandler(id, model) {
1728
1728
  }));
1729
1729
  }
1730
1730
  function mapRivetEventToOpenAIChunk(eventData, id, model) {
1731
- var _a15, _b, _c, _d, _e, _f, _g, _h;
1731
+ var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1732
1732
  const eventType = eventData.type;
1733
1733
  switch (eventType) {
1734
1734
  case "partialOutput":
@@ -1750,6 +1750,8 @@ function mapRivetEventToOpenAIChunk(eventData, id, model) {
1750
1750
  usage: void 0
1751
1751
  };
1752
1752
  case "nodeFinish":
1753
+ const rawContent = (_g = (_f = (_c = (_b = eventData.outputs) == null ? void 0 : _b.response) == null ? void 0 : _c.value) != null ? _f : (_e = (_d = eventData.outputs) == null ? void 0 : _d.valueOutput) == null ? void 0 : _e.value) != null ? _g : void 0;
1754
+ const delta = typeof rawContent === "string" ? rawContent : rawContent !== void 0 ? JSON.stringify(rawContent) : void 0;
1753
1755
  return {
1754
1756
  id,
1755
1757
  created: Math.floor(Date.now() / 1e3),
@@ -1758,14 +1760,14 @@ function mapRivetEventToOpenAIChunk(eventData, id, model) {
1758
1760
  {
1759
1761
  delta: {
1760
1762
  role: "assistant",
1761
- content: (_b = eventData.delta) != null ? _b : "",
1763
+ content: delta != null ? delta : "",
1762
1764
  tool_calls: void 0
1763
1765
  },
1764
1766
  finish_reason: null,
1765
1767
  index: 0
1766
1768
  }
1767
1769
  ],
1768
- usage: void 0
1770
+ usage: toOpenAIUsage((_k = (_j = (_i = (_h = eventData == null ? void 0 : eventData.output) == null ? void 0 : _h.usages) == null ? void 0 : _i.value) == null ? void 0 : _j[0]) == null ? void 0 : _k.value)
1769
1771
  };
1770
1772
  case "done":
1771
1773
  return {
@@ -1776,16 +1778,17 @@ function mapRivetEventToOpenAIChunk(eventData, id, model) {
1776
1778
  {
1777
1779
  delta: {
1778
1780
  role: "assistant",
1779
- content: (_e = (_d = (_c = eventData.graphOutput) == null ? void 0 : _c.response) == null ? void 0 : _d.value) != null ? _e : "",
1781
+ content: (_n = (_m = (_l = eventData.graphOutput) == null ? void 0 : _l.response) == null ? void 0 : _m.value) != null ? _n : "",
1780
1782
  tool_calls: void 0
1781
1783
  },
1782
1784
  finish_reason: "stop",
1783
1785
  index: 0
1784
1786
  }
1785
1787
  ],
1786
- usage: toOpenAIUsage((_h = (_g = (_f = eventData.graphOutput.usages) == null ? void 0 : _f.value) == null ? void 0 : _g[0]) == null ? void 0 : _h.value)
1788
+ usage: toOpenAIUsage((_q = (_p = (_o = eventData.graphOutput.usages) == null ? void 0 : _o.value) == null ? void 0 : _p[0]) == null ? void 0 : _q.value)
1787
1789
  };
1788
1790
  default:
1791
+ console.log(`failling on default for type:${printObject(eventType)}`);
1789
1792
  return {
1790
1793
  id,
1791
1794
  created: Math.floor(Date.now() / 1e3),