ai 2.2.34 → 2.2.36

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
@@ -681,6 +681,44 @@ function HuggingFaceStream(res, callbacks) {
681
681
  );
682
682
  }
683
683
 
684
+ // streams/inkeep-stream.ts
685
+ function InkeepStream(res, callbacks) {
686
+ if (!res.body) {
687
+ throw new Error("Response body is null");
688
+ }
689
+ let chat_session_id = "";
690
+ let records_cited;
691
+ const inkeepEventParser = (data, options) => {
692
+ var _a, _b;
693
+ const { event } = options;
694
+ if (event === "records_cited") {
695
+ records_cited = JSON.parse(data);
696
+ (_a = callbacks == null ? void 0 : callbacks.onRecordsCited) == null ? void 0 : _a.call(callbacks, records_cited);
697
+ }
698
+ if (event === "message_chunk") {
699
+ const inkeepMessageChunk = JSON.parse(data);
700
+ chat_session_id = (_b = inkeepMessageChunk.chat_session_id) != null ? _b : chat_session_id;
701
+ return inkeepMessageChunk.content_chunk;
702
+ }
703
+ return;
704
+ };
705
+ let { onRecordsCited, ...passThroughCallbacks } = callbacks || {};
706
+ passThroughCallbacks = {
707
+ ...passThroughCallbacks,
708
+ onFinal: (completion) => {
709
+ var _a;
710
+ const inkeepOnFinalMetadata = {
711
+ chat_session_id,
712
+ records_cited
713
+ };
714
+ (_a = callbacks == null ? void 0 : callbacks.onFinal) == null ? void 0 : _a.call(callbacks, completion, inkeepOnFinalMetadata);
715
+ }
716
+ };
717
+ return AIStream(res, inkeepEventParser, passThroughCallbacks).pipeThrough(
718
+ createStreamDataTransformer(passThroughCallbacks == null ? void 0 : passThroughCallbacks.experimental_streamData)
719
+ );
720
+ }
721
+
684
722
  // streams/langchain-stream.ts
685
723
  function LangChainStream(callbacks) {
686
724
  const stream = new TransformStream();
@@ -1012,6 +1050,7 @@ function createFunctionCallTransformer(callbacks) {
1012
1050
  controller.enqueue(
1013
1051
  isComplexMode ? textEncoder.encode(formatStreamPart("text", functionResponse)) : textEncoder.encode(functionResponse)
1014
1052
  );
1053
+ aggregatedFinalCompletionResponse = functionResponse;
1015
1054
  return;
1016
1055
  }
1017
1056
  const filteredCallbacks = {
@@ -1339,6 +1378,7 @@ export {
1339
1378
  CohereStream,
1340
1379
  GoogleGenerativeAIStream,
1341
1380
  HuggingFaceStream,
1381
+ InkeepStream,
1342
1382
  LangChainStream,
1343
1383
  OpenAIStream,
1344
1384
  ReplicateStream,