@copilotkit/runtime 1.50.0-beta.8 → 1.50.0-beta.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/CHANGELOG.md +11 -0
- package/dist/chunk-2OZAGFV3.mjs +43 -0
- package/dist/chunk-2OZAGFV3.mjs.map +1 -0
- package/dist/chunk-62NE5S6M.mjs +226 -0
- package/dist/chunk-62NE5S6M.mjs.map +1 -0
- package/dist/chunk-6XRUR5UK.mjs +1 -0
- package/dist/chunk-6XRUR5UK.mjs.map +1 -0
- package/dist/chunk-AMUJQ6IR.mjs +50 -0
- package/dist/chunk-AMUJQ6IR.mjs.map +1 -0
- package/dist/chunk-BJEYMRDD.mjs +25 -0
- package/dist/chunk-BJEYMRDD.mjs.map +1 -0
- package/dist/chunk-DZV4ZIAR.mjs +3063 -0
- package/dist/chunk-DZV4ZIAR.mjs.map +1 -0
- package/dist/chunk-FHD4JECV.mjs +33 -0
- package/dist/chunk-FHD4JECV.mjs.map +1 -0
- package/dist/chunk-FMU55SEU.mjs +25 -0
- package/dist/chunk-FMU55SEU.mjs.map +1 -0
- package/dist/chunk-OWIGJONH.mjs +275 -0
- package/dist/chunk-OWIGJONH.mjs.map +1 -0
- package/dist/chunk-SBCOROE4.mjs +1112 -0
- package/dist/chunk-SBCOROE4.mjs.map +1 -0
- package/dist/chunk-TTUAEJLD.mjs +617 -0
- package/dist/chunk-TTUAEJLD.mjs.map +1 -0
- package/dist/chunk-XWBDEXDA.mjs +153 -0
- package/dist/chunk-XWBDEXDA.mjs.map +1 -0
- package/dist/chunk-Z752VE75.mjs +74 -0
- package/dist/chunk-Z752VE75.mjs.map +1 -0
- package/dist/graphql/message-conversion/index.d.ts +18 -0
- package/dist/graphql/message-conversion/index.js +725 -0
- package/dist/graphql/message-conversion/index.js.map +1 -0
- package/dist/graphql/message-conversion/index.mjs +245 -0
- package/dist/graphql/message-conversion/index.mjs.map +1 -0
- package/dist/graphql/types/base/index.d.ts +6 -0
- package/dist/graphql/types/base/index.js +63 -0
- package/dist/graphql/types/base/index.js.map +1 -0
- package/dist/graphql/types/base/index.mjs +8 -0
- package/dist/graphql/types/base/index.mjs.map +1 -0
- package/dist/graphql/types/converted/index.d.ts +2 -0
- package/dist/graphql/types/converted/index.js +294 -0
- package/dist/graphql/types/converted/index.js.map +1 -0
- package/dist/graphql/types/converted/index.mjs +20 -0
- package/dist/graphql/types/converted/index.mjs.map +1 -0
- package/dist/groq-adapter-50bc6e4a.d.ts +326 -0
- package/dist/index-adbd78f1.d.ts +154 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/langserve-74a52292.d.ts +242 -0
- package/dist/lib/cloud/index.d.ts +6 -0
- package/dist/lib/cloud/index.js +18 -0
- package/dist/lib/cloud/index.js.map +1 -0
- package/dist/lib/cloud/index.mjs +1 -0
- package/dist/lib/cloud/index.mjs.map +1 -0
- package/dist/lib/index.d.ts +266 -0
- package/dist/lib/index.js +4944 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/index.mjs +74 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/integrations/index.d.ts +28 -0
- package/dist/lib/integrations/index.js +3024 -0
- package/dist/lib/integrations/index.js.map +1 -0
- package/dist/lib/integrations/index.mjs +36 -0
- package/dist/lib/integrations/index.mjs.map +1 -0
- package/dist/lib/integrations/nest/index.d.ts +16 -0
- package/dist/lib/integrations/nest/index.js +2937 -0
- package/dist/lib/integrations/nest/index.js.map +1 -0
- package/dist/lib/integrations/nest/index.mjs +13 -0
- package/dist/lib/integrations/nest/index.mjs.map +1 -0
- package/dist/lib/integrations/node-express/index.d.ts +16 -0
- package/dist/lib/integrations/node-express/index.js +2937 -0
- package/dist/lib/integrations/node-express/index.js.map +1 -0
- package/dist/lib/integrations/node-express/index.mjs +13 -0
- package/dist/lib/integrations/node-express/index.mjs.map +1 -0
- package/dist/lib/integrations/node-http/index.d.ts +16 -0
- package/dist/lib/integrations/node-http/index.js +2923 -0
- package/dist/lib/integrations/node-http/index.js.map +1 -0
- package/dist/lib/integrations/node-http/index.mjs +12 -0
- package/dist/lib/integrations/node-http/index.mjs.map +1 -0
- package/dist/service-adapters/index.d.ts +166 -0
- package/dist/service-adapters/index.js +1800 -0
- package/dist/service-adapters/index.js.map +1 -0
- package/dist/service-adapters/index.mjs +36 -0
- package/dist/service-adapters/index.mjs.map +1 -0
- package/dist/service-adapters/shared/index.d.ts +9 -0
- package/dist/service-adapters/shared/index.js +72 -0
- package/dist/service-adapters/shared/index.js.map +1 -0
- package/dist/service-adapters/shared/index.mjs +8 -0
- package/dist/service-adapters/shared/index.mjs.map +1 -0
- package/dist/shared-f6d43ef8.d.ts +446 -0
- package/dist/utils/index.d.ts +65 -0
- package/dist/utils/index.js +175 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +12 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/graphql/types/converted/index.ts
|
|
21
|
+
var converted_exports = {};
|
|
22
|
+
__export(converted_exports, {
|
|
23
|
+
ActionExecutionMessage: () => ActionExecutionMessage,
|
|
24
|
+
AgentStateMessage: () => AgentStateMessage,
|
|
25
|
+
ImageMessage: () => ImageMessage,
|
|
26
|
+
Message: () => Message,
|
|
27
|
+
ResultMessage: () => ResultMessage,
|
|
28
|
+
Role: () => Role,
|
|
29
|
+
TextMessage: () => TextMessage
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(converted_exports);
|
|
32
|
+
var import_shared = require("@copilotkit/shared");
|
|
33
|
+
|
|
34
|
+
// src/graphql/types/enums.ts
|
|
35
|
+
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
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
74
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
75
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
76
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
77
|
+
else
|
|
78
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
79
|
+
if (d = decorators[i])
|
|
80
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
81
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
82
|
+
}
|
|
83
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
84
|
+
function _ts_metadata(k, v) {
|
|
85
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
86
|
+
return Reflect.metadata(k, v);
|
|
87
|
+
}
|
|
88
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
89
|
+
var MessageStatusCode;
|
|
90
|
+
(function(MessageStatusCode2) {
|
|
91
|
+
MessageStatusCode2["Pending"] = "pending";
|
|
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;
|
|
100
|
+
};
|
|
101
|
+
__name(BaseMessageStatus, "BaseMessageStatus");
|
|
102
|
+
_ts_decorate([
|
|
103
|
+
(0, import_type_graphql2.Field)(() => MessageStatusCode),
|
|
104
|
+
_ts_metadata("design:type", String)
|
|
105
|
+
], BaseMessageStatus.prototype, "code", void 0);
|
|
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");
|
|
128
|
+
_ts_decorate([
|
|
129
|
+
(0, import_type_graphql2.Field)(() => String),
|
|
130
|
+
_ts_metadata("design:type", String)
|
|
131
|
+
], FailedMessageStatus.prototype, "reason", void 0);
|
|
132
|
+
FailedMessageStatus = _ts_decorate([
|
|
133
|
+
(0, import_type_graphql2.ObjectType)()
|
|
134
|
+
], FailedMessageStatus);
|
|
135
|
+
var MessageStatusUnion = (0, import_type_graphql2.createUnionType)({
|
|
136
|
+
name: "MessageStatus",
|
|
137
|
+
types: () => [
|
|
138
|
+
PendingMessageStatus,
|
|
139
|
+
SuccessMessageStatus,
|
|
140
|
+
FailedMessageStatus
|
|
141
|
+
]
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// src/graphql/types/converted/index.ts
|
|
145
|
+
var Message = class {
|
|
146
|
+
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
|
+
isTextMessage() {
|
|
159
|
+
return this.type === "TextMessage";
|
|
160
|
+
}
|
|
161
|
+
isActionExecutionMessage() {
|
|
162
|
+
return this.type === "ActionExecutionMessage";
|
|
163
|
+
}
|
|
164
|
+
isResultMessage() {
|
|
165
|
+
return this.type === "ResultMessage";
|
|
166
|
+
}
|
|
167
|
+
isAgentStateMessage() {
|
|
168
|
+
return this.type === "AgentStateMessage";
|
|
169
|
+
}
|
|
170
|
+
isImageMessage() {
|
|
171
|
+
return this.type === "ImageMessage";
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
__name(Message, "Message");
|
|
175
|
+
var Role = MessageRole;
|
|
176
|
+
var TextMessage = class extends Message {
|
|
177
|
+
content;
|
|
178
|
+
parentMessageId;
|
|
179
|
+
role;
|
|
180
|
+
type = "TextMessage";
|
|
181
|
+
constructor(props) {
|
|
182
|
+
super(props);
|
|
183
|
+
this.type = "TextMessage";
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
__name(TextMessage, "TextMessage");
|
|
187
|
+
var ActionExecutionMessage = class extends Message {
|
|
188
|
+
type = "ActionExecutionMessage";
|
|
189
|
+
name;
|
|
190
|
+
arguments;
|
|
191
|
+
parentMessageId;
|
|
192
|
+
};
|
|
193
|
+
__name(ActionExecutionMessage, "ActionExecutionMessage");
|
|
194
|
+
var ResultMessage = class extends Message {
|
|
195
|
+
type = "ResultMessage";
|
|
196
|
+
actionExecutionId;
|
|
197
|
+
actionName;
|
|
198
|
+
result;
|
|
199
|
+
static encodeResult(result, error) {
|
|
200
|
+
const errorObj = error ? typeof error === "string" ? {
|
|
201
|
+
code: "ERROR",
|
|
202
|
+
message: error
|
|
203
|
+
} : error instanceof Error ? {
|
|
204
|
+
code: "ERROR",
|
|
205
|
+
message: error.message
|
|
206
|
+
} : error : void 0;
|
|
207
|
+
if (errorObj) {
|
|
208
|
+
return JSON.stringify({
|
|
209
|
+
error: errorObj,
|
|
210
|
+
result: result || ""
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (result === void 0) {
|
|
214
|
+
return "";
|
|
215
|
+
}
|
|
216
|
+
return typeof result === "string" ? result : JSON.stringify(result);
|
|
217
|
+
}
|
|
218
|
+
static decodeResult(result) {
|
|
219
|
+
if (!result) {
|
|
220
|
+
return {
|
|
221
|
+
result: ""
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
const parsed = JSON.parse(result);
|
|
226
|
+
if (parsed && typeof parsed === "object") {
|
|
227
|
+
if ("error" in parsed) {
|
|
228
|
+
return {
|
|
229
|
+
error: parsed.error,
|
|
230
|
+
result: parsed.result || ""
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
result: JSON.stringify(parsed)
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
result
|
|
239
|
+
};
|
|
240
|
+
} catch (e) {
|
|
241
|
+
return {
|
|
242
|
+
result
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
hasError() {
|
|
247
|
+
try {
|
|
248
|
+
const { error } = ResultMessage.decodeResult(this.result);
|
|
249
|
+
return !!error;
|
|
250
|
+
} catch {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
getError() {
|
|
255
|
+
try {
|
|
256
|
+
const { error } = ResultMessage.decodeResult(this.result);
|
|
257
|
+
return error;
|
|
258
|
+
} catch {
|
|
259
|
+
return void 0;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
__name(ResultMessage, "ResultMessage");
|
|
264
|
+
var AgentStateMessage = class extends Message {
|
|
265
|
+
type = "AgentStateMessage";
|
|
266
|
+
threadId;
|
|
267
|
+
agentName;
|
|
268
|
+
nodeName;
|
|
269
|
+
runId;
|
|
270
|
+
active;
|
|
271
|
+
role;
|
|
272
|
+
state;
|
|
273
|
+
running;
|
|
274
|
+
};
|
|
275
|
+
__name(AgentStateMessage, "AgentStateMessage");
|
|
276
|
+
var ImageMessage = class extends Message {
|
|
277
|
+
type = "ImageMessage";
|
|
278
|
+
format;
|
|
279
|
+
bytes;
|
|
280
|
+
role;
|
|
281
|
+
parentMessageId;
|
|
282
|
+
};
|
|
283
|
+
__name(ImageMessage, "ImageMessage");
|
|
284
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
285
|
+
0 && (module.exports = {
|
|
286
|
+
ActionExecutionMessage,
|
|
287
|
+
AgentStateMessage,
|
|
288
|
+
ImageMessage,
|
|
289
|
+
Message,
|
|
290
|
+
ResultMessage,
|
|
291
|
+
Role,
|
|
292
|
+
TextMessage
|
|
293
|
+
});
|
|
294
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;oBAAyB;;;ACAzB,0BAAiC;;UAErBA,cAAAA;;;;;;GAAAA,gBAAAA,cAAAA,CAAAA,EAAAA;;UAQAC,qBAAAA;;;;;;GAAAA,uBAAAA,qBAAAA,CAAAA,EAAAA;;UAQAC,0BAAAA;;;;GAAAA,4BAAAA,0BAAAA,CAAAA,EAAAA;IAMZC,sCAAiBH,aAAa;EAC5BI,MAAM;EACNC,aAAa;AACf,CAAA;IAEAF,sCAAiBF,oBAAoB;EACnCG,MAAM;EACNC,aAAa;AACf,CAAA;IAEAF,sCAAiBD,yBAAyB;EACxCE,MAAM;EACNC,aAAa;AACf,CAAA;;;ACrCA,IAAAC,uBAAqE;;;;;;;;;;;;;;;;;;UAEzDC,oBAAAA;;;;GAAAA,sBAAAA,oBAAAA,CAAAA,EAAAA;IAMZC,uCAAiBD,mBAAmB;EAClCE,MAAM;AACR,CAAA;AAGO,IAAMC,oBAAN,MAAMA;EAEXC;AACF;AAHaD;;MACVE,4BAAM,MAAML,iBAAAA;;GADFG,kBAAAA,WAAAA,QAAAA,MAAAA;AAAAA,oBAAAA,aAAAA;MADZG,iCAAAA;GACYH,iBAAAA;AAMN,IAAMI,uBAAN,cAAmCJ,kBAAAA;EACxCC,OAAAA;AACF;AAFaG;AAAAA,uBAAAA,aAAAA;MADZD,iCAAAA;GACYC,oBAAAA;AAKN,IAAMC,uBAAN,cAAmCL,kBAAAA;EACxCC,OAAAA;AACF;AAFaI;AAAAA,uBAAAA,aAAAA;MADZF,iCAAAA;GACYE,oBAAAA;AAKN,IAAMC,sBAAN,cAAkCN,kBAAAA;EACvCC,OAAAA;EAGAM;AACF;AALaD;;MAGVJ,4BAAM,MAAMM,MAAAA;;GAHFF,oBAAAA,WAAAA,UAAAA,MAAAA;AAAAA,sBAAAA,aAAAA;MADZH,iCAAAA;GACYG,mBAAAA;AAON,IAAMG,yBAAqBC,sCAAgB;EAChDX,MAAM;EACNY,OAAO,MAAM;IAACP;IAAsBC;IAAsBC;;AAC5D,CAAA;;;AFnBO,IAAMM,UAAN,MAAMA;EACXC;EACAC;EACAC;EACAC;EAEAC,YAAYC,OAAY;AACtBA,UAAMJ,OAANI,MAAMJ,SAAOK,wBAAAA;AACbD,UAAMF,WAANE,MAAMF,SAAW;MAAEI,MAAMC,kBAAkBC;IAAQ;AACnDJ,UAAMH,cAANG,MAAMH,YAAc,oBAAIQ,KAAAA;AACxBC,WAAOC,OAAO,MAAMP,KAAAA;EACtB;EAEAQ,gBAAqC;AACnC,WAAO,KAAKb,SAAS;EACvB;EAEAc,2BAA2D;AACzD,WAAO,KAAKd,SAAS;EACvB;EAEAe,kBAAyC;AACvC,WAAO,KAAKf,SAAS;EACvB;EAEAgB,sBAAiD;AAC/C,WAAO,KAAKhB,SAAS;EACvB;EAEAiB,iBAAuC;AACrC,WAAO,KAAKjB,SAAS;EACvB;AACF;AAhCaD;AAmCN,IAAMmB,OAAOC;AAOb,IAAMC,cAAN,cAA0BrB,QAAAA;EAC/BsB;EACAC;EACAC;EACAvB,OAAO;EAEPI,YAAYC,OAAsC;AAChD,UAAMA,KAAAA;AACN,SAAKL,OAAO;EACd;AACF;AAVaoB;AAYN,IAAMI,yBAAN,cACGzB,QAAAA;EAGRC,OAAoB;EACpByB;EACAC;EACAJ;AACF;AARaE;AAUN,IAAMG,gBAAN,cAA4B5B,QAAAA;EACjCC,OAAoB;EACpB4B;EACAC;EACAC;EAEA,OAAOC,aACLD,QACAE,OACQ;AACR,UAAMC,WAAWD,QACb,OAAOA,UAAU,WACf;MAAEzB,MAAM;MAAS2B,SAASF;IAAM,IAChCA,iBAAiBG,QACf;MAAE5B,MAAM;MAAS2B,SAASF,MAAME;IAAQ,IACxCF,QACJI;AAEJ,QAAIH,UAAU;AACZ,aAAOI,KAAKC,UAAU;QACpBN,OAAOC;QACPH,QAAQA,UAAU;MACpB,CAAA;IACF;AACA,QAAIA,WAAWM,QAAW;AACxB,aAAO;IACT;AACA,WAAO,OAAON,WAAW,WAAWA,SAASO,KAAKC,UAAUR,MAAAA;EAC9D;EAEA,OAAOS,aAAaT,QAGlB;AACA,QAAI,CAACA,QAAQ;AACX,aAAO;QAAEA,QAAQ;MAAG;IACtB;AACA,QAAI;AACF,YAAMU,SAASH,KAAKI,MAAMX,MAAAA;AAC1B,UAAIU,UAAU,OAAOA,WAAW,UAAU;AACxC,YAAI,WAAWA,QAAQ;AACrB,iBAAO;YACLR,OAAOQ,OAAOR;YACdF,QAAQU,OAAOV,UAAU;UAC3B;QACF;AACA,eAAO;UAAEA,QAAQO,KAAKC,UAAUE,MAAAA;QAAQ;MAC1C;AACA,aAAO;QAAEV;MAAO;IAClB,SAASY,GAAP;AACA,aAAO;QAAEZ;MAAO;IAClB;EACF;EAEAa,WAAoB;AAClB,QAAI;AACF,YAAM,EAAEX,MAAK,IAAKL,cAAcY,aAAa,KAAKT,MAAM;AACxD,aAAO,CAAC,CAACE;IACX,QAAE;AACA,aAAO;IACT;EACF;EAEAY,WAA0D;AACxD,QAAI;AACF,YAAM,EAAEZ,MAAK,IAAKL,cAAcY,aAAa,KAAKT,MAAM;AACxD,aAAOE;IACT,QAAE;AACA,aAAOI;IACT;EACF;AACF;AAvEaT;AAyEN,IAAMkB,oBAAN,cAAgC9C,QAAAA;EACrCC,OAAoB;EACpB8C;EACAC;EACAC;EACAC;EACAC;EACA3B;EACA4B;EACAC;AACF;AAVaP;AAYN,IAAMQ,eAAN,cAA2BtD,QAAAA;EAChCC,OAAoB;EACpBsD;EACAC;EACAhC;EACAD;AACF;AANa+B;","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"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActionExecutionMessage,
|
|
3
|
+
AgentStateMessage,
|
|
4
|
+
ImageMessage,
|
|
5
|
+
Message,
|
|
6
|
+
ResultMessage,
|
|
7
|
+
Role,
|
|
8
|
+
TextMessage
|
|
9
|
+
} from "../../../chunk-OWIGJONH.mjs";
|
|
10
|
+
import "../../../chunk-FHD4JECV.mjs";
|
|
11
|
+
export {
|
|
12
|
+
ActionExecutionMessage,
|
|
13
|
+
AgentStateMessage,
|
|
14
|
+
ImageMessage,
|
|
15
|
+
Message,
|
|
16
|
+
ResultMessage,
|
|
17
|
+
Role,
|
|
18
|
+
TextMessage
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import OpenAI from 'openai';
|
|
2
|
+
import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from './langserve-74a52292.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
|
+
constructor(params?: OpenAIAdapterParams);
|
|
94
|
+
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
type LangChainBaseMessageChunkStream = IterableReadableStream<BaseMessageChunk>;
|
|
98
|
+
type LangChainAIMessageChunkStream = IterableReadableStreamInterface<AIMessageChunk>;
|
|
99
|
+
type LangChainReturnType = LangChainBaseMessageChunkStream | LangChainAIMessageChunkStream | BaseMessageChunk | string | AIMessage;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Copilot Runtime adapter for LangChain.
|
|
103
|
+
*
|
|
104
|
+
* ## Example
|
|
105
|
+
*
|
|
106
|
+
* ```ts
|
|
107
|
+
* import { CopilotRuntime, LangChainAdapter } from "@copilotkit/runtime";
|
|
108
|
+
* import { ChatOpenAI } from "@langchain/openai";
|
|
109
|
+
*
|
|
110
|
+
* const copilotKit = new CopilotRuntime();
|
|
111
|
+
*
|
|
112
|
+
* const model = new ChatOpenAI({
|
|
113
|
+
* model: "gpt-4o",
|
|
114
|
+
* apiKey: "<your-api-key>",
|
|
115
|
+
* });
|
|
116
|
+
*
|
|
117
|
+
* return new LangChainAdapter({
|
|
118
|
+
* chainFn: async ({ messages, tools }) => {
|
|
119
|
+
* return model.bindTools(tools).stream(messages);
|
|
120
|
+
* // or optionally enable strict mode
|
|
121
|
+
* // return model.bindTools(tools, { strict: true }).stream(messages);
|
|
122
|
+
* }
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* The asynchronous handler function (`chainFn`) can return any of the following:
|
|
127
|
+
*
|
|
128
|
+
* - A simple `string` response
|
|
129
|
+
* - A LangChain stream (`IterableReadableStream`)
|
|
130
|
+
* - A LangChain `BaseMessageChunk` object
|
|
131
|
+
* - A LangChain `AIMessage` object
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
interface ChainFnParameters {
|
|
135
|
+
model: string;
|
|
136
|
+
messages: BaseMessage[];
|
|
137
|
+
tools: DynamicStructuredTool[];
|
|
138
|
+
threadId?: string;
|
|
139
|
+
runId?: string;
|
|
140
|
+
}
|
|
141
|
+
interface LangChainAdapterOptions {
|
|
142
|
+
/**
|
|
143
|
+
* A function that uses the LangChain API to generate a response.
|
|
144
|
+
*/
|
|
145
|
+
chainFn: (parameters: ChainFnParameters) => Promise<LangChainReturnType>;
|
|
146
|
+
}
|
|
147
|
+
declare class LangChainAdapter implements CopilotServiceAdapter {
|
|
148
|
+
private options;
|
|
149
|
+
/**
|
|
150
|
+
* To use LangChain as a backend, provide a handler function to the adapter with your custom LangChain logic.
|
|
151
|
+
*/
|
|
152
|
+
constructor(options: LangChainAdapterOptions);
|
|
153
|
+
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
interface GoogleGenerativeAIAdapterOptions {
|
|
157
|
+
/**
|
|
158
|
+
* A custom Google Generative AI model to use.
|
|
159
|
+
*/
|
|
160
|
+
model?: string;
|
|
161
|
+
/**
|
|
162
|
+
* The API key to use.
|
|
163
|
+
*/
|
|
164
|
+
apiKey?: string;
|
|
165
|
+
}
|
|
166
|
+
declare class GoogleGenerativeAIAdapter extends LangChainAdapter {
|
|
167
|
+
provider: string;
|
|
168
|
+
model: string;
|
|
169
|
+
constructor(options?: GoogleGenerativeAIAdapterOptions);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Copilot Runtime adapter for the OpenAI Assistant API.
|
|
174
|
+
*
|
|
175
|
+
* ## Example
|
|
176
|
+
*
|
|
177
|
+
* ```ts
|
|
178
|
+
* import { CopilotRuntime, OpenAIAssistantAdapter } from "@copilotkit/runtime";
|
|
179
|
+
* import OpenAI from "openai";
|
|
180
|
+
*
|
|
181
|
+
* const copilotKit = new CopilotRuntime();
|
|
182
|
+
*
|
|
183
|
+
* const openai = new OpenAI({
|
|
184
|
+
* organization: "<your-organization-id>",
|
|
185
|
+
* apiKey: "<your-api-key>",
|
|
186
|
+
* });
|
|
187
|
+
*
|
|
188
|
+
* return new OpenAIAssistantAdapter({
|
|
189
|
+
* openai,
|
|
190
|
+
* assistantId: "<your-assistant-id>",
|
|
191
|
+
* codeInterpreterEnabled: true,
|
|
192
|
+
* fileSearchEnabled: true,
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
interface OpenAIAssistantAdapterParams {
|
|
198
|
+
/**
|
|
199
|
+
* The ID of the assistant to use.
|
|
200
|
+
*/
|
|
201
|
+
assistantId: string;
|
|
202
|
+
/**
|
|
203
|
+
* An optional OpenAI instance to use. If not provided, a new instance will be created.
|
|
204
|
+
*/
|
|
205
|
+
openai?: OpenAI;
|
|
206
|
+
/**
|
|
207
|
+
* Whether to enable code interpretation.
|
|
208
|
+
* @default true
|
|
209
|
+
*/
|
|
210
|
+
codeInterpreterEnabled?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Whether to enable file search.
|
|
213
|
+
* @default true
|
|
214
|
+
*/
|
|
215
|
+
fileSearchEnabled?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Whether to disable parallel tool calls.
|
|
218
|
+
* You can disable parallel tool calls to force the model to execute tool calls sequentially.
|
|
219
|
+
* This is useful if you want to execute tool calls in a specific order so that the state changes
|
|
220
|
+
* introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
|
|
221
|
+
*
|
|
222
|
+
* @default false
|
|
223
|
+
*/
|
|
224
|
+
disableParallelToolCalls?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Whether to keep the role in system messages as "System".
|
|
227
|
+
* By default, it is converted to "developer", which is used by newer OpenAI models
|
|
228
|
+
*
|
|
229
|
+
* @default false
|
|
230
|
+
*/
|
|
231
|
+
keepSystemRole?: boolean;
|
|
232
|
+
}
|
|
233
|
+
declare class OpenAIAssistantAdapter implements CopilotServiceAdapter {
|
|
234
|
+
private openai;
|
|
235
|
+
private codeInterpreterEnabled;
|
|
236
|
+
private assistantId;
|
|
237
|
+
private fileSearchEnabled;
|
|
238
|
+
private disableParallelToolCalls;
|
|
239
|
+
private keepSystemRole;
|
|
240
|
+
constructor(params: OpenAIAssistantAdapterParams);
|
|
241
|
+
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
242
|
+
private submitToolOutputs;
|
|
243
|
+
private submitUserMessage;
|
|
244
|
+
private streamResponse;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* CopilotKit Adapter for Unify
|
|
249
|
+
*
|
|
250
|
+
* <RequestExample>
|
|
251
|
+
* ```jsx CopilotRuntime Example
|
|
252
|
+
* const copilotKit = new CopilotRuntime();
|
|
253
|
+
* return copilotKit.response(req, new UnifyAdapter());
|
|
254
|
+
* ```
|
|
255
|
+
* </RequestExample>
|
|
256
|
+
*
|
|
257
|
+
* You can easily set the model to use by passing it to the constructor.
|
|
258
|
+
* ```jsx
|
|
259
|
+
* const copilotKit = new CopilotRuntime();
|
|
260
|
+
* return copilotKit.response(
|
|
261
|
+
* req,
|
|
262
|
+
* new UnifyAdapter({ model: "llama-3-8b-chat@fireworks-ai" }),
|
|
263
|
+
* );
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
|
|
267
|
+
interface UnifyAdapterParams {
|
|
268
|
+
apiKey?: string;
|
|
269
|
+
model: string;
|
|
270
|
+
}
|
|
271
|
+
declare class UnifyAdapter implements CopilotServiceAdapter {
|
|
272
|
+
private apiKey;
|
|
273
|
+
model: string;
|
|
274
|
+
private start;
|
|
275
|
+
provider: string;
|
|
276
|
+
constructor(options?: UnifyAdapterParams);
|
|
277
|
+
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Copilot Runtime adapter for Groq.
|
|
282
|
+
*
|
|
283
|
+
* ## Example
|
|
284
|
+
*
|
|
285
|
+
* ```ts
|
|
286
|
+
* import { CopilotRuntime, GroqAdapter } from "@copilotkit/runtime";
|
|
287
|
+
* import { Groq } from "groq-sdk";
|
|
288
|
+
*
|
|
289
|
+
* const groq = new Groq({ apiKey: process.env["GROQ_API_KEY"] });
|
|
290
|
+
*
|
|
291
|
+
* const copilotKit = new CopilotRuntime();
|
|
292
|
+
*
|
|
293
|
+
* return new GroqAdapter({ groq, model: "<model-name>" });
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
|
|
297
|
+
interface GroqAdapterParams {
|
|
298
|
+
/**
|
|
299
|
+
* An optional Groq instance to use.
|
|
300
|
+
*/
|
|
301
|
+
groq?: Groq;
|
|
302
|
+
/**
|
|
303
|
+
* The model to use.
|
|
304
|
+
*/
|
|
305
|
+
model?: string;
|
|
306
|
+
/**
|
|
307
|
+
* Whether to disable parallel tool calls.
|
|
308
|
+
* You can disable parallel tool calls to force the model to execute tool calls sequentially.
|
|
309
|
+
* This is useful if you want to execute tool calls in a specific order so that the state changes
|
|
310
|
+
* introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
|
|
311
|
+
*
|
|
312
|
+
* @default false
|
|
313
|
+
*/
|
|
314
|
+
disableParallelToolCalls?: boolean;
|
|
315
|
+
}
|
|
316
|
+
declare class GroqAdapter implements CopilotServiceAdapter {
|
|
317
|
+
model: string;
|
|
318
|
+
provider: string;
|
|
319
|
+
private disableParallelToolCalls;
|
|
320
|
+
private _groq;
|
|
321
|
+
get groq(): Groq;
|
|
322
|
+
constructor(params?: GroqAdapterParams);
|
|
323
|
+
process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
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 };
|