@copilotkit/runtime 1.4.0-pre-1-4-0.13 → 1.4.0-pre.16
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/CHANGELOG.md +32 -0
- package/dist/{chunk-AQBZWBJD.mjs → chunk-2MEJMEYX.mjs} +2 -2
- package/dist/{chunk-CBZV4PPM.mjs → chunk-5HOOAMQI.mjs} +2 -2
- package/dist/{chunk-P4EZLCB6.mjs → chunk-BNSMQJEH.mjs} +2 -2
- package/dist/{chunk-NKGWZWKJ.mjs → chunk-SQKHB55U.mjs} +33 -76
- package/dist/chunk-SQKHB55U.mjs.map +1 -0
- package/dist/{chunk-56IQ6PGC.mjs → chunk-ZOC3UIQP.mjs} +56 -213
- package/dist/chunk-ZOC3UIQP.mjs.map +1 -0
- package/dist/{copilot-runtime-d9ef5d8c.d.ts → copilot-runtime-335a610d.d.ts} +1 -1
- package/dist/{groq-adapter-192d2413.d.ts → groq-adapter-b6c2b7ec.d.ts} +6 -16
- package/dist/index.d.ts +3 -3
- package/dist/index.js +85 -285
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{langserve-878c62b9.d.ts → langserve-cc06e76e.d.ts} +9 -45
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.js +79 -264
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +5 -5
- package/dist/lib/integrations/index.d.ts +3 -3
- package/dist/lib/integrations/index.js +3 -11
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +5 -5
- package/dist/lib/integrations/nest/index.d.ts +2 -2
- package/dist/lib/integrations/nest/index.js +3 -11
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +3 -3
- package/dist/lib/integrations/node-express/index.d.ts +2 -2
- package/dist/lib/integrations/node-express/index.js +3 -11
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +3 -3
- package/dist/lib/integrations/node-http/index.d.ts +2 -2
- package/dist/lib/integrations/node-http/index.js +3 -11
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +2 -2
- package/dist/service-adapters/index.d.ts +4 -6
- package/dist/service-adapters/index.js +55 -212
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +1 -1
- package/package.json +4 -4
- package/src/agents/langgraph/event-source.ts +0 -12
- package/src/graphql/resolvers/copilot.resolver.ts +2 -28
- package/src/service-adapters/anthropic/anthropic-adapter.ts +7 -18
- package/src/service-adapters/events.ts +35 -73
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +3 -7
- package/src/service-adapters/google/google-genai-adapter.ts +1 -3
- package/src/service-adapters/groq/groq-adapter.ts +9 -25
- package/src/service-adapters/langchain/langchain-adapter.ts +1 -3
- package/src/service-adapters/langchain/utils.ts +31 -47
- package/src/service-adapters/openai/openai-adapter.ts +11 -27
- package/src/service-adapters/openai/openai-assistant-adapter.ts +9 -24
- package/src/service-adapters/unify/unify-adapter.ts +11 -28
- package/dist/chunk-56IQ6PGC.mjs.map +0 -1
- package/dist/chunk-NKGWZWKJ.mjs.map +0 -1
- /package/dist/{chunk-AQBZWBJD.mjs.map → chunk-2MEJMEYX.mjs.map} +0 -0
- /package/dist/{chunk-CBZV4PPM.mjs.map → chunk-5HOOAMQI.mjs.map} +0 -0
- /package/dist/{chunk-P4EZLCB6.mjs.map → chunk-BNSMQJEH.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
copilotRuntimeNodeHttpEndpoint
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-SQKHB55U.mjs";
|
|
4
|
+
import "../../../chunk-ZOC3UIQP.mjs";
|
|
5
5
|
import "../../../chunk-U3V2BCGI.mjs";
|
|
6
6
|
import "../../../chunk-B74M7FXG.mjs";
|
|
7
7
|
import "../../../chunk-D2WLFQS6.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as CopilotServiceAdapter, c as CopilotRuntimeChatCompletionRequest, d as CopilotRuntimeChatCompletionResponse } from '../langserve-
|
|
2
|
-
export { a as RemoteChain, R as RemoteChainParameters } from '../langserve-
|
|
3
|
-
export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-
|
|
1
|
+
import { C as CopilotServiceAdapter, c as CopilotRuntimeChatCompletionRequest, d as CopilotRuntimeChatCompletionResponse } from '../langserve-cc06e76e.js';
|
|
2
|
+
export { a as RemoteChain, R as RemoteChainParameters } from '../langserve-cc06e76e.js';
|
|
3
|
+
export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-b6c2b7ec.js';
|
|
4
4
|
import Anthropic from '@anthropic-ai/sdk';
|
|
5
5
|
import '../index-83ee522f.js';
|
|
6
6
|
import '../graphql/types/base/index.js';
|
|
@@ -27,9 +27,7 @@ import 'groq-sdk';
|
|
|
27
27
|
* apiKey: "<your-api-key>",
|
|
28
28
|
* });
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* return copilotKit.streamHttpServerResponse(req, res, serviceAdapter);
|
|
30
|
+
* return new AnthropicAdapter({ anthropic });
|
|
33
31
|
* ```
|
|
34
32
|
*/
|
|
35
33
|
|
|
@@ -315,8 +315,6 @@ var OpenAIAdapter = class {
|
|
|
315
315
|
eventSource.stream(async (eventStream$) => {
|
|
316
316
|
var _a, _b;
|
|
317
317
|
let mode = null;
|
|
318
|
-
let currentMessageId;
|
|
319
|
-
let currentToolCallId;
|
|
320
318
|
for await (const chunk of stream) {
|
|
321
319
|
if (chunk.choices.length === 0) {
|
|
322
320
|
continue;
|
|
@@ -325,51 +323,30 @@ var OpenAIAdapter = class {
|
|
|
325
323
|
const content = chunk.choices[0].delta.content;
|
|
326
324
|
if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
|
|
327
325
|
mode = null;
|
|
328
|
-
eventStream$.sendTextMessageEnd(
|
|
329
|
-
messageId: currentMessageId
|
|
330
|
-
});
|
|
326
|
+
eventStream$.sendTextMessageEnd();
|
|
331
327
|
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
332
328
|
mode = null;
|
|
333
|
-
eventStream$.sendActionExecutionEnd(
|
|
334
|
-
actionExecutionId: currentToolCallId
|
|
335
|
-
});
|
|
329
|
+
eventStream$.sendActionExecutionEnd();
|
|
336
330
|
}
|
|
337
331
|
if (mode === null) {
|
|
338
332
|
if (toolCall == null ? void 0 : toolCall.id) {
|
|
339
333
|
mode = "function";
|
|
340
|
-
|
|
341
|
-
eventStream$.sendActionExecutionStart({
|
|
342
|
-
actionExecutionId: currentToolCallId,
|
|
343
|
-
actionName: toolCall.function.name
|
|
344
|
-
});
|
|
334
|
+
eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
|
|
345
335
|
} else if (content) {
|
|
346
336
|
mode = "message";
|
|
347
|
-
|
|
348
|
-
eventStream$.sendTextMessageStart({
|
|
349
|
-
messageId: currentMessageId
|
|
350
|
-
});
|
|
337
|
+
eventStream$.sendTextMessageStart(chunk.id);
|
|
351
338
|
}
|
|
352
339
|
}
|
|
353
340
|
if (mode === "message" && content) {
|
|
354
|
-
eventStream$.sendTextMessageContent(
|
|
355
|
-
messageId: currentMessageId,
|
|
356
|
-
content
|
|
357
|
-
});
|
|
341
|
+
eventStream$.sendTextMessageContent(content);
|
|
358
342
|
} else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
|
|
359
|
-
eventStream$.sendActionExecutionArgs(
|
|
360
|
-
actionExecutionId: currentToolCallId,
|
|
361
|
-
args: toolCall.function.arguments
|
|
362
|
-
});
|
|
343
|
+
eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
|
|
363
344
|
}
|
|
364
345
|
}
|
|
365
346
|
if (mode === "message") {
|
|
366
|
-
eventStream$.sendTextMessageEnd(
|
|
367
|
-
messageId: currentMessageId
|
|
368
|
-
});
|
|
347
|
+
eventStream$.sendTextMessageEnd();
|
|
369
348
|
} else if (mode === "function") {
|
|
370
|
-
eventStream$.sendActionExecutionEnd(
|
|
371
|
-
actionExecutionId: currentToolCallId
|
|
372
|
-
});
|
|
349
|
+
eventStream$.sendActionExecutionEnd();
|
|
373
350
|
}
|
|
374
351
|
eventStream$.complete();
|
|
375
352
|
});
|
|
@@ -465,11 +442,7 @@ function isBaseMessageChunk(message) {
|
|
|
465
442
|
__name(isBaseMessageChunk, "isBaseMessageChunk");
|
|
466
443
|
function maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution) {
|
|
467
444
|
if (actionExecution) {
|
|
468
|
-
eventStream$.sendActionExecutionResult(
|
|
469
|
-
actionExecutionId: actionExecution.id,
|
|
470
|
-
actionName: actionExecution.name,
|
|
471
|
-
result: "Sending a message"
|
|
472
|
-
});
|
|
445
|
+
eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, "Sending a message");
|
|
473
446
|
}
|
|
474
447
|
}
|
|
475
448
|
__name(maybeSendActionExecutionResultIsMessage, "maybeSendActionExecutionResultIsMessage");
|
|
@@ -479,11 +452,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
479
452
|
if (!actionExecution) {
|
|
480
453
|
eventStream$.sendTextMessage((0, import_shared2.randomId)(), result);
|
|
481
454
|
} else {
|
|
482
|
-
eventStream$.sendActionExecutionResult(
|
|
483
|
-
actionExecutionId: actionExecution.id,
|
|
484
|
-
actionName: actionExecution.name,
|
|
485
|
-
result
|
|
486
|
-
});
|
|
455
|
+
eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, result);
|
|
487
456
|
}
|
|
488
457
|
} else if (isAIMessage(result)) {
|
|
489
458
|
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
@@ -491,11 +460,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
491
460
|
eventStream$.sendTextMessage((0, import_shared2.randomId)(), result.content);
|
|
492
461
|
}
|
|
493
462
|
for (const toolCall of result.tool_calls) {
|
|
494
|
-
eventStream$.sendActionExecution(
|
|
495
|
-
actionExecutionId: toolCall.id || (0, import_shared2.randomId)(),
|
|
496
|
-
actionName: toolCall.name,
|
|
497
|
-
args: JSON.stringify(toolCall.args)
|
|
498
|
-
});
|
|
463
|
+
eventStream$.sendActionExecution(toolCall.id || (0, import_shared2.randomId)(), toolCall.name, JSON.stringify(toolCall.args));
|
|
499
464
|
}
|
|
500
465
|
} else if (isBaseMessageChunk(result)) {
|
|
501
466
|
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
@@ -504,11 +469,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
504
469
|
}
|
|
505
470
|
if ((_b = result.lc_kwargs) == null ? void 0 : _b.tool_calls) {
|
|
506
471
|
for (const toolCall of (_c = result.lc_kwargs) == null ? void 0 : _c.tool_calls) {
|
|
507
|
-
eventStream$.sendActionExecution(
|
|
508
|
-
actionExecutionId: toolCall.id || (0, import_shared2.randomId)(),
|
|
509
|
-
actionName: toolCall.name,
|
|
510
|
-
args: JSON.stringify(toolCall.args)
|
|
511
|
-
});
|
|
472
|
+
eventStream$.sendActionExecution(toolCall.id || (0, import_shared2.randomId)(), toolCall.name, JSON.stringify(toolCall.args));
|
|
512
473
|
}
|
|
513
474
|
}
|
|
514
475
|
} else if (result && "getReader" in result) {
|
|
@@ -526,7 +487,6 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
526
487
|
const { done, value } = await reader.read();
|
|
527
488
|
let toolCallName = void 0;
|
|
528
489
|
let toolCallId = void 0;
|
|
529
|
-
let currentMessageId;
|
|
530
490
|
let toolCallArgs = void 0;
|
|
531
491
|
let hasToolCall = false;
|
|
532
492
|
let content = value == null ? void 0 : value.content;
|
|
@@ -554,14 +514,10 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
554
514
|
}
|
|
555
515
|
if (mode === "message" && (toolCallId || done)) {
|
|
556
516
|
mode = null;
|
|
557
|
-
eventStream$.sendTextMessageEnd(
|
|
558
|
-
messageId: currentMessageId
|
|
559
|
-
});
|
|
517
|
+
eventStream$.sendTextMessageEnd();
|
|
560
518
|
} else if (mode === "function" && (!hasToolCall || done)) {
|
|
561
519
|
mode = null;
|
|
562
|
-
eventStream$.sendActionExecutionEnd(
|
|
563
|
-
actionExecutionId: toolCallId
|
|
564
|
-
});
|
|
520
|
+
eventStream$.sendActionExecutionEnd();
|
|
565
521
|
}
|
|
566
522
|
if (done) {
|
|
567
523
|
break;
|
|
@@ -569,38 +525,21 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
569
525
|
if (mode === null) {
|
|
570
526
|
if (hasToolCall && toolCallId && toolCallName) {
|
|
571
527
|
mode = "function";
|
|
572
|
-
eventStream$.sendActionExecutionStart(
|
|
573
|
-
actionExecutionId: toolCallId,
|
|
574
|
-
actionName: toolCallName
|
|
575
|
-
});
|
|
528
|
+
eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
|
|
576
529
|
} else if (content) {
|
|
577
530
|
mode = "message";
|
|
578
|
-
|
|
579
|
-
eventStream$.sendTextMessageStart({
|
|
580
|
-
messageId: currentMessageId
|
|
581
|
-
});
|
|
531
|
+
eventStream$.sendTextMessageStart((0, import_shared2.randomId)());
|
|
582
532
|
}
|
|
583
533
|
}
|
|
584
534
|
if (mode === "message" && content) {
|
|
585
|
-
eventStream$.sendTextMessageContent(
|
|
586
|
-
messageId: currentMessageId,
|
|
587
|
-
content: Array.isArray(content) ? ((_i = content[0]) == null ? void 0 : _i.text) ?? "" : content
|
|
588
|
-
});
|
|
535
|
+
eventStream$.sendTextMessageContent(Array.isArray(content) ? ((_i = content[0]) == null ? void 0 : _i.text) ?? "" : content);
|
|
589
536
|
} else if (mode === "function" && toolCallArgs) {
|
|
590
537
|
if (toolCallDetails.index !== toolCallDetails.prevIndex) {
|
|
591
|
-
eventStream$.sendActionExecutionEnd(
|
|
592
|
-
|
|
593
|
-
});
|
|
594
|
-
eventStream$.sendActionExecutionStart({
|
|
595
|
-
actionExecutionId: toolCallId,
|
|
596
|
-
actionName: toolCallName
|
|
597
|
-
});
|
|
538
|
+
eventStream$.sendActionExecutionEnd();
|
|
539
|
+
eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
|
|
598
540
|
toolCallDetails.prevIndex = toolCallDetails.index;
|
|
599
541
|
}
|
|
600
|
-
eventStream$.sendActionExecutionArgs(
|
|
601
|
-
actionExecutionId: toolCallId,
|
|
602
|
-
args: toolCallArgs
|
|
603
|
-
});
|
|
542
|
+
eventStream$.sendActionExecutionArgs(toolCallArgs);
|
|
604
543
|
}
|
|
605
544
|
} catch (error) {
|
|
606
545
|
console.error("Error reading from stream", error);
|
|
@@ -608,11 +547,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
|
|
|
608
547
|
}
|
|
609
548
|
}
|
|
610
549
|
} else if (actionExecution) {
|
|
611
|
-
eventStream$.sendActionExecutionResult(
|
|
612
|
-
actionExecutionId: actionExecution.id,
|
|
613
|
-
actionName: actionExecution.name,
|
|
614
|
-
result: encodeResult(result)
|
|
615
|
-
});
|
|
550
|
+
eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, encodeResult(result));
|
|
616
551
|
} else {
|
|
617
552
|
throw new Error("Invalid return type from LangChain function.");
|
|
618
553
|
}
|
|
@@ -792,33 +727,21 @@ var OpenAIAssistantAdapter = class {
|
|
|
792
727
|
eventSource.stream(async (eventStream$) => {
|
|
793
728
|
var _a, _b, _c, _d, _e, _f;
|
|
794
729
|
let inFunctionCall = false;
|
|
795
|
-
let currentMessageId;
|
|
796
|
-
let currentToolCallId;
|
|
797
730
|
for await (const chunk of stream) {
|
|
798
731
|
switch (chunk.event) {
|
|
799
732
|
case "thread.message.created":
|
|
800
733
|
if (inFunctionCall) {
|
|
801
|
-
eventStream$.sendActionExecutionEnd(
|
|
802
|
-
actionExecutionId: currentToolCallId
|
|
803
|
-
});
|
|
734
|
+
eventStream$.sendActionExecutionEnd();
|
|
804
735
|
}
|
|
805
|
-
|
|
806
|
-
eventStream$.sendTextMessageStart({
|
|
807
|
-
messageId: currentMessageId
|
|
808
|
-
});
|
|
736
|
+
eventStream$.sendTextMessageStart(chunk.data.id);
|
|
809
737
|
break;
|
|
810
738
|
case "thread.message.delta":
|
|
811
739
|
if (((_a = chunk.data.delta.content) == null ? void 0 : _a[0].type) === "text") {
|
|
812
|
-
eventStream$.sendTextMessageContent(
|
|
813
|
-
messageId: currentMessageId,
|
|
814
|
-
content: (_b = chunk.data.delta.content) == null ? void 0 : _b[0].text.value
|
|
815
|
-
});
|
|
740
|
+
eventStream$.sendTextMessageContent((_b = chunk.data.delta.content) == null ? void 0 : _b[0].text.value);
|
|
816
741
|
}
|
|
817
742
|
break;
|
|
818
743
|
case "thread.message.completed":
|
|
819
|
-
eventStream$.sendTextMessageEnd(
|
|
820
|
-
messageId: currentMessageId
|
|
821
|
-
});
|
|
744
|
+
eventStream$.sendTextMessageEnd();
|
|
822
745
|
break;
|
|
823
746
|
case "thread.run.step.delta":
|
|
824
747
|
let toolCallId;
|
|
@@ -831,29 +754,18 @@ var OpenAIAssistantAdapter = class {
|
|
|
831
754
|
}
|
|
832
755
|
if (toolCallName && toolCallId) {
|
|
833
756
|
if (inFunctionCall) {
|
|
834
|
-
eventStream$.sendActionExecutionEnd(
|
|
835
|
-
actionExecutionId: currentToolCallId
|
|
836
|
-
});
|
|
757
|
+
eventStream$.sendActionExecutionEnd();
|
|
837
758
|
}
|
|
838
759
|
inFunctionCall = true;
|
|
839
|
-
|
|
840
|
-
eventStream$.sendActionExecutionStart({
|
|
841
|
-
actionExecutionId: currentToolCallId,
|
|
842
|
-
actionName: toolCallName
|
|
843
|
-
});
|
|
760
|
+
eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
|
|
844
761
|
} else if (toolCallArgs) {
|
|
845
|
-
eventStream$.sendActionExecutionArgs(
|
|
846
|
-
actionExecutionId: currentToolCallId,
|
|
847
|
-
args: toolCallArgs
|
|
848
|
-
});
|
|
762
|
+
eventStream$.sendActionExecutionArgs(toolCallArgs);
|
|
849
763
|
}
|
|
850
764
|
break;
|
|
851
765
|
}
|
|
852
766
|
}
|
|
853
767
|
if (inFunctionCall) {
|
|
854
|
-
eventStream$.sendActionExecutionEnd(
|
|
855
|
-
actionExecutionId: currentToolCallId
|
|
856
|
-
});
|
|
768
|
+
eventStream$.sendActionExecutionEnd();
|
|
857
769
|
}
|
|
858
770
|
eventStream$.complete();
|
|
859
771
|
});
|
|
@@ -906,77 +818,46 @@ var UnifyAdapter = class {
|
|
|
906
818
|
}
|
|
907
819
|
});
|
|
908
820
|
let model = null;
|
|
909
|
-
let currentMessageId;
|
|
910
|
-
let currentToolCallId;
|
|
911
821
|
request.eventSource.stream(async (eventStream$) => {
|
|
912
822
|
var _a, _b;
|
|
913
823
|
let mode = null;
|
|
914
824
|
for await (const chunk of stream) {
|
|
915
825
|
if (this.start) {
|
|
916
826
|
model = chunk.model;
|
|
917
|
-
|
|
918
|
-
eventStream$.
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
eventStream$.sendTextMessageContent({
|
|
922
|
-
messageId: currentMessageId,
|
|
923
|
-
content: `Model used: ${model}
|
|
924
|
-
`
|
|
925
|
-
});
|
|
926
|
-
eventStream$.sendTextMessageEnd({
|
|
927
|
-
messageId: currentMessageId
|
|
928
|
-
});
|
|
827
|
+
eventStream$.sendTextMessageStart((0, import_shared4.randomId)());
|
|
828
|
+
eventStream$.sendTextMessageContent(`Model used: ${model}
|
|
829
|
+
`);
|
|
830
|
+
eventStream$.sendTextMessageEnd();
|
|
929
831
|
this.start = false;
|
|
930
832
|
}
|
|
931
833
|
const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
|
|
932
834
|
const content = chunk.choices[0].delta.content;
|
|
933
835
|
if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
|
|
934
836
|
mode = null;
|
|
935
|
-
eventStream$.sendTextMessageEnd(
|
|
936
|
-
messageId: currentMessageId
|
|
937
|
-
});
|
|
837
|
+
eventStream$.sendTextMessageEnd();
|
|
938
838
|
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
939
839
|
mode = null;
|
|
940
|
-
eventStream$.sendActionExecutionEnd(
|
|
941
|
-
actionExecutionId: currentToolCallId
|
|
942
|
-
});
|
|
840
|
+
eventStream$.sendActionExecutionEnd();
|
|
943
841
|
}
|
|
944
842
|
if (mode === null) {
|
|
945
843
|
if (toolCall == null ? void 0 : toolCall.id) {
|
|
946
844
|
mode = "function";
|
|
947
|
-
|
|
948
|
-
eventStream$.sendActionExecutionStart({
|
|
949
|
-
actionExecutionId: currentToolCallId,
|
|
950
|
-
actionName: toolCall.function.name
|
|
951
|
-
});
|
|
845
|
+
eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
|
|
952
846
|
} else if (content) {
|
|
953
847
|
mode = "message";
|
|
954
|
-
|
|
955
|
-
eventStream$.sendTextMessageStart({
|
|
956
|
-
messageId: currentMessageId
|
|
957
|
-
});
|
|
848
|
+
eventStream$.sendTextMessageStart(chunk.id);
|
|
958
849
|
}
|
|
959
850
|
}
|
|
960
851
|
if (mode === "message" && content) {
|
|
961
|
-
eventStream$.sendTextMessageContent(
|
|
962
|
-
messageId: currentMessageId,
|
|
963
|
-
content
|
|
964
|
-
});
|
|
852
|
+
eventStream$.sendTextMessageContent(content);
|
|
965
853
|
} else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
|
|
966
|
-
eventStream$.sendActionExecutionArgs(
|
|
967
|
-
actionExecutionId: currentToolCallId,
|
|
968
|
-
args: toolCall.function.arguments
|
|
969
|
-
});
|
|
854
|
+
eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
|
|
970
855
|
}
|
|
971
856
|
}
|
|
972
857
|
if (mode === "message") {
|
|
973
|
-
eventStream$.sendTextMessageEnd(
|
|
974
|
-
messageId: currentMessageId
|
|
975
|
-
});
|
|
858
|
+
eventStream$.sendTextMessageEnd();
|
|
976
859
|
} else if (mode === "function") {
|
|
977
|
-
eventStream$.sendActionExecutionEnd(
|
|
978
|
-
actionExecutionId: currentToolCallId
|
|
979
|
-
});
|
|
860
|
+
eventStream$.sendActionExecutionEnd();
|
|
980
861
|
}
|
|
981
862
|
eventStream$.complete();
|
|
982
863
|
});
|
|
@@ -1042,58 +923,35 @@ var GroqAdapter = class {
|
|
|
1042
923
|
eventSource.stream(async (eventStream$) => {
|
|
1043
924
|
var _a, _b;
|
|
1044
925
|
let mode = null;
|
|
1045
|
-
let currentMessageId;
|
|
1046
|
-
let currentToolCallId;
|
|
1047
926
|
for await (const chunk of stream) {
|
|
1048
927
|
const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
|
|
1049
928
|
const content = chunk.choices[0].delta.content;
|
|
1050
929
|
if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
|
|
1051
930
|
mode = null;
|
|
1052
|
-
eventStream$.sendTextMessageEnd(
|
|
1053
|
-
messageId: currentMessageId
|
|
1054
|
-
});
|
|
931
|
+
eventStream$.sendTextMessageEnd();
|
|
1055
932
|
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
1056
933
|
mode = null;
|
|
1057
|
-
eventStream$.sendActionExecutionEnd(
|
|
1058
|
-
actionExecutionId: currentToolCallId
|
|
1059
|
-
});
|
|
934
|
+
eventStream$.sendActionExecutionEnd();
|
|
1060
935
|
}
|
|
1061
936
|
if (mode === null) {
|
|
1062
937
|
if (toolCall == null ? void 0 : toolCall.id) {
|
|
1063
938
|
mode = "function";
|
|
1064
|
-
|
|
1065
|
-
eventStream$.sendActionExecutionStart({
|
|
1066
|
-
actionExecutionId: currentToolCallId,
|
|
1067
|
-
actionName: toolCall.function.name
|
|
1068
|
-
});
|
|
939
|
+
eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
|
|
1069
940
|
} else if (content) {
|
|
1070
941
|
mode = "message";
|
|
1071
|
-
|
|
1072
|
-
eventStream$.sendTextMessageStart({
|
|
1073
|
-
messageId: currentMessageId
|
|
1074
|
-
});
|
|
942
|
+
eventStream$.sendTextMessageStart(chunk.id);
|
|
1075
943
|
}
|
|
1076
944
|
}
|
|
1077
945
|
if (mode === "message" && content) {
|
|
1078
|
-
eventStream$.sendTextMessageContent(
|
|
1079
|
-
messageId: currentMessageId,
|
|
1080
|
-
content
|
|
1081
|
-
});
|
|
946
|
+
eventStream$.sendTextMessageContent(content);
|
|
1082
947
|
} else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
|
|
1083
|
-
eventStream$.sendActionExecutionArgs(
|
|
1084
|
-
actionExecutionId: currentToolCallId,
|
|
1085
|
-
args: toolCall.function.arguments
|
|
1086
|
-
});
|
|
948
|
+
eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
|
|
1087
949
|
}
|
|
1088
950
|
}
|
|
1089
951
|
if (mode === "message") {
|
|
1090
|
-
eventStream$.sendTextMessageEnd(
|
|
1091
|
-
messageId: currentMessageId
|
|
1092
|
-
});
|
|
952
|
+
eventStream$.sendTextMessageEnd();
|
|
1093
953
|
} else if (mode === "function") {
|
|
1094
|
-
eventStream$.sendActionExecutionEnd(
|
|
1095
|
-
actionExecutionId: currentToolCallId
|
|
1096
|
-
});
|
|
954
|
+
eventStream$.sendActionExecutionEnd();
|
|
1097
955
|
}
|
|
1098
956
|
eventStream$.complete();
|
|
1099
957
|
});
|
|
@@ -1301,10 +1159,7 @@ var AnthropicAdapter = class {
|
|
|
1301
1159
|
mode = "message";
|
|
1302
1160
|
} else if (chunk.content_block.type === "tool_use") {
|
|
1303
1161
|
currentToolCallId = chunk.content_block.id;
|
|
1304
|
-
eventStream$.sendActionExecutionStart(
|
|
1305
|
-
actionExecutionId: currentToolCallId,
|
|
1306
|
-
actionName: chunk.content_block.name
|
|
1307
|
-
});
|
|
1162
|
+
eventStream$.sendActionExecutionStart(currentToolCallId, chunk.content_block.name);
|
|
1308
1163
|
mode = "function";
|
|
1309
1164
|
}
|
|
1310
1165
|
} else if (chunk.type === "content_block_delta") {
|
|
@@ -1312,33 +1167,21 @@ var AnthropicAdapter = class {
|
|
|
1312
1167
|
const text = filterThinkingTextBuffer.onTextChunk(chunk.delta.text);
|
|
1313
1168
|
if (text.length > 0) {
|
|
1314
1169
|
if (!didOutputText) {
|
|
1315
|
-
eventStream$.sendTextMessageStart(
|
|
1316
|
-
messageId: currentMessageId
|
|
1317
|
-
});
|
|
1170
|
+
eventStream$.sendTextMessageStart(currentMessageId);
|
|
1318
1171
|
didOutputText = true;
|
|
1319
1172
|
}
|
|
1320
|
-
eventStream$.sendTextMessageContent(
|
|
1321
|
-
messageId: currentMessageId,
|
|
1322
|
-
content: text
|
|
1323
|
-
});
|
|
1173
|
+
eventStream$.sendTextMessageContent(text);
|
|
1324
1174
|
}
|
|
1325
1175
|
} else if (chunk.delta.type === "input_json_delta") {
|
|
1326
|
-
eventStream$.sendActionExecutionArgs(
|
|
1327
|
-
actionExecutionId: currentToolCallId,
|
|
1328
|
-
args: chunk.delta.partial_json
|
|
1329
|
-
});
|
|
1176
|
+
eventStream$.sendActionExecutionArgs(chunk.delta.partial_json);
|
|
1330
1177
|
}
|
|
1331
1178
|
} else if (chunk.type === "content_block_stop") {
|
|
1332
1179
|
if (mode === "message") {
|
|
1333
1180
|
if (didOutputText) {
|
|
1334
|
-
eventStream$.sendTextMessageEnd(
|
|
1335
|
-
messageId: currentMessageId
|
|
1336
|
-
});
|
|
1181
|
+
eventStream$.sendTextMessageEnd();
|
|
1337
1182
|
}
|
|
1338
1183
|
} else if (mode === "function") {
|
|
1339
|
-
eventStream$.sendActionExecutionEnd(
|
|
1340
|
-
actionExecutionId: currentToolCallId
|
|
1341
|
-
});
|
|
1184
|
+
eventStream$.sendActionExecutionEnd();
|
|
1342
1185
|
}
|
|
1343
1186
|
}
|
|
1344
1187
|
}
|