@copilotkit/runtime 1.50.0-beta.9 → 1.50.0
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 +157 -0
- package/dist/chunk-27JKTS6P.mjs +1704 -0
- package/dist/chunk-27JKTS6P.mjs.map +1 -0
- package/dist/{chunk-FMU55SEU.mjs → chunk-2GPTVDTO.mjs} +2 -2
- package/dist/chunk-3AJVKDZX.mjs +3097 -0
- package/dist/chunk-3AJVKDZX.mjs.map +1 -0
- package/dist/{chunk-BJEYMRDD.mjs → chunk-45RCC3ZS.mjs} +2 -2
- package/dist/chunk-4EHJ4XFJ.mjs +25 -0
- package/dist/chunk-4EHJ4XFJ.mjs.map +1 -0
- package/dist/chunk-4IANB4TC.mjs +25 -0
- package/dist/chunk-4IANB4TC.mjs.map +1 -0
- package/dist/{chunk-Z752VE75.mjs → chunk-4KES76K3.mjs} +2 -2
- package/dist/chunk-4OGE3SLW.mjs +3100 -0
- package/dist/chunk-4OGE3SLW.mjs.map +1 -0
- package/dist/chunk-54YJBMCP.mjs +3097 -0
- package/dist/chunk-54YJBMCP.mjs.map +1 -0
- package/dist/chunk-6ER4SZYH.mjs +74 -0
- package/dist/chunk-6ER4SZYH.mjs.map +1 -0
- package/dist/chunk-6TNSLHVR.mjs +74 -0
- package/dist/chunk-6TNSLHVR.mjs.map +1 -0
- package/dist/chunk-7V4BK7TZ.mjs +25 -0
- package/dist/chunk-7V4BK7TZ.mjs.map +1 -0
- package/dist/chunk-7YZIEXD2.mjs +74 -0
- package/dist/chunk-7YZIEXD2.mjs.map +1 -0
- package/dist/chunk-A4XHOAFU.mjs +25 -0
- package/dist/chunk-A4XHOAFU.mjs.map +1 -0
- package/dist/chunk-A555KEAD.mjs +6020 -0
- package/dist/chunk-A555KEAD.mjs.map +1 -0
- package/dist/chunk-AF73TFTX.mjs +74 -0
- package/dist/chunk-AF73TFTX.mjs.map +1 -0
- package/dist/chunk-AQG2SVCA.mjs +25 -0
- package/dist/chunk-AQG2SVCA.mjs.map +1 -0
- package/dist/chunk-BJZHMXND.mjs +74 -0
- package/dist/chunk-BJZHMXND.mjs.map +1 -0
- package/dist/chunk-CB2OJXF6.mjs +25 -0
- package/dist/chunk-CB2OJXF6.mjs.map +1 -0
- package/dist/chunk-CEOMFPJU.mjs +6020 -0
- package/dist/chunk-CEOMFPJU.mjs.map +1 -0
- package/dist/chunk-CZVLR7CC.mjs +175 -0
- package/dist/chunk-CZVLR7CC.mjs.map +1 -0
- package/dist/{chunk-SBCOROE4.mjs → chunk-DCEEHMLJ.mjs} +16 -1
- package/dist/chunk-DCEEHMLJ.mjs.map +1 -0
- package/dist/chunk-DE3CLKUG.mjs +25 -0
- package/dist/chunk-DE3CLKUG.mjs.map +1 -0
- package/dist/chunk-DTPRUTNV.mjs +25 -0
- package/dist/chunk-DTPRUTNV.mjs.map +1 -0
- package/dist/{chunk-TTUAEJLD.mjs → chunk-ERUOA47O.mjs} +11 -2
- package/dist/chunk-ERUOA47O.mjs.map +1 -0
- package/dist/chunk-ESSRC64W.mjs +74 -0
- package/dist/chunk-ESSRC64W.mjs.map +1 -0
- package/dist/chunk-GRAN6K6N.mjs +25 -0
- package/dist/chunk-GRAN6K6N.mjs.map +1 -0
- package/dist/chunk-I27F2UPA.mjs +175 -0
- package/dist/chunk-I27F2UPA.mjs.map +1 -0
- package/dist/chunk-IAZKTOQW.mjs +25 -0
- package/dist/chunk-IAZKTOQW.mjs.map +1 -0
- package/dist/chunk-J6XZ5MFB.mjs +25 -0
- package/dist/chunk-J6XZ5MFB.mjs.map +1 -0
- package/dist/chunk-JJ32MA4C.mjs +73 -0
- package/dist/chunk-JJ32MA4C.mjs.map +1 -0
- package/dist/chunk-JJY4ZTHQ.mjs +25 -0
- package/dist/chunk-JJY4ZTHQ.mjs.map +1 -0
- package/dist/chunk-KEYLBFU2.mjs +3117 -0
- package/dist/chunk-KEYLBFU2.mjs.map +1 -0
- package/dist/chunk-KQ53L4WZ.mjs +3094 -0
- package/dist/chunk-KQ53L4WZ.mjs.map +1 -0
- package/dist/chunk-KTELVQ67.mjs +3098 -0
- package/dist/chunk-KTELVQ67.mjs.map +1 -0
- package/dist/chunk-LPEPX6NH.mjs +25 -0
- package/dist/chunk-LPEPX6NH.mjs.map +1 -0
- package/dist/chunk-MDXE55DK.mjs +3117 -0
- package/dist/chunk-MDXE55DK.mjs.map +1 -0
- package/dist/chunk-MMFUVOXH.mjs +73 -0
- package/dist/chunk-MMFUVOXH.mjs.map +1 -0
- package/dist/chunk-N3Y4U66N.mjs +253 -0
- package/dist/chunk-N3Y4U66N.mjs.map +1 -0
- package/dist/chunk-O7UYB4MH.mjs +25 -0
- package/dist/chunk-O7UYB4MH.mjs.map +1 -0
- package/dist/chunk-OFNVQHNM.mjs +3089 -0
- package/dist/chunk-OFNVQHNM.mjs.map +1 -0
- package/dist/{chunk-DZV4ZIAR.mjs → chunk-OFSV5GET.mjs} +17 -6
- package/dist/chunk-OFSV5GET.mjs.map +1 -0
- package/dist/chunk-OMRST67R.mjs +25 -0
- package/dist/chunk-OMRST67R.mjs.map +1 -0
- package/dist/chunk-PRZHE74A.mjs +25 -0
- package/dist/chunk-PRZHE74A.mjs.map +1 -0
- package/dist/chunk-PTYRVXXP.mjs +80 -0
- package/dist/chunk-PTYRVXXP.mjs.map +1 -0
- package/dist/chunk-R22B5CCO.mjs +25 -0
- package/dist/chunk-R22B5CCO.mjs.map +1 -0
- package/dist/chunk-SHBDMA63.mjs +141 -0
- package/dist/chunk-SHBDMA63.mjs.map +1 -0
- package/dist/chunk-SPVXBPRA.mjs +74 -0
- package/dist/chunk-SPVXBPRA.mjs.map +1 -0
- package/dist/chunk-T72G46ME.mjs +25 -0
- package/dist/chunk-T72G46ME.mjs.map +1 -0
- package/dist/chunk-TGELROPU.mjs +25 -0
- package/dist/chunk-TGELROPU.mjs.map +1 -0
- package/dist/chunk-UNX4IAAD.mjs +25 -0
- package/dist/chunk-UNX4IAAD.mjs.map +1 -0
- package/dist/chunk-V4DHVC7M.mjs +3085 -0
- package/dist/chunk-V4DHVC7M.mjs.map +1 -0
- package/dist/chunk-VVRFOB66.mjs +25 -0
- package/dist/chunk-VVRFOB66.mjs.map +1 -0
- package/dist/chunk-W6NVBYM6.mjs +80 -0
- package/dist/chunk-W6NVBYM6.mjs.map +1 -0
- package/dist/chunk-W7MBACGC.mjs +74 -0
- package/dist/chunk-W7MBACGC.mjs.map +1 -0
- package/dist/chunk-WMD4XZZS.mjs +25 -0
- package/dist/chunk-WMD4XZZS.mjs.map +1 -0
- package/dist/chunk-WX2ZNCRT.mjs +74 -0
- package/dist/chunk-WX2ZNCRT.mjs.map +1 -0
- package/dist/chunk-Y2Z62E2T.mjs +74 -0
- package/dist/chunk-Y2Z62E2T.mjs.map +1 -0
- package/dist/chunk-YO4I6RVI.mjs +25 -0
- package/dist/chunk-YO4I6RVI.mjs.map +1 -0
- package/dist/chunk-Z6Q5IW6I.mjs +3098 -0
- package/dist/chunk-Z6Q5IW6I.mjs.map +1 -0
- package/dist/chunk-Z726O3G2.mjs +25 -0
- package/dist/chunk-Z726O3G2.mjs.map +1 -0
- package/dist/chunk-ZE4SMZZR.mjs +3097 -0
- package/dist/chunk-ZE4SMZZR.mjs.map +1 -0
- package/dist/chunk-ZULZB33C.mjs +73 -0
- package/dist/chunk-ZULZB33C.mjs.map +1 -0
- package/dist/chunk-ZVRGXMY7.mjs +25 -0
- package/dist/chunk-ZVRGXMY7.mjs.map +1 -0
- package/dist/chunk-ZZ35WBYQ.mjs +25 -0
- package/dist/chunk-ZZ35WBYQ.mjs.map +1 -0
- package/dist/graphql/types/converted/index.d.ts +1 -1
- package/dist/graphql/types/converted/index.js +16 -110
- package/dist/graphql/types/converted/index.js.map +1 -1
- package/dist/graphql/types/converted/index.mjs +2 -3
- package/dist/{groq-adapter-50bc6e4a.d.ts → groq-adapter-540da9c3.d.ts} +6 -1
- package/dist/groq-adapter-a6f5e9d2.d.ts +331 -0
- package/dist/groq-adapter-c8aec5c5.d.ts +321 -0
- package/dist/index-96b330da.d.ts +119 -0
- package/dist/index.d.ts +67 -8
- package/dist/index.js +118 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -31
- package/dist/index.mjs.map +1 -1
- package/dist/langserve-0c6100e3.d.ts +257 -0
- package/dist/langserve-978d5790.d.ts +243 -0
- package/dist/{langserve-74a52292.d.ts → langserve-9fc76ce5.d.ts} +1 -0
- package/dist/lib/index.d.ts +5 -59
- package/dist/lib/index.js +3702 -803
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +20 -18
- package/dist/lib/integrations/index.d.ts +15 -9
- package/dist/lib/integrations/index.js +215 -187
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +8 -7
- package/dist/lib/integrations/nest/index.d.ts +5 -6
- package/dist/lib/integrations/nest/index.js +197 -175
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +6 -5
- package/dist/lib/integrations/node-express/index.d.ts +5 -6
- package/dist/lib/integrations/node-express/index.js +197 -175
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +6 -5
- package/dist/lib/integrations/node-http/index.d.ts +5 -6
- package/dist/lib/integrations/node-http/index.js +197 -175
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +5 -4
- package/dist/service-adapters/index.d.ts +7 -11
- package/dist/service-adapters/index.js +8 -21
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +2 -4
- package/dist/shared-0a7346ce.d.ts +466 -0
- package/dist/{shared-f6d43ef8.d.ts → shared-35c6eb04.d.ts} +3 -1
- package/dist/shared-9ed1dc31.d.ts +414 -0
- package/dist/shared-da5708fe.d.ts +449 -0
- package/package.json +14 -20
- package/src/lib/index.ts +7 -6
- package/src/lib/runtime/copilot-runtime.ts +62 -26
- package/src/lib/runtime/telemetry-agent-runner.ts +139 -0
- package/dist/chunk-DZV4ZIAR.mjs.map +0 -1
- package/dist/chunk-SBCOROE4.mjs.map +0 -1
- package/dist/chunk-TTUAEJLD.mjs.map +0 -1
- /package/dist/{chunk-FMU55SEU.mjs.map → chunk-2GPTVDTO.mjs.map} +0 -0
- /package/dist/{chunk-BJEYMRDD.mjs.map → chunk-45RCC3ZS.mjs.map} +0 -0
- /package/dist/{chunk-Z752VE75.mjs.map → chunk-4KES76K3.mjs.map} +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
copilotRuntimeNodeHttpEndpoint,
|
|
3
|
+
getRuntimeInstanceTelemetryInfo,
|
|
4
|
+
telemetry_client_default
|
|
5
|
+
} from "./chunk-3AJVKDZX.mjs";
|
|
6
|
+
import {
|
|
7
|
+
__name
|
|
8
|
+
} from "./chunk-FHD4JECV.mjs";
|
|
9
|
+
|
|
10
|
+
// src/lib/integrations/nest/index.ts
|
|
11
|
+
function copilotRuntimeNestEndpoint(options) {
|
|
12
|
+
telemetry_client_default.setGlobalProperties({
|
|
13
|
+
runtime: {
|
|
14
|
+
framework: "nest"
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
|
|
18
|
+
return copilotRuntimeNodeHttpEndpoint(options);
|
|
19
|
+
}
|
|
20
|
+
__name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
copilotRuntimeNestEndpoint
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-ZZ35WBYQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/integrations/nest/index.ts"],"sourcesContent":["import { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { copilotRuntimeNodeHttpEndpoint } from \"../node-http\";\nimport telemetry, { getRuntimeInstanceTelemetryInfo } from \"../../telemetry-client\";\n\nexport function copilotRuntimeNestEndpoint(options: CreateCopilotRuntimeServerOptions) {\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"nest\",\n },\n });\n\n telemetry.capture(\"oss.runtime.instance_created\", getRuntimeInstanceTelemetryInfo(options));\n return copilotRuntimeNodeHttpEndpoint(options);\n}\n"],"mappings":";;;;;;;;;;AAIO,SAASA,2BAA2BC,SAA0C;AACnFC,2BAAUC,oBAAoB;IAC5BC,SAAS;MACPC,WAAW;IACb;EACF,CAAA;AAEAH,2BAAUI,QAAQ,gCAAgCC,gCAAgCN,OAAAA,CAAAA;AAClF,SAAOO,+BAA+BP,OAAAA;AACxC;AATgBD;","names":["copilotRuntimeNestEndpoint","options","telemetry","setGlobalProperties","runtime","framework","capture","getRuntimeInstanceTelemetryInfo","copilotRuntimeNodeHttpEndpoint"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a as ActionExecutionMessage, d as AgentStateMessage, I as ImageMessage, M as Message, c as MessageType, R as ResultMessage, T as TextMessage } from '../../../index-96b330da.js';
|
|
2
2
|
import '../base/index.js';
|
|
@@ -25,51 +25,12 @@ __export(converted_exports, {
|
|
|
25
25
|
ImageMessage: () => ImageMessage,
|
|
26
26
|
Message: () => Message,
|
|
27
27
|
ResultMessage: () => ResultMessage,
|
|
28
|
-
Role: () => Role,
|
|
29
28
|
TextMessage: () => TextMessage
|
|
30
29
|
});
|
|
31
30
|
module.exports = __toCommonJS(converted_exports);
|
|
32
|
-
var import_shared = require("@copilotkit/shared");
|
|
33
31
|
|
|
34
|
-
// src/graphql/types/
|
|
32
|
+
// src/graphql/types/base/index.ts
|
|
35
33
|
var import_type_graphql = require("type-graphql");
|
|
36
|
-
var MessageRole;
|
|
37
|
-
(function(MessageRole2) {
|
|
38
|
-
MessageRole2["assistant"] = "assistant";
|
|
39
|
-
MessageRole2["developer"] = "developer";
|
|
40
|
-
MessageRole2["system"] = "system";
|
|
41
|
-
MessageRole2["tool"] = "tool";
|
|
42
|
-
MessageRole2["user"] = "user";
|
|
43
|
-
})(MessageRole || (MessageRole = {}));
|
|
44
|
-
var CopilotRequestType;
|
|
45
|
-
(function(CopilotRequestType2) {
|
|
46
|
-
CopilotRequestType2["Chat"] = "Chat";
|
|
47
|
-
CopilotRequestType2["Task"] = "Task";
|
|
48
|
-
CopilotRequestType2["TextareaCompletion"] = "TextareaCompletion";
|
|
49
|
-
CopilotRequestType2["TextareaPopover"] = "TextareaPopover";
|
|
50
|
-
CopilotRequestType2["Suggestion"] = "Suggestion";
|
|
51
|
-
})(CopilotRequestType || (CopilotRequestType = {}));
|
|
52
|
-
var ActionInputAvailability;
|
|
53
|
-
(function(ActionInputAvailability2) {
|
|
54
|
-
ActionInputAvailability2["disabled"] = "disabled";
|
|
55
|
-
ActionInputAvailability2["enabled"] = "enabled";
|
|
56
|
-
ActionInputAvailability2["remote"] = "remote";
|
|
57
|
-
})(ActionInputAvailability || (ActionInputAvailability = {}));
|
|
58
|
-
(0, import_type_graphql.registerEnumType)(MessageRole, {
|
|
59
|
-
name: "MessageRole",
|
|
60
|
-
description: "The role of the message"
|
|
61
|
-
});
|
|
62
|
-
(0, import_type_graphql.registerEnumType)(CopilotRequestType, {
|
|
63
|
-
name: "CopilotRequestType",
|
|
64
|
-
description: "The type of Copilot request"
|
|
65
|
-
});
|
|
66
|
-
(0, import_type_graphql.registerEnumType)(ActionInputAvailability, {
|
|
67
|
-
name: "ActionInputAvailability",
|
|
68
|
-
description: "The availability of the frontend action"
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// src/graphql/types/message-status.type.ts
|
|
72
|
-
var import_type_graphql2 = require("type-graphql");
|
|
73
34
|
function _ts_decorate(decorators, target, key, desc) {
|
|
74
35
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
75
36
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -86,75 +47,26 @@ function _ts_metadata(k, v) {
|
|
|
86
47
|
return Reflect.metadata(k, v);
|
|
87
48
|
}
|
|
88
49
|
__name(_ts_metadata, "_ts_metadata");
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
MessageStatusCode2["Success"] = "success";
|
|
93
|
-
MessageStatusCode2["Failed"] = "failed";
|
|
94
|
-
})(MessageStatusCode || (MessageStatusCode = {}));
|
|
95
|
-
(0, import_type_graphql2.registerEnumType)(MessageStatusCode, {
|
|
96
|
-
name: "MessageStatusCode"
|
|
97
|
-
});
|
|
98
|
-
var BaseMessageStatus = class {
|
|
99
|
-
code;
|
|
50
|
+
var BaseMessageInput = class {
|
|
51
|
+
id;
|
|
52
|
+
createdAt;
|
|
100
53
|
};
|
|
101
|
-
__name(
|
|
54
|
+
__name(BaseMessageInput, "BaseMessageInput");
|
|
102
55
|
_ts_decorate([
|
|
103
|
-
(0,
|
|
56
|
+
(0, import_type_graphql.Field)(() => String),
|
|
104
57
|
_ts_metadata("design:type", String)
|
|
105
|
-
],
|
|
106
|
-
BaseMessageStatus = _ts_decorate([
|
|
107
|
-
(0, import_type_graphql2.ObjectType)()
|
|
108
|
-
], BaseMessageStatus);
|
|
109
|
-
var PendingMessageStatus = class extends BaseMessageStatus {
|
|
110
|
-
code = "pending";
|
|
111
|
-
};
|
|
112
|
-
__name(PendingMessageStatus, "PendingMessageStatus");
|
|
113
|
-
PendingMessageStatus = _ts_decorate([
|
|
114
|
-
(0, import_type_graphql2.ObjectType)()
|
|
115
|
-
], PendingMessageStatus);
|
|
116
|
-
var SuccessMessageStatus = class extends BaseMessageStatus {
|
|
117
|
-
code = "success";
|
|
118
|
-
};
|
|
119
|
-
__name(SuccessMessageStatus, "SuccessMessageStatus");
|
|
120
|
-
SuccessMessageStatus = _ts_decorate([
|
|
121
|
-
(0, import_type_graphql2.ObjectType)()
|
|
122
|
-
], SuccessMessageStatus);
|
|
123
|
-
var FailedMessageStatus = class extends BaseMessageStatus {
|
|
124
|
-
code = "failed";
|
|
125
|
-
reason;
|
|
126
|
-
};
|
|
127
|
-
__name(FailedMessageStatus, "FailedMessageStatus");
|
|
58
|
+
], BaseMessageInput.prototype, "id", void 0);
|
|
128
59
|
_ts_decorate([
|
|
129
|
-
(0,
|
|
130
|
-
_ts_metadata("design:type",
|
|
131
|
-
],
|
|
132
|
-
|
|
133
|
-
(0,
|
|
134
|
-
],
|
|
135
|
-
var MessageStatusUnion = (0, import_type_graphql2.createUnionType)({
|
|
136
|
-
name: "MessageStatus",
|
|
137
|
-
types: () => [
|
|
138
|
-
PendingMessageStatus,
|
|
139
|
-
SuccessMessageStatus,
|
|
140
|
-
FailedMessageStatus
|
|
141
|
-
]
|
|
142
|
-
});
|
|
60
|
+
(0, import_type_graphql.Field)(() => Date),
|
|
61
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
62
|
+
], BaseMessageInput.prototype, "createdAt", void 0);
|
|
63
|
+
BaseMessageInput = _ts_decorate([
|
|
64
|
+
(0, import_type_graphql.InputType)()
|
|
65
|
+
], BaseMessageInput);
|
|
143
66
|
|
|
144
67
|
// src/graphql/types/converted/index.ts
|
|
145
|
-
var Message = class {
|
|
68
|
+
var Message = class extends BaseMessageInput {
|
|
146
69
|
type;
|
|
147
|
-
id;
|
|
148
|
-
createdAt;
|
|
149
|
-
status;
|
|
150
|
-
constructor(props) {
|
|
151
|
-
props.id ?? (props.id = (0, import_shared.randomId)());
|
|
152
|
-
props.status ?? (props.status = {
|
|
153
|
-
code: MessageStatusCode.Success
|
|
154
|
-
});
|
|
155
|
-
props.createdAt ?? (props.createdAt = /* @__PURE__ */ new Date());
|
|
156
|
-
Object.assign(this, props);
|
|
157
|
-
}
|
|
158
70
|
isTextMessage() {
|
|
159
71
|
return this.type === "TextMessage";
|
|
160
72
|
}
|
|
@@ -172,16 +84,11 @@ var Message = class {
|
|
|
172
84
|
}
|
|
173
85
|
};
|
|
174
86
|
__name(Message, "Message");
|
|
175
|
-
var Role = MessageRole;
|
|
176
87
|
var TextMessage = class extends Message {
|
|
88
|
+
type = "TextMessage";
|
|
177
89
|
content;
|
|
178
|
-
parentMessageId;
|
|
179
90
|
role;
|
|
180
|
-
|
|
181
|
-
constructor(props) {
|
|
182
|
-
super(props);
|
|
183
|
-
this.type = "TextMessage";
|
|
184
|
-
}
|
|
91
|
+
parentMessageId;
|
|
185
92
|
};
|
|
186
93
|
__name(TextMessage, "TextMessage");
|
|
187
94
|
var ActionExecutionMessage = class extends Message {
|
|
@@ -288,7 +195,6 @@ __name(ImageMessage, "ImageMessage");
|
|
|
288
195
|
ImageMessage,
|
|
289
196
|
Message,
|
|
290
197
|
ResultMessage,
|
|
291
|
-
Role,
|
|
292
198
|
TextMessage
|
|
293
199
|
});
|
|
294
200
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/graphql/types/converted/index.ts","../../../../src/graphql/types/enums.ts","../../../../src/graphql/types/message-status.type.ts"],"sourcesContent":["import { randomId } from \"@copilotkit/shared\";\nimport {\n ActionExecutionMessageInput,\n ResultMessageInput,\n TextMessageInput,\n AgentStateMessageInput,\n ImageMessageInput,\n} from \"../../inputs/message.input\";\nimport { BaseMessageInput } from \"../base\";\nimport { BaseMessageOutput } from \"../copilot-response.type\";\nimport { MessageRole } from \"../enums\";\nimport { MessageStatus, MessageStatusCode } from \"../message-status.type\";\n\nexport type MessageType =\n | \"TextMessage\"\n | \"ActionExecutionMessage\"\n | \"ResultMessage\"\n | \"AgentStateMessage\"\n | \"ImageMessage\";\n\nexport class Message {\n type: MessageType;\n id: BaseMessageOutput[\"id\"];\n createdAt: BaseMessageOutput[\"createdAt\"];\n status: MessageStatus;\n\n constructor(props: any) {\n props.id ??= randomId();\n props.status ??= { code: MessageStatusCode.Success };\n props.createdAt ??= new Date();\n Object.assign(this, props);\n }\n\n isTextMessage(): this is TextMessage {\n return this.type === \"TextMessage\";\n }\n\n isActionExecutionMessage(): this is ActionExecutionMessage {\n return this.type === \"ActionExecutionMessage\";\n }\n\n isResultMessage(): this is ResultMessage {\n return this.type === \"ResultMessage\";\n }\n\n isAgentStateMessage(): this is AgentStateMessage {\n return this.type === \"AgentStateMessage\";\n }\n\n isImageMessage(): this is ImageMessage {\n return this.type === \"ImageMessage\";\n }\n}\n\n// alias Role to MessageRole\nexport const Role = MessageRole;\n\n// when constructing any message, the base fields are optional\ntype MessageConstructorOptions = Partial<Message>;\n\ntype TextMessageConstructorOptions = MessageConstructorOptions & TextMessageInput;\n\nexport class TextMessage extends Message implements TextMessageConstructorOptions {\n content: TextMessageInput[\"content\"];\n parentMessageId: TextMessageInput[\"parentMessageId\"];\n role: TextMessageInput[\"role\"];\n type = \"TextMessage\" as const;\n\n constructor(props: TextMessageConstructorOptions) {\n super(props);\n this.type = \"TextMessage\";\n }\n}\n\nexport class ActionExecutionMessage\n extends Message\n implements Omit<ActionExecutionMessageInput, \"arguments\" | \"scope\">\n{\n type: MessageType = \"ActionExecutionMessage\";\n name: string;\n arguments: Record<string, any>;\n parentMessageId?: string;\n}\n\nexport class ResultMessage extends Message implements ResultMessageInput {\n type: MessageType = \"ResultMessage\";\n actionExecutionId: string;\n actionName: string;\n result: string;\n\n static encodeResult(\n result: any,\n error?: { code: string; message: string } | string | Error,\n ): string {\n const errorObj = error\n ? typeof error === \"string\"\n ? { code: \"ERROR\", message: error }\n : error instanceof Error\n ? { code: \"ERROR\", message: error.message }\n : error\n : undefined;\n\n if (errorObj) {\n return JSON.stringify({\n error: errorObj,\n result: result || \"\",\n });\n }\n if (result === undefined) {\n return \"\";\n }\n return typeof result === \"string\" ? result : JSON.stringify(result);\n }\n\n static decodeResult(result: string): {\n error?: { code: string; message: string };\n result: string;\n } {\n if (!result) {\n return { result: \"\" };\n }\n try {\n const parsed = JSON.parse(result);\n if (parsed && typeof parsed === \"object\") {\n if (\"error\" in parsed) {\n return {\n error: parsed.error,\n result: parsed.result || \"\",\n };\n }\n return { result: JSON.stringify(parsed) };\n }\n return { result };\n } catch (e) {\n return { result };\n }\n }\n\n hasError(): boolean {\n try {\n const { error } = ResultMessage.decodeResult(this.result);\n return !!error;\n } catch {\n return false;\n }\n }\n\n getError(): { code: string; message: string } | undefined {\n try {\n const { error } = ResultMessage.decodeResult(this.result);\n return error;\n } catch {\n return undefined;\n }\n }\n}\n\nexport class AgentStateMessage extends Message implements Omit<AgentStateMessageInput, \"state\"> {\n type: MessageType = \"AgentStateMessage\";\n threadId: string;\n agentName: string;\n nodeName: string;\n runId: string;\n active: boolean;\n role: MessageRole;\n state: any;\n running: boolean;\n}\n\nexport class ImageMessage extends Message implements ImageMessageInput {\n type: MessageType = \"ImageMessage\";\n format: string;\n bytes: string;\n role: MessageRole;\n parentMessageId?: string;\n}\n","import { registerEnumType } from \"type-graphql\";\n\nexport enum MessageRole {\n assistant = \"assistant\",\n developer = \"developer\",\n system = \"system\",\n tool = \"tool\",\n user = \"user\",\n}\n\nexport enum CopilotRequestType {\n Chat = \"Chat\",\n Task = \"Task\",\n TextareaCompletion = \"TextareaCompletion\",\n TextareaPopover = \"TextareaPopover\",\n Suggestion = \"Suggestion\",\n}\n\nexport enum ActionInputAvailability {\n disabled = \"disabled\",\n enabled = \"enabled\",\n remote = \"remote\",\n}\n\nregisterEnumType(MessageRole, {\n name: \"MessageRole\",\n description: \"The role of the message\",\n});\n\nregisterEnumType(CopilotRequestType, {\n name: \"CopilotRequestType\",\n description: \"The type of Copilot request\",\n});\n\nregisterEnumType(ActionInputAvailability, {\n name: \"ActionInputAvailability\",\n description: \"The availability of the frontend action\",\n});\n","import { Field, ObjectType, createUnionType, registerEnumType } from \"type-graphql\";\n\nexport enum MessageStatusCode {\n Pending = \"pending\",\n Success = \"success\",\n Failed = \"failed\",\n}\n\nregisterEnumType(MessageStatusCode, {\n name: \"MessageStatusCode\",\n});\n\n@ObjectType()\nexport class BaseMessageStatus {\n @Field(() => MessageStatusCode)\n code: MessageStatusCode;\n}\n\n@ObjectType()\nexport class PendingMessageStatus extends BaseMessageStatus {\n code: MessageStatusCode = MessageStatusCode.Pending;\n}\n\n@ObjectType()\nexport class SuccessMessageStatus extends BaseMessageStatus {\n code: MessageStatusCode = MessageStatusCode.Success;\n}\n\n@ObjectType()\nexport class FailedMessageStatus extends BaseMessageStatus {\n code: MessageStatusCode = MessageStatusCode.Failed;\n\n @Field(() => String)\n reason: string;\n}\n\nexport const MessageStatusUnion = createUnionType({\n name: \"MessageStatus\",\n types: () => [PendingMessageStatus, SuccessMessageStatus, FailedMessageStatus] as const,\n});\n\nexport type MessageStatus = typeof MessageStatusUnion;\n"],"mappings":"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","names":["MessageRole","CopilotRequestType","ActionInputAvailability","registerEnumType","name","description","import_type_graphql","MessageStatusCode","registerEnumType","name","BaseMessageStatus","code","Field","ObjectType","PendingMessageStatus","SuccessMessageStatus","FailedMessageStatus","reason","String","MessageStatusUnion","createUnionType","types","Message","type","id","createdAt","status","constructor","props","randomId","code","MessageStatusCode","Success","Date","Object","assign","isTextMessage","isActionExecutionMessage","isResultMessage","isAgentStateMessage","isImageMessage","Role","MessageRole","TextMessage","content","parentMessageId","role","ActionExecutionMessage","name","arguments","ResultMessage","actionExecutionId","actionName","result","encodeResult","error","errorObj","message","Error","undefined","JSON","stringify","decodeResult","parsed","parse","e","hasError","getError","AgentStateMessage","threadId","agentName","nodeName","runId","active","state","running","ImageMessage","format","bytes"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/graphql/types/converted/index.ts","../../../../src/graphql/types/base/index.ts"],"sourcesContent":["import {\n ActionExecutionMessageInput,\n ResultMessageInput,\n TextMessageInput,\n AgentStateMessageInput,\n ImageMessageInput,\n} from \"../../inputs/message.input\";\nimport { BaseMessageInput } from \"../base\";\nimport { MessageRole } from \"../enums\";\n\nexport type MessageType =\n | \"TextMessage\"\n | \"ActionExecutionMessage\"\n | \"ResultMessage\"\n | \"AgentStateMessage\"\n | \"ImageMessage\";\n\nexport class Message extends BaseMessageInput {\n type: MessageType;\n\n isTextMessage(): this is TextMessage {\n return this.type === \"TextMessage\";\n }\n\n isActionExecutionMessage(): this is ActionExecutionMessage {\n return this.type === \"ActionExecutionMessage\";\n }\n\n isResultMessage(): this is ResultMessage {\n return this.type === \"ResultMessage\";\n }\n\n isAgentStateMessage(): this is AgentStateMessage {\n return this.type === \"AgentStateMessage\";\n }\n\n isImageMessage(): this is ImageMessage {\n return this.type === \"ImageMessage\";\n }\n}\n\nexport class TextMessage extends Message implements TextMessageInput {\n type: MessageType = \"TextMessage\";\n content: string;\n role: MessageRole;\n parentMessageId?: string;\n}\n\nexport class ActionExecutionMessage\n extends Message\n implements Omit<ActionExecutionMessageInput, \"arguments\" | \"scope\">\n{\n type: MessageType = \"ActionExecutionMessage\";\n name: string;\n arguments: Record<string, any>;\n parentMessageId?: string;\n}\n\nexport class ResultMessage extends Message implements ResultMessageInput {\n type: MessageType = \"ResultMessage\";\n actionExecutionId: string;\n actionName: string;\n result: string;\n\n static encodeResult(\n result: any,\n error?: { code: string; message: string } | string | Error,\n ): string {\n const errorObj = error\n ? typeof error === \"string\"\n ? { code: \"ERROR\", message: error }\n : error instanceof Error\n ? { code: \"ERROR\", message: error.message }\n : error\n : undefined;\n\n if (errorObj) {\n return JSON.stringify({\n error: errorObj,\n result: result || \"\",\n });\n }\n if (result === undefined) {\n return \"\";\n }\n return typeof result === \"string\" ? result : JSON.stringify(result);\n }\n\n static decodeResult(result: string): {\n error?: { code: string; message: string };\n result: string;\n } {\n if (!result) {\n return { result: \"\" };\n }\n try {\n const parsed = JSON.parse(result);\n if (parsed && typeof parsed === \"object\") {\n if (\"error\" in parsed) {\n return {\n error: parsed.error,\n result: parsed.result || \"\",\n };\n }\n return { result: JSON.stringify(parsed) };\n }\n return { result };\n } catch (e) {\n return { result };\n }\n }\n\n hasError(): boolean {\n try {\n const { error } = ResultMessage.decodeResult(this.result);\n return !!error;\n } catch {\n return false;\n }\n }\n\n getError(): { code: string; message: string } | undefined {\n try {\n const { error } = ResultMessage.decodeResult(this.result);\n return error;\n } catch {\n return undefined;\n }\n }\n}\n\nexport class AgentStateMessage extends Message implements Omit<AgentStateMessageInput, \"state\"> {\n type: MessageType = \"AgentStateMessage\";\n threadId: string;\n agentName: string;\n nodeName: string;\n runId: string;\n active: boolean;\n role: MessageRole;\n state: any;\n running: boolean;\n}\n\nexport class ImageMessage extends Message implements ImageMessageInput {\n type: MessageType = \"ImageMessage\";\n format: string;\n bytes: string;\n role: MessageRole;\n parentMessageId?: string;\n}\n","import { Field, InputType } from \"type-graphql\";\n\n@InputType()\nexport class BaseMessageInput {\n @Field(() => String)\n id: string;\n\n @Field(() => Date)\n createdAt: Date;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOA;;;;;;;;;;;;ACPA,0BAAiC;;;;;;;;;;;;;;;;;AAG1B,IAAMA,mBAAN,MAAMA;EAEXC;EAGAC;AACF;AANaF;;MACVG,2BAAM,MAAMC,MAAAA;;GADFJ,iBAAAA,WAAAA,MAAAA,MAAAA;;MAIVG,2BAAM,MAAME,IAAAA;qCACF,SAAA,cAAA,SAAA,IAAA;GALAL,iBAAAA,WAAAA,aAAAA,MAAAA;AAAAA,mBAAAA,aAAAA;MADZM,+BAAAA;GACYN,gBAAAA;;;ADcN,IAAMO,UAAN,cAAsBC,iBAAAA;EAC3BC;EAEAC,gBAAqC;AACnC,WAAO,KAAKD,SAAS;EACvB;EAEAE,2BAA2D;AACzD,WAAO,KAAKF,SAAS;EACvB;EAEAG,kBAAyC;AACvC,WAAO,KAAKH,SAAS;EACvB;EAEAI,sBAAiD;AAC/C,WAAO,KAAKJ,SAAS;EACvB;EAEAK,iBAAuC;AACrC,WAAO,KAAKL,SAAS;EACvB;AACF;AAtBaF;AAwBN,IAAMQ,cAAN,cAA0BR,QAAAA;EAC/BE,OAAoB;EACpBO;EACAC;EACAC;AACF;AALaH;AAON,IAAMI,yBAAN,cACGZ,QAAAA;EAGRE,OAAoB;EACpBW;EACAC;EACAH;AACF;AARaC;AAUN,IAAMG,gBAAN,cAA4Bf,QAAAA;EACjCE,OAAoB;EACpBc;EACAC;EACAC;EAEA,OAAOC,aACLD,QACAE,OACQ;AACR,UAAMC,WAAWD,QACb,OAAOA,UAAU,WACf;MAAEE,MAAM;MAASC,SAASH;IAAM,IAChCA,iBAAiBI,QACf;MAAEF,MAAM;MAASC,SAASH,MAAMG;IAAQ,IACxCH,QACJK;AAEJ,QAAIJ,UAAU;AACZ,aAAOK,KAAKC,UAAU;QACpBP,OAAOC;QACPH,QAAQA,UAAU;MACpB,CAAA;IACF;AACA,QAAIA,WAAWO,QAAW;AACxB,aAAO;IACT;AACA,WAAO,OAAOP,WAAW,WAAWA,SAASQ,KAAKC,UAAUT,MAAAA;EAC9D;EAEA,OAAOU,aAAaV,QAGlB;AACA,QAAI,CAACA,QAAQ;AACX,aAAO;QAAEA,QAAQ;MAAG;IACtB;AACA,QAAI;AACF,YAAMW,SAASH,KAAKI,MAAMZ,MAAAA;AAC1B,UAAIW,UAAU,OAAOA,WAAW,UAAU;AACxC,YAAI,WAAWA,QAAQ;AACrB,iBAAO;YACLT,OAAOS,OAAOT;YACdF,QAAQW,OAAOX,UAAU;UAC3B;QACF;AACA,eAAO;UAAEA,QAAQQ,KAAKC,UAAUE,MAAAA;QAAQ;MAC1C;AACA,aAAO;QAAEX;MAAO;IAClB,SAASa,GAAP;AACA,aAAO;QAAEb;MAAO;IAClB;EACF;EAEAc,WAAoB;AAClB,QAAI;AACF,YAAM,EAAEZ,MAAK,IAAKL,cAAca,aAAa,KAAKV,MAAM;AACxD,aAAO,CAAC,CAACE;IACX,QAAE;AACA,aAAO;IACT;EACF;EAEAa,WAA0D;AACxD,QAAI;AACF,YAAM,EAAEb,MAAK,IAAKL,cAAca,aAAa,KAAKV,MAAM;AACxD,aAAOE;IACT,QAAE;AACA,aAAOK;IACT;EACF;AACF;AAvEaV;AAyEN,IAAMmB,oBAAN,cAAgClC,QAAAA;EACrCE,OAAoB;EACpBiC;EACAC;EACAC;EACAC;EACAC;EACA7B;EACA8B;EACAC;AACF;AAVaP;AAYN,IAAMQ,eAAN,cAA2B1C,QAAAA;EAChCE,OAAoB;EACpByC;EACAC;EACAlC;EACAC;AACF;AANa+B;","names":["BaseMessageInput","id","createdAt","Field","String","Date","InputType","Message","BaseMessageInput","type","isTextMessage","isActionExecutionMessage","isResultMessage","isAgentStateMessage","isImageMessage","TextMessage","content","role","parentMessageId","ActionExecutionMessage","name","arguments","ResultMessage","actionExecutionId","actionName","result","encodeResult","error","errorObj","code","message","Error","undefined","JSON","stringify","decodeResult","parsed","parse","e","hasError","getError","AgentStateMessage","threadId","agentName","nodeName","runId","active","state","running","ImageMessage","format","bytes"]}
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
ImageMessage,
|
|
5
5
|
Message,
|
|
6
6
|
ResultMessage,
|
|
7
|
-
Role,
|
|
8
7
|
TextMessage
|
|
9
|
-
} from "../../../chunk-
|
|
8
|
+
} from "../../../chunk-SHBDMA63.mjs";
|
|
9
|
+
import "../../../chunk-2OZAGFV3.mjs";
|
|
10
10
|
import "../../../chunk-FHD4JECV.mjs";
|
|
11
11
|
export {
|
|
12
12
|
ActionExecutionMessage,
|
|
@@ -14,7 +14,6 @@ export {
|
|
|
14
14
|
ImageMessage,
|
|
15
15
|
Message,
|
|
16
16
|
ResultMessage,
|
|
17
|
-
Role,
|
|
18
17
|
TextMessage
|
|
19
18
|
};
|
|
20
19
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
|
-
import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from './langserve-
|
|
2
|
+
import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from './langserve-9fc76ce5.js';
|
|
3
3
|
import { BaseMessageChunk, AIMessage, AIMessageChunk, BaseMessage } from '@langchain/core/messages';
|
|
4
4
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
5
5
|
import { IterableReadableStream, IterableReadableStreamInterface } from '@langchain/core/utils/stream';
|
|
@@ -90,6 +90,7 @@ declare class OpenAIAdapter implements CopilotServiceAdapter {
|
|
|
90
90
|
private _openai;
|
|
91
91
|
private keepSystemRole;
|
|
92
92
|
get openai(): OpenAI;
|
|
93
|
+
get name(): string;
|
|
93
94
|
constructor(params?: OpenAIAdapterParams);
|
|
94
95
|
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
95
96
|
}
|
|
@@ -149,6 +150,7 @@ declare class LangChainAdapter implements CopilotServiceAdapter {
|
|
|
149
150
|
/**
|
|
150
151
|
* To use LangChain as a backend, provide a handler function to the adapter with your custom LangChain logic.
|
|
151
152
|
*/
|
|
153
|
+
get name(): string;
|
|
152
154
|
constructor(options: LangChainAdapterOptions);
|
|
153
155
|
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
154
156
|
}
|
|
@@ -237,6 +239,7 @@ declare class OpenAIAssistantAdapter implements CopilotServiceAdapter {
|
|
|
237
239
|
private fileSearchEnabled;
|
|
238
240
|
private disableParallelToolCalls;
|
|
239
241
|
private keepSystemRole;
|
|
242
|
+
get name(): string;
|
|
240
243
|
constructor(params: OpenAIAssistantAdapterParams);
|
|
241
244
|
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
242
245
|
private submitToolOutputs;
|
|
@@ -273,6 +276,7 @@ declare class UnifyAdapter implements CopilotServiceAdapter {
|
|
|
273
276
|
model: string;
|
|
274
277
|
private start;
|
|
275
278
|
provider: string;
|
|
279
|
+
get name(): string;
|
|
276
280
|
constructor(options?: UnifyAdapterParams);
|
|
277
281
|
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
278
282
|
}
|
|
@@ -319,6 +323,7 @@ declare class GroqAdapter implements CopilotServiceAdapter {
|
|
|
319
323
|
private disableParallelToolCalls;
|
|
320
324
|
private _groq;
|
|
321
325
|
get groq(): Groq;
|
|
326
|
+
get name(): string;
|
|
322
327
|
constructor(params?: GroqAdapterParams);
|
|
323
328
|
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
324
329
|
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import OpenAI from 'openai';
|
|
2
|
+
import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from './langserve-978d5790.js';
|
|
3
|
+
import { BaseMessageChunk, AIMessage, AIMessageChunk, BaseMessage } from '@langchain/core/messages';
|
|
4
|
+
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
5
|
+
import { IterableReadableStream, IterableReadableStreamInterface } from '@langchain/core/utils/stream';
|
|
6
|
+
import { Groq } from 'groq-sdk';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Copilot Runtime adapter for OpenAI.
|
|
10
|
+
*
|
|
11
|
+
* ## Example
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/runtime";
|
|
15
|
+
* import OpenAI from "openai";
|
|
16
|
+
*
|
|
17
|
+
* const copilotKit = new CopilotRuntime();
|
|
18
|
+
*
|
|
19
|
+
* const openai = new OpenAI({
|
|
20
|
+
* organization: "<your-organization-id>", // optional
|
|
21
|
+
* apiKey: "<your-api-key>",
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* return new OpenAIAdapter({ openai });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* ## Example with Azure OpenAI
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/runtime";
|
|
31
|
+
* import OpenAI from "openai";
|
|
32
|
+
*
|
|
33
|
+
* // The name of your Azure OpenAI Instance.
|
|
34
|
+
* // https://learn.microsoft.com/en-us/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal#create-a-resource
|
|
35
|
+
* const instance = "<your instance name>";
|
|
36
|
+
*
|
|
37
|
+
* // Corresponds to your Model deployment within your OpenAI resource, e.g. my-gpt35-16k-deployment
|
|
38
|
+
* // Navigate to the Azure OpenAI Studio to deploy a model.
|
|
39
|
+
* const model = "<your model>";
|
|
40
|
+
*
|
|
41
|
+
* const apiKey = process.env["AZURE_OPENAI_API_KEY"];
|
|
42
|
+
* if (!apiKey) {
|
|
43
|
+
* throw new Error("The AZURE_OPENAI_API_KEY environment variable is missing or empty.");
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
46
|
+
* const copilotKit = new CopilotRuntime();
|
|
47
|
+
*
|
|
48
|
+
* const openai = new OpenAI({
|
|
49
|
+
* apiKey,
|
|
50
|
+
* baseURL: `https://${instance}.openai.azure.com/openai/deployments/${model}`,
|
|
51
|
+
* defaultQuery: { "api-version": "2024-04-01-preview" },
|
|
52
|
+
* defaultHeaders: { "api-key": apiKey },
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* return new OpenAIAdapter({ openai });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
interface OpenAIAdapterParams {
|
|
60
|
+
/**
|
|
61
|
+
* An optional OpenAI instance to use. If not provided, a new instance will be
|
|
62
|
+
* created.
|
|
63
|
+
*/
|
|
64
|
+
openai?: OpenAI;
|
|
65
|
+
/**
|
|
66
|
+
* The model to use.
|
|
67
|
+
*/
|
|
68
|
+
model?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Whether to disable parallel tool calls.
|
|
71
|
+
* You can disable parallel tool calls to force the model to execute tool calls sequentially.
|
|
72
|
+
* This is useful if you want to execute tool calls in a specific order so that the state changes
|
|
73
|
+
* introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
|
|
74
|
+
*
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
disableParallelToolCalls?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Whether to keep the role in system messages as "System".
|
|
80
|
+
* By default, it is converted to "developer", which is used by newer OpenAI models
|
|
81
|
+
*
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
keepSystemRole?: boolean;
|
|
85
|
+
}
|
|
86
|
+
declare class OpenAIAdapter implements CopilotServiceAdapter {
|
|
87
|
+
model: string;
|
|
88
|
+
provider: string;
|
|
89
|
+
private disableParallelToolCalls;
|
|
90
|
+
private _openai;
|
|
91
|
+
private keepSystemRole;
|
|
92
|
+
get openai(): OpenAI;
|
|
93
|
+
get name(): string;
|
|
94
|
+
constructor(params?: OpenAIAdapterParams);
|
|
95
|
+
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
type LangChainBaseMessageChunkStream = IterableReadableStream<BaseMessageChunk>;
|
|
99
|
+
type LangChainAIMessageChunkStream = IterableReadableStreamInterface<AIMessageChunk>;
|
|
100
|
+
type LangChainReturnType = LangChainBaseMessageChunkStream | LangChainAIMessageChunkStream | BaseMessageChunk | string | AIMessage;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Copilot Runtime adapter for LangChain.
|
|
104
|
+
*
|
|
105
|
+
* ## Example
|
|
106
|
+
*
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { CopilotRuntime, LangChainAdapter } from "@copilotkit/runtime";
|
|
109
|
+
* import { ChatOpenAI } from "@langchain/openai";
|
|
110
|
+
*
|
|
111
|
+
* const copilotKit = new CopilotRuntime();
|
|
112
|
+
*
|
|
113
|
+
* const model = new ChatOpenAI({
|
|
114
|
+
* model: "gpt-4o",
|
|
115
|
+
* apiKey: "<your-api-key>",
|
|
116
|
+
* });
|
|
117
|
+
*
|
|
118
|
+
* return new LangChainAdapter({
|
|
119
|
+
* chainFn: async ({ messages, tools }) => {
|
|
120
|
+
* return model.bindTools(tools).stream(messages);
|
|
121
|
+
* // or optionally enable strict mode
|
|
122
|
+
* // return model.bindTools(tools, { strict: true }).stream(messages);
|
|
123
|
+
* }
|
|
124
|
+
* });
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* The asynchronous handler function (`chainFn`) can return any of the following:
|
|
128
|
+
*
|
|
129
|
+
* - A simple `string` response
|
|
130
|
+
* - A LangChain stream (`IterableReadableStream`)
|
|
131
|
+
* - A LangChain `BaseMessageChunk` object
|
|
132
|
+
* - A LangChain `AIMessage` object
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
interface ChainFnParameters {
|
|
136
|
+
model: string;
|
|
137
|
+
messages: BaseMessage[];
|
|
138
|
+
tools: DynamicStructuredTool[];
|
|
139
|
+
threadId?: string;
|
|
140
|
+
runId?: string;
|
|
141
|
+
}
|
|
142
|
+
interface LangChainAdapterOptions {
|
|
143
|
+
/**
|
|
144
|
+
* A function that uses the LangChain API to generate a response.
|
|
145
|
+
*/
|
|
146
|
+
chainFn: (parameters: ChainFnParameters) => Promise<LangChainReturnType>;
|
|
147
|
+
}
|
|
148
|
+
declare class LangChainAdapter implements CopilotServiceAdapter {
|
|
149
|
+
private options;
|
|
150
|
+
/**
|
|
151
|
+
* To use LangChain as a backend, provide a handler function to the adapter with your custom LangChain logic.
|
|
152
|
+
*/
|
|
153
|
+
get name(): string;
|
|
154
|
+
constructor(options: LangChainAdapterOptions);
|
|
155
|
+
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface GoogleGenerativeAIAdapterOptions {
|
|
159
|
+
/**
|
|
160
|
+
* A custom Google Generative AI model to use.
|
|
161
|
+
*/
|
|
162
|
+
model?: string;
|
|
163
|
+
/**
|
|
164
|
+
* The API key to use.
|
|
165
|
+
*/
|
|
166
|
+
apiKey?: string;
|
|
167
|
+
}
|
|
168
|
+
declare class GoogleGenerativeAIAdapter extends LangChainAdapter {
|
|
169
|
+
provider: string;
|
|
170
|
+
model: string;
|
|
171
|
+
constructor(options?: GoogleGenerativeAIAdapterOptions);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Copilot Runtime adapter for the OpenAI Assistant API.
|
|
176
|
+
*
|
|
177
|
+
* ## Example
|
|
178
|
+
*
|
|
179
|
+
* ```ts
|
|
180
|
+
* import { CopilotRuntime, OpenAIAssistantAdapter } from "@copilotkit/runtime";
|
|
181
|
+
* import OpenAI from "openai";
|
|
182
|
+
*
|
|
183
|
+
* const copilotKit = new CopilotRuntime();
|
|
184
|
+
*
|
|
185
|
+
* const openai = new OpenAI({
|
|
186
|
+
* organization: "<your-organization-id>",
|
|
187
|
+
* apiKey: "<your-api-key>",
|
|
188
|
+
* });
|
|
189
|
+
*
|
|
190
|
+
* return new OpenAIAssistantAdapter({
|
|
191
|
+
* openai,
|
|
192
|
+
* assistantId: "<your-assistant-id>",
|
|
193
|
+
* codeInterpreterEnabled: true,
|
|
194
|
+
* fileSearchEnabled: true,
|
|
195
|
+
* });
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
|
|
199
|
+
interface OpenAIAssistantAdapterParams {
|
|
200
|
+
/**
|
|
201
|
+
* The ID of the assistant to use.
|
|
202
|
+
*/
|
|
203
|
+
assistantId: string;
|
|
204
|
+
/**
|
|
205
|
+
* An optional OpenAI instance to use. If not provided, a new instance will be created.
|
|
206
|
+
*/
|
|
207
|
+
openai?: OpenAI;
|
|
208
|
+
/**
|
|
209
|
+
* Whether to enable code interpretation.
|
|
210
|
+
* @default true
|
|
211
|
+
*/
|
|
212
|
+
codeInterpreterEnabled?: boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Whether to enable file search.
|
|
215
|
+
* @default true
|
|
216
|
+
*/
|
|
217
|
+
fileSearchEnabled?: boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Whether to disable parallel tool calls.
|
|
220
|
+
* You can disable parallel tool calls to force the model to execute tool calls sequentially.
|
|
221
|
+
* This is useful if you want to execute tool calls in a specific order so that the state changes
|
|
222
|
+
* introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
|
|
223
|
+
*
|
|
224
|
+
* @default false
|
|
225
|
+
*/
|
|
226
|
+
disableParallelToolCalls?: boolean;
|
|
227
|
+
/**
|
|
228
|
+
* Whether to keep the role in system messages as "System".
|
|
229
|
+
* By default, it is converted to "developer", which is used by newer OpenAI models
|
|
230
|
+
*
|
|
231
|
+
* @default false
|
|
232
|
+
*/
|
|
233
|
+
keepSystemRole?: boolean;
|
|
234
|
+
}
|
|
235
|
+
declare class OpenAIAssistantAdapter implements CopilotServiceAdapter {
|
|
236
|
+
private openai;
|
|
237
|
+
private codeInterpreterEnabled;
|
|
238
|
+
private assistantId;
|
|
239
|
+
private fileSearchEnabled;
|
|
240
|
+
private disableParallelToolCalls;
|
|
241
|
+
private keepSystemRole;
|
|
242
|
+
get name(): string;
|
|
243
|
+
constructor(params: OpenAIAssistantAdapterParams);
|
|
244
|
+
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
245
|
+
private submitToolOutputs;
|
|
246
|
+
private submitUserMessage;
|
|
247
|
+
private streamResponse;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* CopilotKit Adapter for Unify
|
|
252
|
+
*
|
|
253
|
+
* <RequestExample>
|
|
254
|
+
* ```jsx CopilotRuntime Example
|
|
255
|
+
* const copilotKit = new CopilotRuntime();
|
|
256
|
+
* return copilotKit.response(req, new UnifyAdapter());
|
|
257
|
+
* ```
|
|
258
|
+
* </RequestExample>
|
|
259
|
+
*
|
|
260
|
+
* You can easily set the model to use by passing it to the constructor.
|
|
261
|
+
* ```jsx
|
|
262
|
+
* const copilotKit = new CopilotRuntime();
|
|
263
|
+
* return copilotKit.response(
|
|
264
|
+
* req,
|
|
265
|
+
* new UnifyAdapter({ model: "llama-3-8b-chat@fireworks-ai" }),
|
|
266
|
+
* );
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
|
|
270
|
+
interface UnifyAdapterParams {
|
|
271
|
+
apiKey?: string;
|
|
272
|
+
model: string;
|
|
273
|
+
}
|
|
274
|
+
declare class UnifyAdapter implements CopilotServiceAdapter {
|
|
275
|
+
private apiKey;
|
|
276
|
+
model: string;
|
|
277
|
+
private start;
|
|
278
|
+
provider: string;
|
|
279
|
+
get name(): string;
|
|
280
|
+
constructor(options?: UnifyAdapterParams);
|
|
281
|
+
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Copilot Runtime adapter for Groq.
|
|
286
|
+
*
|
|
287
|
+
* ## Example
|
|
288
|
+
*
|
|
289
|
+
* ```ts
|
|
290
|
+
* import { CopilotRuntime, GroqAdapter } from "@copilotkit/runtime";
|
|
291
|
+
* import { Groq } from "groq-sdk";
|
|
292
|
+
*
|
|
293
|
+
* const groq = new Groq({ apiKey: process.env["GROQ_API_KEY"] });
|
|
294
|
+
*
|
|
295
|
+
* const copilotKit = new CopilotRuntime();
|
|
296
|
+
*
|
|
297
|
+
* return new GroqAdapter({ groq, model: "<model-name>" });
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
|
|
301
|
+
interface GroqAdapterParams {
|
|
302
|
+
/**
|
|
303
|
+
* An optional Groq instance to use.
|
|
304
|
+
*/
|
|
305
|
+
groq?: Groq;
|
|
306
|
+
/**
|
|
307
|
+
* The model to use.
|
|
308
|
+
*/
|
|
309
|
+
model?: string;
|
|
310
|
+
/**
|
|
311
|
+
* Whether to disable parallel tool calls.
|
|
312
|
+
* You can disable parallel tool calls to force the model to execute tool calls sequentially.
|
|
313
|
+
* This is useful if you want to execute tool calls in a specific order so that the state changes
|
|
314
|
+
* introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
|
|
315
|
+
*
|
|
316
|
+
* @default false
|
|
317
|
+
*/
|
|
318
|
+
disableParallelToolCalls?: boolean;
|
|
319
|
+
}
|
|
320
|
+
declare class GroqAdapter implements CopilotServiceAdapter {
|
|
321
|
+
model: string;
|
|
322
|
+
provider: string;
|
|
323
|
+
private disableParallelToolCalls;
|
|
324
|
+
private _groq;
|
|
325
|
+
get groq(): Groq;
|
|
326
|
+
get name(): string;
|
|
327
|
+
constructor(params?: GroqAdapterParams);
|
|
328
|
+
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export { GoogleGenerativeAIAdapter as G, LangChainAdapter as L, OpenAIAdapterParams as O, UnifyAdapterParams as U, OpenAIAdapter as a, OpenAIAssistantAdapterParams as b, OpenAIAssistantAdapter as c, UnifyAdapter as d, GroqAdapterParams as e, GroqAdapter as f };
|