@botpress/vai 0.0.1-beta.1
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/.env +3 -0
- package/README.md +163 -0
- package/dist/index.cjs +506 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +473 -0
- package/dist/index.d.ts +473 -0
- package/dist/index.js +476 -0
- package/dist/index.js.map +1 -0
- package/ensure-env.cjs +9 -0
- package/package.json +45 -0
- package/src/assertions/check.ts +28 -0
- package/src/assertions/extension.ts +51 -0
- package/src/assertions/extract.ts +39 -0
- package/src/assertions/filter.ts +86 -0
- package/src/assertions/rate.ts +40 -0
- package/src/context.ts +65 -0
- package/src/hooks/setEvaluator.ts +13 -0
- package/src/hooks/setupClient.ts +6 -0
- package/src/index.ts +9 -0
- package/src/models.ts +394 -0
- package/src/scripts/update-models.ts +76 -0
- package/src/scripts/update-types.ts +59 -0
- package/src/sdk-interfaces/llm/generateContent.ts +127 -0
- package/src/sdk-interfaces/llm/listLanguageModels.ts +19 -0
- package/src/task/compare.ts +72 -0
- package/src/utils/asyncAssertion.ts +40 -0
- package/src/utils/deferred.ts +20 -0
- package/src/utils/predictJson.ts +114 -0
- package/tsconfig.json +28 -0
- package/tsup.config.ts +16 -0
- package/vitest.config.ts +9 -0
- package/vitest.setup.ts +13 -0
package/src/models.ts
ADDED
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
|
|
2
|
+
// This file is generated. Do not edit it manually.
|
|
3
|
+
// See 'scripts/update-models.ts'
|
|
4
|
+
|
|
5
|
+
/* eslint-disable */
|
|
6
|
+
/* tslint:disable */
|
|
7
|
+
|
|
8
|
+
export const Models = [
|
|
9
|
+
{
|
|
10
|
+
"id": "anthropic__claude-3-haiku-20240307",
|
|
11
|
+
"name": "Claude 3 Haiku",
|
|
12
|
+
"integration": "anthropic",
|
|
13
|
+
"input": {
|
|
14
|
+
"maxTokens": 200000
|
|
15
|
+
},
|
|
16
|
+
"output": {
|
|
17
|
+
"maxTokens": 4096
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"id": "anthropic__claude-3-5-sonnet-20240620",
|
|
22
|
+
"name": "Claude 3.5 Sonnet",
|
|
23
|
+
"integration": "anthropic",
|
|
24
|
+
"input": {
|
|
25
|
+
"maxTokens": 200000
|
|
26
|
+
},
|
|
27
|
+
"output": {
|
|
28
|
+
"maxTokens": 4096
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": "cerebras__llama3.1-70b",
|
|
33
|
+
"name": "Llama 3.1 70B",
|
|
34
|
+
"integration": "cerebras",
|
|
35
|
+
"input": {
|
|
36
|
+
"maxTokens": 8192
|
|
37
|
+
},
|
|
38
|
+
"output": {
|
|
39
|
+
"maxTokens": 8192
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "cerebras__llama3.1-8b",
|
|
44
|
+
"name": "Llama 3.1 8B",
|
|
45
|
+
"integration": "cerebras",
|
|
46
|
+
"input": {
|
|
47
|
+
"maxTokens": 8192
|
|
48
|
+
},
|
|
49
|
+
"output": {
|
|
50
|
+
"maxTokens": 8192
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "fireworks-ai__accounts/fireworks/models/deepseek-coder-v2-instruct",
|
|
55
|
+
"name": "DeepSeek Coder V2 Instruct",
|
|
56
|
+
"integration": "fireworks-ai",
|
|
57
|
+
"input": {
|
|
58
|
+
"maxTokens": 131072
|
|
59
|
+
},
|
|
60
|
+
"output": {
|
|
61
|
+
"maxTokens": 131072
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"id": "fireworks-ai__accounts/fireworks/models/deepseek-coder-v2-lite-instruct",
|
|
66
|
+
"name": "DeepSeek Coder V2 Lite",
|
|
67
|
+
"integration": "fireworks-ai",
|
|
68
|
+
"input": {
|
|
69
|
+
"maxTokens": 163840
|
|
70
|
+
},
|
|
71
|
+
"output": {
|
|
72
|
+
"maxTokens": 163840
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "fireworks-ai__accounts/fireworks/models/firellava-13b",
|
|
77
|
+
"name": "FireLLaVA-13B",
|
|
78
|
+
"integration": "fireworks-ai",
|
|
79
|
+
"input": {
|
|
80
|
+
"maxTokens": 4096
|
|
81
|
+
},
|
|
82
|
+
"output": {
|
|
83
|
+
"maxTokens": 4096
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "fireworks-ai__accounts/fireworks/models/firefunction-v2",
|
|
88
|
+
"name": "Firefunction V2",
|
|
89
|
+
"integration": "fireworks-ai",
|
|
90
|
+
"input": {
|
|
91
|
+
"maxTokens": 8192
|
|
92
|
+
},
|
|
93
|
+
"output": {
|
|
94
|
+
"maxTokens": 8192
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"id": "fireworks-ai__accounts/fireworks/models/gemma2-9b-it",
|
|
99
|
+
"name": "Gemma 2 9B Instruct",
|
|
100
|
+
"integration": "fireworks-ai",
|
|
101
|
+
"input": {
|
|
102
|
+
"maxTokens": 8192
|
|
103
|
+
},
|
|
104
|
+
"output": {
|
|
105
|
+
"maxTokens": 8192
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"id": "fireworks-ai__accounts/fireworks/models/llama-v3p1-405b-instruct",
|
|
110
|
+
"name": "Llama 3.1 405B Instruct",
|
|
111
|
+
"integration": "fireworks-ai",
|
|
112
|
+
"input": {
|
|
113
|
+
"maxTokens": 131072
|
|
114
|
+
},
|
|
115
|
+
"output": {
|
|
116
|
+
"maxTokens": 131072
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"id": "fireworks-ai__accounts/fireworks/models/llama-v3p1-70b-instruct",
|
|
121
|
+
"name": "Llama 3.1 70B Instruct",
|
|
122
|
+
"integration": "fireworks-ai",
|
|
123
|
+
"input": {
|
|
124
|
+
"maxTokens": 131072
|
|
125
|
+
},
|
|
126
|
+
"output": {
|
|
127
|
+
"maxTokens": 131072
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"id": "fireworks-ai__accounts/fireworks/models/llama-v3p1-8b-instruct",
|
|
132
|
+
"name": "Llama 3.1 8B Instruct",
|
|
133
|
+
"integration": "fireworks-ai",
|
|
134
|
+
"input": {
|
|
135
|
+
"maxTokens": 131072
|
|
136
|
+
},
|
|
137
|
+
"output": {
|
|
138
|
+
"maxTokens": 131072
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"id": "fireworks-ai__accounts/fireworks/models/mixtral-8x22b-instruct",
|
|
143
|
+
"name": "Mixtral MoE 8x22B Instruct",
|
|
144
|
+
"integration": "fireworks-ai",
|
|
145
|
+
"input": {
|
|
146
|
+
"maxTokens": 65536
|
|
147
|
+
},
|
|
148
|
+
"output": {
|
|
149
|
+
"maxTokens": 65536
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"id": "fireworks-ai__accounts/fireworks/models/mixtral-8x7b-instruct",
|
|
154
|
+
"name": "Mixtral MoE 8x7B Instruct",
|
|
155
|
+
"integration": "fireworks-ai",
|
|
156
|
+
"input": {
|
|
157
|
+
"maxTokens": 32768
|
|
158
|
+
},
|
|
159
|
+
"output": {
|
|
160
|
+
"maxTokens": 32768
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"id": "fireworks-ai__accounts/fireworks/models/mythomax-l2-13b",
|
|
165
|
+
"name": "MythoMax L2 13b",
|
|
166
|
+
"integration": "fireworks-ai",
|
|
167
|
+
"input": {
|
|
168
|
+
"maxTokens": 4096
|
|
169
|
+
},
|
|
170
|
+
"output": {
|
|
171
|
+
"maxTokens": 4096
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"id": "fireworks-ai__accounts/fireworks/models/qwen2-72b-instruct",
|
|
176
|
+
"name": "Qwen2 72b Instruct",
|
|
177
|
+
"integration": "fireworks-ai",
|
|
178
|
+
"input": {
|
|
179
|
+
"maxTokens": 32768
|
|
180
|
+
},
|
|
181
|
+
"output": {
|
|
182
|
+
"maxTokens": 32768
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"id": "groq__gemma2-9b-it",
|
|
187
|
+
"name": "Gemma2 9B",
|
|
188
|
+
"integration": "groq",
|
|
189
|
+
"input": {
|
|
190
|
+
"maxTokens": 8192
|
|
191
|
+
},
|
|
192
|
+
"output": {
|
|
193
|
+
"maxTokens": 8192
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"id": "groq__llama3-70b-8192",
|
|
198
|
+
"name": "LLaMA 3 70B",
|
|
199
|
+
"integration": "groq",
|
|
200
|
+
"input": {
|
|
201
|
+
"maxTokens": 8192
|
|
202
|
+
},
|
|
203
|
+
"output": {
|
|
204
|
+
"maxTokens": 8192
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"id": "groq__llama3-8b-8192",
|
|
209
|
+
"name": "LLaMA 3 8B",
|
|
210
|
+
"integration": "groq",
|
|
211
|
+
"input": {
|
|
212
|
+
"maxTokens": 8192
|
|
213
|
+
},
|
|
214
|
+
"output": {
|
|
215
|
+
"maxTokens": 8192
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"id": "groq__llama-3.1-70b-versatile",
|
|
220
|
+
"name": "LLaMA 3.1 70B",
|
|
221
|
+
"integration": "groq",
|
|
222
|
+
"input": {
|
|
223
|
+
"maxTokens": 128000
|
|
224
|
+
},
|
|
225
|
+
"output": {
|
|
226
|
+
"maxTokens": 8192
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"id": "groq__llama-3.1-8b-instant",
|
|
231
|
+
"name": "LLaMA 3.1 8B",
|
|
232
|
+
"integration": "groq",
|
|
233
|
+
"input": {
|
|
234
|
+
"maxTokens": 128000
|
|
235
|
+
},
|
|
236
|
+
"output": {
|
|
237
|
+
"maxTokens": 8192
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"id": "groq__llama-3.2-11b-vision-preview",
|
|
242
|
+
"name": "LLaMA 3.2 11B Vision",
|
|
243
|
+
"integration": "groq",
|
|
244
|
+
"input": {
|
|
245
|
+
"maxTokens": 128000
|
|
246
|
+
},
|
|
247
|
+
"output": {
|
|
248
|
+
"maxTokens": 8192
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"id": "groq__llama-3.2-1b-preview",
|
|
253
|
+
"name": "LLaMA 3.2 1B",
|
|
254
|
+
"integration": "groq",
|
|
255
|
+
"input": {
|
|
256
|
+
"maxTokens": 128000
|
|
257
|
+
},
|
|
258
|
+
"output": {
|
|
259
|
+
"maxTokens": 8192
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"id": "groq__llama-3.2-3b-preview",
|
|
264
|
+
"name": "LLaMA 3.2 3B",
|
|
265
|
+
"integration": "groq",
|
|
266
|
+
"input": {
|
|
267
|
+
"maxTokens": 128000
|
|
268
|
+
},
|
|
269
|
+
"output": {
|
|
270
|
+
"maxTokens": 8192
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"id": "groq__llama-3.2-90b-vision-preview",
|
|
275
|
+
"name": "LLaMA 3.2 90B Vision",
|
|
276
|
+
"integration": "groq",
|
|
277
|
+
"input": {
|
|
278
|
+
"maxTokens": 128000
|
|
279
|
+
},
|
|
280
|
+
"output": {
|
|
281
|
+
"maxTokens": 8192
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"id": "groq__llama-3.3-70b-versatile",
|
|
286
|
+
"name": "LLaMA 3.3 70B",
|
|
287
|
+
"integration": "groq",
|
|
288
|
+
"input": {
|
|
289
|
+
"maxTokens": 128000
|
|
290
|
+
},
|
|
291
|
+
"output": {
|
|
292
|
+
"maxTokens": 32768
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"id": "groq__mixtral-8x7b-32768",
|
|
297
|
+
"name": "Mixtral 8x7B",
|
|
298
|
+
"integration": "groq",
|
|
299
|
+
"input": {
|
|
300
|
+
"maxTokens": 32768
|
|
301
|
+
},
|
|
302
|
+
"output": {
|
|
303
|
+
"maxTokens": 32768
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"id": "openai__o1-2024-12-17",
|
|
308
|
+
"name": "GPT o1",
|
|
309
|
+
"integration": "openai",
|
|
310
|
+
"input": {
|
|
311
|
+
"maxTokens": 200000
|
|
312
|
+
},
|
|
313
|
+
"output": {
|
|
314
|
+
"maxTokens": 100000
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"id": "openai__o1-mini-2024-09-12",
|
|
319
|
+
"name": "GPT o1-mini",
|
|
320
|
+
"integration": "openai",
|
|
321
|
+
"input": {
|
|
322
|
+
"maxTokens": 128000
|
|
323
|
+
},
|
|
324
|
+
"output": {
|
|
325
|
+
"maxTokens": 65536
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"id": "openai__gpt-3.5-turbo-0125",
|
|
330
|
+
"name": "GPT-3.5 Turbo",
|
|
331
|
+
"integration": "openai",
|
|
332
|
+
"input": {
|
|
333
|
+
"maxTokens": 128000
|
|
334
|
+
},
|
|
335
|
+
"output": {
|
|
336
|
+
"maxTokens": 4096
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
"id": "openai__gpt-4-turbo-2024-04-09",
|
|
341
|
+
"name": "GPT-4 Turbo",
|
|
342
|
+
"integration": "openai",
|
|
343
|
+
"input": {
|
|
344
|
+
"maxTokens": 128000
|
|
345
|
+
},
|
|
346
|
+
"output": {
|
|
347
|
+
"maxTokens": 4096
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
"id": "openai__gpt-4o-2024-08-06",
|
|
352
|
+
"name": "GPT-4o (August 2024)",
|
|
353
|
+
"integration": "openai",
|
|
354
|
+
"input": {
|
|
355
|
+
"maxTokens": 128000
|
|
356
|
+
},
|
|
357
|
+
"output": {
|
|
358
|
+
"maxTokens": 16384
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
"id": "openai__gpt-4o-2024-05-13",
|
|
363
|
+
"name": "GPT-4o (May 2024)",
|
|
364
|
+
"integration": "openai",
|
|
365
|
+
"input": {
|
|
366
|
+
"maxTokens": 128000
|
|
367
|
+
},
|
|
368
|
+
"output": {
|
|
369
|
+
"maxTokens": 4096
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"id": "openai__gpt-4o-2024-11-20",
|
|
374
|
+
"name": "GPT-4o (November 2024)",
|
|
375
|
+
"integration": "openai",
|
|
376
|
+
"input": {
|
|
377
|
+
"maxTokens": 128000
|
|
378
|
+
},
|
|
379
|
+
"output": {
|
|
380
|
+
"maxTokens": 16384
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
"id": "openai__gpt-4o-mini-2024-07-18",
|
|
385
|
+
"name": "GPT-4o Mini",
|
|
386
|
+
"integration": "openai",
|
|
387
|
+
"input": {
|
|
388
|
+
"maxTokens": 128000
|
|
389
|
+
},
|
|
390
|
+
"output": {
|
|
391
|
+
"maxTokens": 16384
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
] as const
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Client } from '@botpress/client'
|
|
2
|
+
|
|
3
|
+
import _ from 'lodash'
|
|
4
|
+
import fs from 'node:fs'
|
|
5
|
+
|
|
6
|
+
const LLM_LIST_MODELS = 'listLanguageModels'
|
|
7
|
+
|
|
8
|
+
const client = new Client({
|
|
9
|
+
apiUrl: process.env.CLOUD_API_ENDPOINT,
|
|
10
|
+
botId: process.env.CLOUD_BOT_ID,
|
|
11
|
+
token: process.env.CLOUD_PAT
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const { bot } = await client.getBot({
|
|
15
|
+
id: process.env.CLOUD_BOT_ID!
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
type Model = {
|
|
19
|
+
id: string
|
|
20
|
+
name: string
|
|
21
|
+
integration: string
|
|
22
|
+
input: { maxTokens: number }
|
|
23
|
+
output: { maxTokens: number }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const models: Model[] = []
|
|
27
|
+
|
|
28
|
+
for (const integrationId in bot.integrations) {
|
|
29
|
+
const botIntegration = bot.integrations[integrationId]
|
|
30
|
+
if (botIntegration?.public && botIntegration?.enabled && botIntegration?.status === 'registered') {
|
|
31
|
+
try {
|
|
32
|
+
const { integration } = await client.getPublicIntegrationById({
|
|
33
|
+
id: botIntegration.id
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const canListModels = Object.keys(integration.actions).includes(LLM_LIST_MODELS)
|
|
37
|
+
if (!canListModels) {
|
|
38
|
+
continue
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { output } = await client.callAction({
|
|
42
|
+
type: `${integration.name}:${LLM_LIST_MODELS}`,
|
|
43
|
+
input: {}
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
if (_.isArray(output?.models)) {
|
|
47
|
+
for (const model of output.models) {
|
|
48
|
+
models.push({
|
|
49
|
+
id: `${integration.name}__${model.id}`,
|
|
50
|
+
name: model.name,
|
|
51
|
+
integration: integration.name,
|
|
52
|
+
input: { maxTokens: model.input.maxTokens },
|
|
53
|
+
output: { maxTokens: model.output.maxTokens }
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
} catch (err: unknown) {
|
|
58
|
+
console.error('Error fetching integration:', err instanceof Error ? err.message : `${err}`)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const content = JSON.stringify(_.orderBy(models, ['integration', 'name']), null, 2)
|
|
64
|
+
|
|
65
|
+
fs.writeFileSync(
|
|
66
|
+
'./src/models.ts',
|
|
67
|
+
`
|
|
68
|
+
// This file is generated. Do not edit it manually.
|
|
69
|
+
// See 'scripts/update-models.ts'
|
|
70
|
+
|
|
71
|
+
/* eslint-disable */
|
|
72
|
+
/* tslint:disable */
|
|
73
|
+
|
|
74
|
+
export const Models = ${content} as const`,
|
|
75
|
+
'utf-8'
|
|
76
|
+
)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Client } from '@botpress/client'
|
|
2
|
+
import sdk from '@botpress/sdk'
|
|
3
|
+
|
|
4
|
+
import _ from 'lodash'
|
|
5
|
+
import fs from 'node:fs'
|
|
6
|
+
import path from 'node:path'
|
|
7
|
+
|
|
8
|
+
const { z } = sdk
|
|
9
|
+
|
|
10
|
+
const Interfaces = ['llm'] as const
|
|
11
|
+
|
|
12
|
+
const client = new Client({
|
|
13
|
+
apiUrl: process.env.CLOUD_API_ENDPOINT,
|
|
14
|
+
botId: process.env.CLOUD_BOT_ID,
|
|
15
|
+
token: process.env.CLOUD_PAT
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
for (const name of Interfaces) {
|
|
19
|
+
const { interfaces } = await client.listInterfaces({
|
|
20
|
+
name
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const { interface: latest } = await client.getInterface({
|
|
24
|
+
id: _.maxBy(interfaces, 'version')!.id
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
for (const action of Object.keys(latest.actions)) {
|
|
28
|
+
const references = Object.keys(latest.entities).reduce((acc, key) => {
|
|
29
|
+
return { ...acc, [key]: z.fromJsonSchema(latest.entities?.[key]?.schema!) }
|
|
30
|
+
}, {})
|
|
31
|
+
const input = latest.actions[action]?.input.schema!
|
|
32
|
+
const output = latest.actions[action]?.output.schema!
|
|
33
|
+
|
|
34
|
+
const types = `
|
|
35
|
+
// This file is generated. Do not edit it manually.
|
|
36
|
+
// See 'scripts/update-models.ts'
|
|
37
|
+
|
|
38
|
+
/* eslint-disable */
|
|
39
|
+
/* tslint:disable */
|
|
40
|
+
|
|
41
|
+
export namespace ${name} {
|
|
42
|
+
export namespace ${action} {
|
|
43
|
+
export ${sdk.z
|
|
44
|
+
.fromJsonSchema(input)
|
|
45
|
+
.title('Input')
|
|
46
|
+
.dereference(references)
|
|
47
|
+
.toTypescript({ declaration: 'type' })};
|
|
48
|
+
export ${sdk.z
|
|
49
|
+
.fromJsonSchema(output)
|
|
50
|
+
.title('Output')
|
|
51
|
+
.dereference(references)
|
|
52
|
+
.toTypescript({ declaration: 'type' })};
|
|
53
|
+
}
|
|
54
|
+
}`
|
|
55
|
+
|
|
56
|
+
fs.mkdirSync(path.resolve(`./src/sdk-interfaces/${name}`), { recursive: true })
|
|
57
|
+
fs.writeFileSync(path.resolve(`./src/sdk-interfaces/${name}/${action}.ts`), types)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
|
|
2
|
+
// This file is generated. Do not edit it manually.
|
|
3
|
+
// See 'scripts/update-models.ts'
|
|
4
|
+
|
|
5
|
+
/* eslint-disable */
|
|
6
|
+
/* tslint:disable */
|
|
7
|
+
|
|
8
|
+
export namespace llm {
|
|
9
|
+
export namespace generateContent {
|
|
10
|
+
export type Input = {
|
|
11
|
+
/** Model to use for content generation */
|
|
12
|
+
model?: { id: string }
|
|
13
|
+
;
|
|
14
|
+
/** Optional system prompt to guide the model */
|
|
15
|
+
systemPrompt?: string
|
|
16
|
+
;
|
|
17
|
+
/** Array of messages for the model to process */
|
|
18
|
+
messages: Array<{ role: 'user' | 'assistant'; type?: 'text' | 'tool_calls' | 'tool_result' | 'multipart';
|
|
19
|
+
/** Required if `type` is "tool_calls" */
|
|
20
|
+
toolCalls?: Array<{ id: string; type: 'function'; function: { name: string;
|
|
21
|
+
/** Some LLMs may generate invalid JSON for a tool call, so this will be `null` when it happens. */
|
|
22
|
+
arguments:
|
|
23
|
+
{ [key: string]: any } | null
|
|
24
|
+
} }>
|
|
25
|
+
;
|
|
26
|
+
/** Required if `type` is "tool_result" */
|
|
27
|
+
toolResultCallId?: string
|
|
28
|
+
;
|
|
29
|
+
/** Required unless `type` is "tool_call". If `type` is "multipart", this field must be an array of content objects. If `type` is "tool_result" then this field should be the result of the tool call (a plain string or a JSON-encoded array or object). If `type` is "tool_call" then the `toolCalls` field should be used instead. */
|
|
30
|
+
content:
|
|
31
|
+
|
|
32
|
+
string | Array<{ type: 'text' | 'image';
|
|
33
|
+
/** Indicates the MIME type of the content. If not provided it will be detected from the content-type header of the provided URL. */
|
|
34
|
+
mimeType?: string
|
|
35
|
+
;
|
|
36
|
+
/** Required if part type is "text" */
|
|
37
|
+
text?: string
|
|
38
|
+
;
|
|
39
|
+
/** Required if part type is "image" */
|
|
40
|
+
url?: string
|
|
41
|
+
}> | null
|
|
42
|
+
}>
|
|
43
|
+
;
|
|
44
|
+
/** Response format expected from the model. If "json_object" is chosen, you must instruct the model to generate JSON either via the system prompt or a user message. */
|
|
45
|
+
responseFormat?: 'text' | 'json_object'
|
|
46
|
+
;
|
|
47
|
+
/** Maximum number of tokens allowed in the generated response */
|
|
48
|
+
maxTokens?: number
|
|
49
|
+
;
|
|
50
|
+
/** Sampling temperature for the model. Higher values result in more random outputs. */
|
|
51
|
+
temperature?: /** Sampling temperature for the model. Higher values result in more random outputs. */ number
|
|
52
|
+
;
|
|
53
|
+
/** Top-p sampling parameter. Limits sampling to the smallest set of tokens with a cumulative probability above the threshold. */
|
|
54
|
+
topP?: /** Top-p sampling parameter. Limits sampling to the smallest set of tokens with a cumulative probability above the threshold. */ number
|
|
55
|
+
;
|
|
56
|
+
/** Sequences where the model should stop generating further tokens. */
|
|
57
|
+
stopSequences?: string[]
|
|
58
|
+
; tools?: Array<{ type: 'function'; function: {
|
|
59
|
+
/** Function name */
|
|
60
|
+
name: string
|
|
61
|
+
; description?: string;
|
|
62
|
+
/** JSON schema of the function arguments */
|
|
63
|
+
argumentsSchema?: { }
|
|
64
|
+
} }>; toolChoice?: { type?: 'auto' | 'specific' | 'any' | 'none' | '';
|
|
65
|
+
/** Required if `type` is "specific" */
|
|
66
|
+
functionName?: string
|
|
67
|
+
}; userId?: string;
|
|
68
|
+
/** Set to `true` to output debug information to the bot logs */
|
|
69
|
+
debug?: boolean
|
|
70
|
+
; meta?: {
|
|
71
|
+
/** Source of the prompt, e.g. agent/:id/:version cards/ai-generate, cards/ai-task, nodes/autonomous, etc. */
|
|
72
|
+
promptSource?: string
|
|
73
|
+
; promptCategory?: string;
|
|
74
|
+
/** Name of the integration that originally received the message that initiated this action */
|
|
75
|
+
integrationName?: string
|
|
76
|
+
} };;
|
|
77
|
+
export type Output = {
|
|
78
|
+
/** Response ID from LLM provider */
|
|
79
|
+
id: string
|
|
80
|
+
;
|
|
81
|
+
/** LLM provider name */
|
|
82
|
+
provider: string
|
|
83
|
+
;
|
|
84
|
+
/** Model name */
|
|
85
|
+
model: string
|
|
86
|
+
; choices: Array<{ type?: 'text' | 'tool_calls' | 'tool_result' | 'multipart';
|
|
87
|
+
/** Required if `type` is "tool_calls" */
|
|
88
|
+
toolCalls?: Array<{ id: string; type: 'function'; function: { name: string;
|
|
89
|
+
/** Some LLMs may generate invalid JSON for a tool call, so this will be `null` when it happens. */
|
|
90
|
+
arguments:
|
|
91
|
+
{ [key: string]: any } | null
|
|
92
|
+
} }>
|
|
93
|
+
;
|
|
94
|
+
/** Required if `type` is "tool_result" */
|
|
95
|
+
toolResultCallId?: string
|
|
96
|
+
;
|
|
97
|
+
/** Required unless `type` is "tool_call". If `type` is "multipart", this field must be an array of content objects. If `type` is "tool_result" then this field should be the result of the tool call (a plain string or a JSON-encoded array or object). If `type` is "tool_call" then the `toolCalls` field should be used instead. */
|
|
98
|
+
content:
|
|
99
|
+
|
|
100
|
+
string | Array<{ type: 'text' | 'image';
|
|
101
|
+
/** Indicates the MIME type of the content. If not provided it will be detected from the content-type header of the provided URL. */
|
|
102
|
+
mimeType?: string
|
|
103
|
+
;
|
|
104
|
+
/** Required if part type is "text" */
|
|
105
|
+
text?: string
|
|
106
|
+
;
|
|
107
|
+
/** Required if part type is "image" */
|
|
108
|
+
url?: string
|
|
109
|
+
}> | null
|
|
110
|
+
; role: 'assistant'; index: number; stopReason: 'stop' | 'max_tokens' | 'tool_calls' | 'content_filter' | 'other' }>; usage: {
|
|
111
|
+
/** Number of input tokens used by the model */
|
|
112
|
+
inputTokens: number
|
|
113
|
+
;
|
|
114
|
+
/** Cost of the input tokens received by the model, in U.S. dollars */
|
|
115
|
+
inputCost: number
|
|
116
|
+
;
|
|
117
|
+
/** Number of output tokens used by the model */
|
|
118
|
+
outputTokens: number
|
|
119
|
+
;
|
|
120
|
+
/** Cost of the output tokens generated by the model, in U.S. dollars */
|
|
121
|
+
outputCost: number
|
|
122
|
+
}; botpress: {
|
|
123
|
+
/** Total cost of the content generation, in U.S. dollars */
|
|
124
|
+
cost: number
|
|
125
|
+
} };;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
// This file is generated. Do not edit it manually.
|
|
3
|
+
// See 'scripts/update-models.ts'
|
|
4
|
+
|
|
5
|
+
/* eslint-disable */
|
|
6
|
+
/* tslint:disable */
|
|
7
|
+
|
|
8
|
+
export namespace llm {
|
|
9
|
+
export namespace listLanguageModels {
|
|
10
|
+
export type Input = { };;
|
|
11
|
+
export type Output = { models: Array<{ id: string; name: string; description: string; tags: Array<'recommended' | 'deprecated' | 'general-purpose' | 'low-cost' | 'vision' | 'coding' | 'agents' | 'function-calling' | 'roleplay' | 'storytelling' | 'reasoning'>; input: { maxTokens: number;
|
|
12
|
+
/** Cost per 1 million tokens, in U.S. dollars */
|
|
13
|
+
costPer1MTokens: number
|
|
14
|
+
}; output: { maxTokens: number;
|
|
15
|
+
/** Cost per 1 million tokens, in U.S. dollars */
|
|
16
|
+
costPer1MTokens: number
|
|
17
|
+
} } & { id: string }> };;
|
|
18
|
+
}
|
|
19
|
+
}
|