@promptbook/openai 0.66.0-0 → 0.66.0-4
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/esm/index.es.js +604 -536
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/anthropic-claude.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +12 -2
- package/esm/typings/src/_packages/openai.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +6 -2
- package/esm/typings/src/config.d.ts +15 -0
- package/esm/typings/src/execution/AvailableModel.d.ts +20 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +12 -24
- package/esm/typings/src/execution/LlmExecutionToolsConstructor.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/$llmToolsConfigurationBoilerplatesRegister.d.ts +12 -0
- package/esm/typings/src/llm-providers/_common/$llmToolsRegister.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/LlmToolsConfiguration.d.ts +2 -10
- package/esm/typings/src/llm-providers/_common/config.d.ts +5 -6
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.d.ts +18 -0
- package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.test.d.ts +4 -0
- package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +7 -2
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +8 -0
- package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +11 -0
- package/esm/typings/src/llm-providers/anthropic-claude/register1.d.ts +4 -0
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -3
- package/esm/typings/src/llm-providers/openai/{computeOpenaiUsage.d.ts → computeOpenAiUsage.d.ts} +6 -2
- package/esm/typings/src/llm-providers/openai/computeOpenAiUsage.test.d.ts +4 -0
- package/esm/typings/src/llm-providers/openai/createOpenAiExecutionTools.d.ts +15 -0
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +8 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +11 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +5 -2
- package/esm/typings/src/utils/Register.d.ts +22 -0
- package/esm/typings/src/utils/environment/getGlobalScope.d.ts +3 -0
- package/package.json +2 -2
- package/umd/index.umd.js +605 -535
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.test.d.ts +0 -1
package/esm/index.es.js
CHANGED
|
@@ -6,7 +6,7 @@ import spaceTrim$1, { spaceTrim } from 'spacetrim';
|
|
|
6
6
|
/**
|
|
7
7
|
* The version of the Promptbook library
|
|
8
8
|
*/
|
|
9
|
-
var PROMPTBOOK_VERSION = '0.
|
|
9
|
+
var PROMPTBOOK_VERSION = '0.66.0-3';
|
|
10
10
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
11
11
|
|
|
12
12
|
/*! *****************************************************************************
|
|
@@ -128,368 +128,6 @@ function __spreadArray(to, from, pack) {
|
|
|
128
128
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
/**
|
|
132
|
-
* Function computeUsage will create price per one token based on the string value found on openai page
|
|
133
|
-
*
|
|
134
|
-
* @private within the repository, used only as internal helper for `OPENAI_MODELS`
|
|
135
|
-
*/
|
|
136
|
-
function computeUsage(value) {
|
|
137
|
-
var _a = __read(value.split(' / '), 2), price = _a[0], tokens = _a[1];
|
|
138
|
-
return parseFloat(price.replace('$', '')) / parseFloat(tokens.replace('M tokens', '')) / 1000000;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* List of available OpenAI models with pricing
|
|
143
|
-
*
|
|
144
|
-
* Note: Done at 2024-05-20
|
|
145
|
-
*
|
|
146
|
-
* @see https://platform.openai.com/docs/models/
|
|
147
|
-
* @see https://openai.com/api/pricing/
|
|
148
|
-
* @public exported from `@promptbook/openai`
|
|
149
|
-
*/
|
|
150
|
-
var OPENAI_MODELS = [
|
|
151
|
-
/*/
|
|
152
|
-
{
|
|
153
|
-
modelTitle: 'dall-e-3',
|
|
154
|
-
modelName: 'dall-e-3',
|
|
155
|
-
},
|
|
156
|
-
/**/
|
|
157
|
-
/*/
|
|
158
|
-
{
|
|
159
|
-
modelTitle: 'whisper-1',
|
|
160
|
-
modelName: 'whisper-1',
|
|
161
|
-
},
|
|
162
|
-
/**/
|
|
163
|
-
/**/
|
|
164
|
-
{
|
|
165
|
-
modelVariant: 'COMPLETION',
|
|
166
|
-
modelTitle: 'davinci-002',
|
|
167
|
-
modelName: 'davinci-002',
|
|
168
|
-
pricing: {
|
|
169
|
-
prompt: computeUsage("$2.00 / 1M tokens"),
|
|
170
|
-
output: computeUsage("$2.00 / 1M tokens"), // <- not sure
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
/**/
|
|
174
|
-
/*/
|
|
175
|
-
{
|
|
176
|
-
modelTitle: 'dall-e-2',
|
|
177
|
-
modelName: 'dall-e-2',
|
|
178
|
-
},
|
|
179
|
-
/**/
|
|
180
|
-
/**/
|
|
181
|
-
{
|
|
182
|
-
modelVariant: 'CHAT',
|
|
183
|
-
modelTitle: 'gpt-3.5-turbo-16k',
|
|
184
|
-
modelName: 'gpt-3.5-turbo-16k',
|
|
185
|
-
pricing: {
|
|
186
|
-
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
187
|
-
output: computeUsage("$4.00 / 1M tokens"),
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
/**/
|
|
191
|
-
/*/
|
|
192
|
-
{
|
|
193
|
-
modelTitle: 'tts-1-hd-1106',
|
|
194
|
-
modelName: 'tts-1-hd-1106',
|
|
195
|
-
},
|
|
196
|
-
/**/
|
|
197
|
-
/*/
|
|
198
|
-
{
|
|
199
|
-
modelTitle: 'tts-1-hd',
|
|
200
|
-
modelName: 'tts-1-hd',
|
|
201
|
-
},
|
|
202
|
-
/**/
|
|
203
|
-
/**/
|
|
204
|
-
{
|
|
205
|
-
modelVariant: 'CHAT',
|
|
206
|
-
modelTitle: 'gpt-4',
|
|
207
|
-
modelName: 'gpt-4',
|
|
208
|
-
pricing: {
|
|
209
|
-
prompt: computeUsage("$30.00 / 1M tokens"),
|
|
210
|
-
output: computeUsage("$60.00 / 1M tokens"),
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
/**/
|
|
214
|
-
/**/
|
|
215
|
-
{
|
|
216
|
-
modelVariant: 'CHAT',
|
|
217
|
-
modelTitle: 'gpt-4-32k',
|
|
218
|
-
modelName: 'gpt-4-32k',
|
|
219
|
-
pricing: {
|
|
220
|
-
prompt: computeUsage("$60.00 / 1M tokens"),
|
|
221
|
-
output: computeUsage("$120.00 / 1M tokens"),
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
/**/
|
|
225
|
-
/*/
|
|
226
|
-
{
|
|
227
|
-
modelVariant: 'CHAT',
|
|
228
|
-
modelTitle: 'gpt-4-0613',
|
|
229
|
-
modelName: 'gpt-4-0613',
|
|
230
|
-
pricing: {
|
|
231
|
-
prompt: computeUsage(` / 1M tokens`),
|
|
232
|
-
output: computeUsage(` / 1M tokens`),
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
/**/
|
|
236
|
-
/**/
|
|
237
|
-
{
|
|
238
|
-
modelVariant: 'CHAT',
|
|
239
|
-
modelTitle: 'gpt-4-turbo-2024-04-09',
|
|
240
|
-
modelName: 'gpt-4-turbo-2024-04-09',
|
|
241
|
-
pricing: {
|
|
242
|
-
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
243
|
-
output: computeUsage("$30.00 / 1M tokens"),
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
/**/
|
|
247
|
-
/**/
|
|
248
|
-
{
|
|
249
|
-
modelVariant: 'CHAT',
|
|
250
|
-
modelTitle: 'gpt-3.5-turbo-1106',
|
|
251
|
-
modelName: 'gpt-3.5-turbo-1106',
|
|
252
|
-
pricing: {
|
|
253
|
-
prompt: computeUsage("$1.00 / 1M tokens"),
|
|
254
|
-
output: computeUsage("$2.00 / 1M tokens"),
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
/**/
|
|
258
|
-
/**/
|
|
259
|
-
{
|
|
260
|
-
modelVariant: 'CHAT',
|
|
261
|
-
modelTitle: 'gpt-4-turbo',
|
|
262
|
-
modelName: 'gpt-4-turbo',
|
|
263
|
-
pricing: {
|
|
264
|
-
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
265
|
-
output: computeUsage("$30.00 / 1M tokens"),
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
/**/
|
|
269
|
-
/**/
|
|
270
|
-
{
|
|
271
|
-
modelVariant: 'COMPLETION',
|
|
272
|
-
modelTitle: 'gpt-3.5-turbo-instruct-0914',
|
|
273
|
-
modelName: 'gpt-3.5-turbo-instruct-0914',
|
|
274
|
-
pricing: {
|
|
275
|
-
prompt: computeUsage("$1.50 / 1M tokens"),
|
|
276
|
-
output: computeUsage("$2.00 / 1M tokens"), // <- For gpt-3.5-turbo-instruct
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
/**/
|
|
280
|
-
/**/
|
|
281
|
-
{
|
|
282
|
-
modelVariant: 'COMPLETION',
|
|
283
|
-
modelTitle: 'gpt-3.5-turbo-instruct',
|
|
284
|
-
modelName: 'gpt-3.5-turbo-instruct',
|
|
285
|
-
pricing: {
|
|
286
|
-
prompt: computeUsage("$1.50 / 1M tokens"),
|
|
287
|
-
output: computeUsage("$2.00 / 1M tokens"),
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
|
-
/**/
|
|
291
|
-
/*/
|
|
292
|
-
{
|
|
293
|
-
modelTitle: 'tts-1',
|
|
294
|
-
modelName: 'tts-1',
|
|
295
|
-
},
|
|
296
|
-
/**/
|
|
297
|
-
/**/
|
|
298
|
-
{
|
|
299
|
-
modelVariant: 'CHAT',
|
|
300
|
-
modelTitle: 'gpt-3.5-turbo',
|
|
301
|
-
modelName: 'gpt-3.5-turbo',
|
|
302
|
-
pricing: {
|
|
303
|
-
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
304
|
-
output: computeUsage("$6.00 / 1M tokens"), // <- Not sure, refer to gpt-3.5-turbo in Fine-tuning models
|
|
305
|
-
},
|
|
306
|
-
},
|
|
307
|
-
/**/
|
|
308
|
-
/**/
|
|
309
|
-
{
|
|
310
|
-
modelVariant: 'CHAT',
|
|
311
|
-
modelTitle: 'gpt-3.5-turbo-0301',
|
|
312
|
-
modelName: 'gpt-3.5-turbo-0301',
|
|
313
|
-
pricing: {
|
|
314
|
-
prompt: computeUsage("$1.50 / 1M tokens"),
|
|
315
|
-
output: computeUsage("$2.00 / 1M tokens"),
|
|
316
|
-
},
|
|
317
|
-
},
|
|
318
|
-
/**/
|
|
319
|
-
/**/
|
|
320
|
-
{
|
|
321
|
-
modelVariant: 'COMPLETION',
|
|
322
|
-
modelTitle: 'babbage-002',
|
|
323
|
-
modelName: 'babbage-002',
|
|
324
|
-
pricing: {
|
|
325
|
-
prompt: computeUsage("$0.40 / 1M tokens"),
|
|
326
|
-
output: computeUsage("$0.40 / 1M tokens"), // <- Not sure
|
|
327
|
-
},
|
|
328
|
-
},
|
|
329
|
-
/**/
|
|
330
|
-
/**/
|
|
331
|
-
{
|
|
332
|
-
modelVariant: 'CHAT',
|
|
333
|
-
modelTitle: 'gpt-4-1106-preview',
|
|
334
|
-
modelName: 'gpt-4-1106-preview',
|
|
335
|
-
pricing: {
|
|
336
|
-
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
337
|
-
output: computeUsage("$30.00 / 1M tokens"),
|
|
338
|
-
},
|
|
339
|
-
},
|
|
340
|
-
/**/
|
|
341
|
-
/**/
|
|
342
|
-
{
|
|
343
|
-
modelVariant: 'CHAT',
|
|
344
|
-
modelTitle: 'gpt-4-0125-preview',
|
|
345
|
-
modelName: 'gpt-4-0125-preview',
|
|
346
|
-
pricing: {
|
|
347
|
-
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
348
|
-
output: computeUsage("$30.00 / 1M tokens"),
|
|
349
|
-
},
|
|
350
|
-
},
|
|
351
|
-
/**/
|
|
352
|
-
/*/
|
|
353
|
-
{
|
|
354
|
-
modelTitle: 'tts-1-1106',
|
|
355
|
-
modelName: 'tts-1-1106',
|
|
356
|
-
},
|
|
357
|
-
/**/
|
|
358
|
-
/**/
|
|
359
|
-
{
|
|
360
|
-
modelVariant: 'CHAT',
|
|
361
|
-
modelTitle: 'gpt-3.5-turbo-0125',
|
|
362
|
-
modelName: 'gpt-3.5-turbo-0125',
|
|
363
|
-
pricing: {
|
|
364
|
-
prompt: computeUsage("$0.50 / 1M tokens"),
|
|
365
|
-
output: computeUsage("$1.50 / 1M tokens"),
|
|
366
|
-
},
|
|
367
|
-
},
|
|
368
|
-
/**/
|
|
369
|
-
/**/
|
|
370
|
-
{
|
|
371
|
-
modelVariant: 'CHAT',
|
|
372
|
-
modelTitle: 'gpt-4-turbo-preview',
|
|
373
|
-
modelName: 'gpt-4-turbo-preview',
|
|
374
|
-
pricing: {
|
|
375
|
-
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
376
|
-
output: computeUsage("$30.00 / 1M tokens"), // <- Not sure, just for gpt-4-turbo
|
|
377
|
-
},
|
|
378
|
-
},
|
|
379
|
-
/**/
|
|
380
|
-
/**/
|
|
381
|
-
{
|
|
382
|
-
modelVariant: 'EMBEDDING',
|
|
383
|
-
modelTitle: 'text-embedding-3-large',
|
|
384
|
-
modelName: 'text-embedding-3-large',
|
|
385
|
-
pricing: {
|
|
386
|
-
prompt: computeUsage("$0.13 / 1M tokens"),
|
|
387
|
-
// TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
|
|
388
|
-
output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
|
|
389
|
-
},
|
|
390
|
-
},
|
|
391
|
-
/**/
|
|
392
|
-
/**/
|
|
393
|
-
{
|
|
394
|
-
modelVariant: 'EMBEDDING',
|
|
395
|
-
modelTitle: 'text-embedding-3-small',
|
|
396
|
-
modelName: 'text-embedding-3-small',
|
|
397
|
-
pricing: {
|
|
398
|
-
prompt: computeUsage("$0.02 / 1M tokens"),
|
|
399
|
-
// TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
|
|
400
|
-
output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
|
|
401
|
-
},
|
|
402
|
-
},
|
|
403
|
-
/**/
|
|
404
|
-
/**/
|
|
405
|
-
{
|
|
406
|
-
modelVariant: 'CHAT',
|
|
407
|
-
modelTitle: 'gpt-3.5-turbo-0613',
|
|
408
|
-
modelName: 'gpt-3.5-turbo-0613',
|
|
409
|
-
pricing: {
|
|
410
|
-
prompt: computeUsage("$1.50 / 1M tokens"),
|
|
411
|
-
output: computeUsage("$2.00 / 1M tokens"),
|
|
412
|
-
},
|
|
413
|
-
},
|
|
414
|
-
/**/
|
|
415
|
-
/**/
|
|
416
|
-
{
|
|
417
|
-
modelVariant: 'EMBEDDING',
|
|
418
|
-
modelTitle: 'text-embedding-ada-002',
|
|
419
|
-
modelName: 'text-embedding-ada-002',
|
|
420
|
-
pricing: {
|
|
421
|
-
prompt: computeUsage("$0.1 / 1M tokens"),
|
|
422
|
-
// TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
|
|
423
|
-
output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
|
|
424
|
-
},
|
|
425
|
-
},
|
|
426
|
-
/**/
|
|
427
|
-
/*/
|
|
428
|
-
{
|
|
429
|
-
modelVariant: 'CHAT',
|
|
430
|
-
modelTitle: 'gpt-4-1106-vision-preview',
|
|
431
|
-
modelName: 'gpt-4-1106-vision-preview',
|
|
432
|
-
},
|
|
433
|
-
/**/
|
|
434
|
-
/*/
|
|
435
|
-
{
|
|
436
|
-
modelVariant: 'CHAT',
|
|
437
|
-
modelTitle: 'gpt-4-vision-preview',
|
|
438
|
-
modelName: 'gpt-4-vision-preview',
|
|
439
|
-
pricing: {
|
|
440
|
-
prompt: computeUsage(`$10.00 / 1M tokens`),
|
|
441
|
-
output: computeUsage(`$30.00 / 1M tokens`),
|
|
442
|
-
},
|
|
443
|
-
},
|
|
444
|
-
/**/
|
|
445
|
-
/**/
|
|
446
|
-
{
|
|
447
|
-
modelVariant: 'CHAT',
|
|
448
|
-
modelTitle: 'gpt-4o-2024-05-13',
|
|
449
|
-
modelName: 'gpt-4o-2024-05-13',
|
|
450
|
-
pricing: {
|
|
451
|
-
prompt: computeUsage("$5.00 / 1M tokens"),
|
|
452
|
-
output: computeUsage("$15.00 / 1M tokens"),
|
|
453
|
-
},
|
|
454
|
-
},
|
|
455
|
-
/**/
|
|
456
|
-
/**/
|
|
457
|
-
{
|
|
458
|
-
modelVariant: 'CHAT',
|
|
459
|
-
modelTitle: 'gpt-4o',
|
|
460
|
-
modelName: 'gpt-4o',
|
|
461
|
-
pricing: {
|
|
462
|
-
prompt: computeUsage("$5.00 / 1M tokens"),
|
|
463
|
-
output: computeUsage("$15.00 / 1M tokens"),
|
|
464
|
-
},
|
|
465
|
-
},
|
|
466
|
-
/**/
|
|
467
|
-
/**/
|
|
468
|
-
{
|
|
469
|
-
modelVariant: 'CHAT',
|
|
470
|
-
modelTitle: 'gpt-3.5-turbo-16k-0613',
|
|
471
|
-
modelName: 'gpt-3.5-turbo-16k-0613',
|
|
472
|
-
pricing: {
|
|
473
|
-
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
474
|
-
output: computeUsage("$4.00 / 1M tokens"),
|
|
475
|
-
},
|
|
476
|
-
},
|
|
477
|
-
/**/
|
|
478
|
-
];
|
|
479
|
-
/**
|
|
480
|
-
* Note: [🤖] Add models of new variant
|
|
481
|
-
* TODO: [🧠] Some mechanism to propagate unsureness
|
|
482
|
-
* TODO: [🎰] Some mechanism to auto-update available models
|
|
483
|
-
* TODO: [🎰][👮♀️] Make this list dynamic - dynamically can be listed modelNames but not modelVariant, legacy status, context length and pricing
|
|
484
|
-
* TODO: [🧠][👮♀️] Put here more info like description, isVision, trainingDateCutoff, languages, strengths ( Top-level performance, intelligence, fluency, and understanding), contextWindow,...
|
|
485
|
-
* @see https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4
|
|
486
|
-
* @see https://openai.com/api/pricing/
|
|
487
|
-
* @see /other/playground/playground.ts
|
|
488
|
-
* TODO: [🍓] Make better
|
|
489
|
-
* TODO: Change model titles to human eg: "gpt-4-turbo-2024-04-09" -> "GPT-4 Turbo (2024-04-09)"
|
|
490
|
-
* TODO: [🚸] Not all models are compatible with JSON mode, add this information here and use it
|
|
491
|
-
*/
|
|
492
|
-
|
|
493
131
|
/**
|
|
494
132
|
* This error indicates errors during the execution of the pipeline
|
|
495
133
|
*
|
|
@@ -605,6 +243,9 @@ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
|
605
243
|
* @private within the repository
|
|
606
244
|
*/
|
|
607
245
|
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
246
|
+
/**
|
|
247
|
+
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
248
|
+
*/
|
|
608
249
|
|
|
609
250
|
/**
|
|
610
251
|
* This error type indicates that some limit was reached
|
|
@@ -854,222 +495,584 @@ var defaultDiacriticsRemovalMap = [
|
|
|
854
495
|
},
|
|
855
496
|
{ base: 'TZ', letters: '\uA728' },
|
|
856
497
|
{
|
|
857
|
-
base: 'U',
|
|
858
|
-
letters: '\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244',
|
|
498
|
+
base: 'U',
|
|
499
|
+
letters: '\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244',
|
|
500
|
+
},
|
|
501
|
+
{ base: 'V', letters: '\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245' },
|
|
502
|
+
{ base: 'VY', letters: '\uA760' },
|
|
503
|
+
{
|
|
504
|
+
base: 'W',
|
|
505
|
+
letters: '\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72',
|
|
506
|
+
},
|
|
507
|
+
{ base: 'X', letters: '\u0058\u24CD\uFF38\u1E8A\u1E8C' },
|
|
508
|
+
{
|
|
509
|
+
base: 'Y',
|
|
510
|
+
letters: '\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE',
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
base: 'Z',
|
|
514
|
+
letters: '\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762',
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
base: 'a',
|
|
518
|
+
letters: '\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250',
|
|
519
|
+
},
|
|
520
|
+
{ base: 'aa', letters: '\uA733' },
|
|
521
|
+
{ base: 'ae', letters: '\u00E6\u01FD\u01E3' },
|
|
522
|
+
{ base: 'ao', letters: '\uA735' },
|
|
523
|
+
{ base: 'au', letters: '\uA737' },
|
|
524
|
+
{ base: 'av', letters: '\uA739\uA73B' },
|
|
525
|
+
{ base: 'ay', letters: '\uA73D' },
|
|
526
|
+
{
|
|
527
|
+
base: 'b',
|
|
528
|
+
letters: '\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253',
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
base: 'c',
|
|
532
|
+
letters: '\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184',
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
base: 'd',
|
|
536
|
+
letters: '\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A',
|
|
537
|
+
},
|
|
538
|
+
{ base: 'dz', letters: '\u01F3\u01C6' },
|
|
539
|
+
{
|
|
540
|
+
base: 'e',
|
|
541
|
+
letters: '\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD',
|
|
542
|
+
},
|
|
543
|
+
{ base: 'f', letters: '\u0066\u24D5\uFF46\u1E1F\u0192\uA77C' },
|
|
544
|
+
{
|
|
545
|
+
base: 'g',
|
|
546
|
+
letters: '\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F',
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
base: 'h',
|
|
550
|
+
letters: '\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265',
|
|
551
|
+
},
|
|
552
|
+
{ base: 'hv', letters: '\u0195' },
|
|
553
|
+
{
|
|
554
|
+
base: 'i',
|
|
555
|
+
letters: '\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131',
|
|
556
|
+
},
|
|
557
|
+
{ base: 'j', letters: '\u006A\u24D9\uFF4A\u0135\u01F0\u0249' },
|
|
558
|
+
{
|
|
559
|
+
base: 'k',
|
|
560
|
+
letters: '\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3',
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
base: 'l',
|
|
564
|
+
letters: '\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747',
|
|
565
|
+
},
|
|
566
|
+
{ base: 'lj', letters: '\u01C9' },
|
|
567
|
+
{ base: 'm', letters: '\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F' },
|
|
568
|
+
{
|
|
569
|
+
base: 'n',
|
|
570
|
+
letters: '\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5',
|
|
571
|
+
},
|
|
572
|
+
{ base: 'nj', letters: '\u01CC' },
|
|
573
|
+
{
|
|
574
|
+
base: 'o',
|
|
575
|
+
letters: '\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275',
|
|
576
|
+
},
|
|
577
|
+
{ base: 'oi', letters: '\u01A3' },
|
|
578
|
+
{ base: 'ou', letters: '\u0223' },
|
|
579
|
+
{ base: 'oo', letters: '\uA74F' },
|
|
580
|
+
{
|
|
581
|
+
base: 'p',
|
|
582
|
+
letters: '\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755',
|
|
583
|
+
},
|
|
584
|
+
{ base: 'q', letters: '\u0071\u24E0\uFF51\u024B\uA757\uA759' },
|
|
585
|
+
{
|
|
586
|
+
base: 'r',
|
|
587
|
+
letters: '\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783',
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
base: 's',
|
|
591
|
+
letters: '\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B',
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
base: 't',
|
|
595
|
+
letters: '\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787',
|
|
596
|
+
},
|
|
597
|
+
{ base: 'tz', letters: '\uA729' },
|
|
598
|
+
{
|
|
599
|
+
base: 'u',
|
|
600
|
+
letters: '\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289',
|
|
601
|
+
},
|
|
602
|
+
{ base: 'v', letters: '\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C' },
|
|
603
|
+
{ base: 'vy', letters: '\uA761' },
|
|
604
|
+
{
|
|
605
|
+
base: 'w',
|
|
606
|
+
letters: '\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73',
|
|
607
|
+
},
|
|
608
|
+
{ base: 'x', letters: '\u0078\u24E7\uFF58\u1E8B\u1E8D' },
|
|
609
|
+
{
|
|
610
|
+
base: 'y',
|
|
611
|
+
letters: '\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF',
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
base: 'z',
|
|
615
|
+
letters: '\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763',
|
|
616
|
+
},
|
|
617
|
+
];
|
|
618
|
+
/**
|
|
619
|
+
* Map of letters from diacritic variant to diacritless variant
|
|
620
|
+
* Contains lowercase and uppercase separatelly
|
|
621
|
+
*
|
|
622
|
+
* > "á" => "a"
|
|
623
|
+
* > "ě" => "e"
|
|
624
|
+
* > "Ă" => "A"
|
|
625
|
+
* > ...
|
|
626
|
+
*
|
|
627
|
+
* @public exported from `@promptbook/utils`
|
|
628
|
+
*/
|
|
629
|
+
var DIACRITIC_VARIANTS_LETTERS = {};
|
|
630
|
+
// tslint:disable-next-line: prefer-for-of
|
|
631
|
+
for (var i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
632
|
+
var letters = defaultDiacriticsRemovalMap[i].letters;
|
|
633
|
+
// tslint:disable-next-line: prefer-for-of
|
|
634
|
+
for (var j = 0; j < letters.length; j++) {
|
|
635
|
+
DIACRITIC_VARIANTS_LETTERS[letters[j]] = defaultDiacriticsRemovalMap[i].base;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
// <- TODO: [🍓] Put to maker function to save execution time if not needed
|
|
639
|
+
/*
|
|
640
|
+
@see https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
|
|
641
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
642
|
+
you may not use this file except in compliance with the License.
|
|
643
|
+
You may obtain a copy of the License at
|
|
644
|
+
|
|
645
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
646
|
+
|
|
647
|
+
Unless required by applicable law or agreed to in writing, software
|
|
648
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
649
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
650
|
+
See the License for the specific language governing permissions and
|
|
651
|
+
limitations under the License.
|
|
652
|
+
*/
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* @@@
|
|
656
|
+
*
|
|
657
|
+
* @param input @@@
|
|
658
|
+
* @returns @@@
|
|
659
|
+
* @public exported from `@promptbook/utils`
|
|
660
|
+
*/
|
|
661
|
+
function removeDiacritics(input) {
|
|
662
|
+
/*eslint no-control-regex: "off"*/
|
|
663
|
+
return input.replace(/[^\u0000-\u007E]/g, function (a) {
|
|
664
|
+
return DIACRITIC_VARIANTS_LETTERS[a] || a;
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* TODO: [Ж] Variant for cyrillic (and in general non-latin) letters
|
|
669
|
+
*/
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Counts number of words in the text
|
|
673
|
+
*
|
|
674
|
+
* @public exported from `@promptbook/utils`
|
|
675
|
+
*/
|
|
676
|
+
function countWords(text) {
|
|
677
|
+
text = text.replace(/[\p{Extended_Pictographic}]/gu, 'a');
|
|
678
|
+
text = removeDiacritics(text);
|
|
679
|
+
return text.split(/[^a-zа-я0-9]+/i).filter(function (word) { return word.length > 0; }).length;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Helper of usage compute
|
|
684
|
+
*
|
|
685
|
+
* @param content the content of prompt or response
|
|
686
|
+
* @returns part of PromptResultUsageCounts
|
|
687
|
+
*
|
|
688
|
+
* @private internal utility of LlmExecutionTools
|
|
689
|
+
*/
|
|
690
|
+
function computeUsageCounts(content) {
|
|
691
|
+
return {
|
|
692
|
+
charactersCount: { value: countCharacters(content) },
|
|
693
|
+
wordsCount: { value: countWords(content) },
|
|
694
|
+
sentencesCount: { value: countSentences(content) },
|
|
695
|
+
linesCount: { value: countLines(content) },
|
|
696
|
+
paragraphsCount: { value: countParagraphs(content) },
|
|
697
|
+
pagesCount: { value: countPages(content) },
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Make UncertainNumber
|
|
703
|
+
*
|
|
704
|
+
* @param value
|
|
705
|
+
*
|
|
706
|
+
* @private utility for initializating UncertainNumber
|
|
707
|
+
*/
|
|
708
|
+
function uncertainNumber(value) {
|
|
709
|
+
if (value === null || value === undefined || Number.isNaN(value)) {
|
|
710
|
+
return { value: 0, isUncertain: true };
|
|
711
|
+
}
|
|
712
|
+
return { value: value };
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Function computeUsage will create price per one token based on the string value found on openai page
|
|
717
|
+
*
|
|
718
|
+
* @private within the repository, used only as internal helper for `OPENAI_MODELS`
|
|
719
|
+
*/
|
|
720
|
+
function computeUsage(value) {
|
|
721
|
+
var _a = __read(value.split(' / '), 2), price = _a[0], tokens = _a[1];
|
|
722
|
+
return parseFloat(price.replace('$', '')) / parseFloat(tokens.replace('M tokens', '')) / 1000000;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* List of available OpenAI models with pricing
|
|
727
|
+
*
|
|
728
|
+
* Note: Done at 2024-05-20
|
|
729
|
+
*
|
|
730
|
+
* @see https://platform.openai.com/docs/models/
|
|
731
|
+
* @see https://openai.com/api/pricing/
|
|
732
|
+
* @public exported from `@promptbook/openai`
|
|
733
|
+
*/
|
|
734
|
+
var OPENAI_MODELS = [
|
|
735
|
+
/*/
|
|
736
|
+
{
|
|
737
|
+
modelTitle: 'dall-e-3',
|
|
738
|
+
modelName: 'dall-e-3',
|
|
739
|
+
},
|
|
740
|
+
/**/
|
|
741
|
+
/*/
|
|
742
|
+
{
|
|
743
|
+
modelTitle: 'whisper-1',
|
|
744
|
+
modelName: 'whisper-1',
|
|
745
|
+
},
|
|
746
|
+
/**/
|
|
747
|
+
/**/
|
|
748
|
+
{
|
|
749
|
+
modelVariant: 'COMPLETION',
|
|
750
|
+
modelTitle: 'davinci-002',
|
|
751
|
+
modelName: 'davinci-002',
|
|
752
|
+
pricing: {
|
|
753
|
+
prompt: computeUsage("$2.00 / 1M tokens"),
|
|
754
|
+
output: computeUsage("$2.00 / 1M tokens"), // <- not sure
|
|
755
|
+
},
|
|
859
756
|
},
|
|
860
|
-
|
|
861
|
-
|
|
757
|
+
/**/
|
|
758
|
+
/*/
|
|
759
|
+
{
|
|
760
|
+
modelTitle: 'dall-e-2',
|
|
761
|
+
modelName: 'dall-e-2',
|
|
762
|
+
},
|
|
763
|
+
/**/
|
|
764
|
+
/**/
|
|
862
765
|
{
|
|
863
|
-
|
|
864
|
-
|
|
766
|
+
modelVariant: 'CHAT',
|
|
767
|
+
modelTitle: 'gpt-3.5-turbo-16k',
|
|
768
|
+
modelName: 'gpt-3.5-turbo-16k',
|
|
769
|
+
pricing: {
|
|
770
|
+
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
771
|
+
output: computeUsage("$4.00 / 1M tokens"),
|
|
772
|
+
},
|
|
865
773
|
},
|
|
866
|
-
|
|
774
|
+
/**/
|
|
775
|
+
/*/
|
|
776
|
+
{
|
|
777
|
+
modelTitle: 'tts-1-hd-1106',
|
|
778
|
+
modelName: 'tts-1-hd-1106',
|
|
779
|
+
},
|
|
780
|
+
/**/
|
|
781
|
+
/*/
|
|
782
|
+
{
|
|
783
|
+
modelTitle: 'tts-1-hd',
|
|
784
|
+
modelName: 'tts-1-hd',
|
|
785
|
+
},
|
|
786
|
+
/**/
|
|
787
|
+
/**/
|
|
867
788
|
{
|
|
868
|
-
|
|
869
|
-
|
|
789
|
+
modelVariant: 'CHAT',
|
|
790
|
+
modelTitle: 'gpt-4',
|
|
791
|
+
modelName: 'gpt-4',
|
|
792
|
+
pricing: {
|
|
793
|
+
prompt: computeUsage("$30.00 / 1M tokens"),
|
|
794
|
+
output: computeUsage("$60.00 / 1M tokens"),
|
|
795
|
+
},
|
|
870
796
|
},
|
|
797
|
+
/**/
|
|
798
|
+
/**/
|
|
871
799
|
{
|
|
872
|
-
|
|
873
|
-
|
|
800
|
+
modelVariant: 'CHAT',
|
|
801
|
+
modelTitle: 'gpt-4-32k',
|
|
802
|
+
modelName: 'gpt-4-32k',
|
|
803
|
+
pricing: {
|
|
804
|
+
prompt: computeUsage("$60.00 / 1M tokens"),
|
|
805
|
+
output: computeUsage("$120.00 / 1M tokens"),
|
|
806
|
+
},
|
|
874
807
|
},
|
|
808
|
+
/**/
|
|
809
|
+
/*/
|
|
875
810
|
{
|
|
876
|
-
|
|
877
|
-
|
|
811
|
+
modelVariant: 'CHAT',
|
|
812
|
+
modelTitle: 'gpt-4-0613',
|
|
813
|
+
modelName: 'gpt-4-0613',
|
|
814
|
+
pricing: {
|
|
815
|
+
prompt: computeUsage(` / 1M tokens`),
|
|
816
|
+
output: computeUsage(` / 1M tokens`),
|
|
817
|
+
},
|
|
878
818
|
},
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
{ base: 'ao', letters: '\uA735' },
|
|
882
|
-
{ base: 'au', letters: '\uA737' },
|
|
883
|
-
{ base: 'av', letters: '\uA739\uA73B' },
|
|
884
|
-
{ base: 'ay', letters: '\uA73D' },
|
|
819
|
+
/**/
|
|
820
|
+
/**/
|
|
885
821
|
{
|
|
886
|
-
|
|
887
|
-
|
|
822
|
+
modelVariant: 'CHAT',
|
|
823
|
+
modelTitle: 'gpt-4-turbo-2024-04-09',
|
|
824
|
+
modelName: 'gpt-4-turbo-2024-04-09',
|
|
825
|
+
pricing: {
|
|
826
|
+
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
827
|
+
output: computeUsage("$30.00 / 1M tokens"),
|
|
828
|
+
},
|
|
888
829
|
},
|
|
830
|
+
/**/
|
|
831
|
+
/**/
|
|
889
832
|
{
|
|
890
|
-
|
|
891
|
-
|
|
833
|
+
modelVariant: 'CHAT',
|
|
834
|
+
modelTitle: 'gpt-3.5-turbo-1106',
|
|
835
|
+
modelName: 'gpt-3.5-turbo-1106',
|
|
836
|
+
pricing: {
|
|
837
|
+
prompt: computeUsage("$1.00 / 1M tokens"),
|
|
838
|
+
output: computeUsage("$2.00 / 1M tokens"),
|
|
839
|
+
},
|
|
892
840
|
},
|
|
841
|
+
/**/
|
|
842
|
+
/**/
|
|
893
843
|
{
|
|
894
|
-
|
|
895
|
-
|
|
844
|
+
modelVariant: 'CHAT',
|
|
845
|
+
modelTitle: 'gpt-4-turbo',
|
|
846
|
+
modelName: 'gpt-4-turbo',
|
|
847
|
+
pricing: {
|
|
848
|
+
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
849
|
+
output: computeUsage("$30.00 / 1M tokens"),
|
|
850
|
+
},
|
|
896
851
|
},
|
|
897
|
-
|
|
852
|
+
/**/
|
|
853
|
+
/**/
|
|
898
854
|
{
|
|
899
|
-
|
|
900
|
-
|
|
855
|
+
modelVariant: 'COMPLETION',
|
|
856
|
+
modelTitle: 'gpt-3.5-turbo-instruct-0914',
|
|
857
|
+
modelName: 'gpt-3.5-turbo-instruct-0914',
|
|
858
|
+
pricing: {
|
|
859
|
+
prompt: computeUsage("$1.50 / 1M tokens"),
|
|
860
|
+
output: computeUsage("$2.00 / 1M tokens"), // <- For gpt-3.5-turbo-instruct
|
|
861
|
+
},
|
|
901
862
|
},
|
|
902
|
-
|
|
863
|
+
/**/
|
|
864
|
+
/**/
|
|
903
865
|
{
|
|
904
|
-
|
|
905
|
-
|
|
866
|
+
modelVariant: 'COMPLETION',
|
|
867
|
+
modelTitle: 'gpt-3.5-turbo-instruct',
|
|
868
|
+
modelName: 'gpt-3.5-turbo-instruct',
|
|
869
|
+
pricing: {
|
|
870
|
+
prompt: computeUsage("$1.50 / 1M tokens"),
|
|
871
|
+
output: computeUsage("$2.00 / 1M tokens"),
|
|
872
|
+
},
|
|
906
873
|
},
|
|
874
|
+
/**/
|
|
875
|
+
/*/
|
|
876
|
+
{
|
|
877
|
+
modelTitle: 'tts-1',
|
|
878
|
+
modelName: 'tts-1',
|
|
879
|
+
},
|
|
880
|
+
/**/
|
|
881
|
+
/**/
|
|
907
882
|
{
|
|
908
|
-
|
|
909
|
-
|
|
883
|
+
modelVariant: 'CHAT',
|
|
884
|
+
modelTitle: 'gpt-3.5-turbo',
|
|
885
|
+
modelName: 'gpt-3.5-turbo',
|
|
886
|
+
pricing: {
|
|
887
|
+
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
888
|
+
output: computeUsage("$6.00 / 1M tokens"), // <- Not sure, refer to gpt-3.5-turbo in Fine-tuning models
|
|
889
|
+
},
|
|
910
890
|
},
|
|
911
|
-
|
|
891
|
+
/**/
|
|
892
|
+
/**/
|
|
912
893
|
{
|
|
913
|
-
|
|
914
|
-
|
|
894
|
+
modelVariant: 'CHAT',
|
|
895
|
+
modelTitle: 'gpt-3.5-turbo-0301',
|
|
896
|
+
modelName: 'gpt-3.5-turbo-0301',
|
|
897
|
+
pricing: {
|
|
898
|
+
prompt: computeUsage("$1.50 / 1M tokens"),
|
|
899
|
+
output: computeUsage("$2.00 / 1M tokens"),
|
|
900
|
+
},
|
|
915
901
|
},
|
|
916
|
-
|
|
902
|
+
/**/
|
|
903
|
+
/**/
|
|
917
904
|
{
|
|
918
|
-
|
|
919
|
-
|
|
905
|
+
modelVariant: 'COMPLETION',
|
|
906
|
+
modelTitle: 'babbage-002',
|
|
907
|
+
modelName: 'babbage-002',
|
|
908
|
+
pricing: {
|
|
909
|
+
prompt: computeUsage("$0.40 / 1M tokens"),
|
|
910
|
+
output: computeUsage("$0.40 / 1M tokens"), // <- Not sure
|
|
911
|
+
},
|
|
920
912
|
},
|
|
913
|
+
/**/
|
|
914
|
+
/**/
|
|
921
915
|
{
|
|
922
|
-
|
|
923
|
-
|
|
916
|
+
modelVariant: 'CHAT',
|
|
917
|
+
modelTitle: 'gpt-4-1106-preview',
|
|
918
|
+
modelName: 'gpt-4-1106-preview',
|
|
919
|
+
pricing: {
|
|
920
|
+
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
921
|
+
output: computeUsage("$30.00 / 1M tokens"),
|
|
922
|
+
},
|
|
924
923
|
},
|
|
925
|
-
|
|
926
|
-
|
|
924
|
+
/**/
|
|
925
|
+
/**/
|
|
927
926
|
{
|
|
928
|
-
|
|
929
|
-
|
|
927
|
+
modelVariant: 'CHAT',
|
|
928
|
+
modelTitle: 'gpt-4-0125-preview',
|
|
929
|
+
modelName: 'gpt-4-0125-preview',
|
|
930
|
+
pricing: {
|
|
931
|
+
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
932
|
+
output: computeUsage("$30.00 / 1M tokens"),
|
|
933
|
+
},
|
|
930
934
|
},
|
|
931
|
-
|
|
935
|
+
/**/
|
|
936
|
+
/*/
|
|
937
|
+
{
|
|
938
|
+
modelTitle: 'tts-1-1106',
|
|
939
|
+
modelName: 'tts-1-1106',
|
|
940
|
+
},
|
|
941
|
+
/**/
|
|
942
|
+
/**/
|
|
932
943
|
{
|
|
933
|
-
|
|
934
|
-
|
|
944
|
+
modelVariant: 'CHAT',
|
|
945
|
+
modelTitle: 'gpt-3.5-turbo-0125',
|
|
946
|
+
modelName: 'gpt-3.5-turbo-0125',
|
|
947
|
+
pricing: {
|
|
948
|
+
prompt: computeUsage("$0.50 / 1M tokens"),
|
|
949
|
+
output: computeUsage("$1.50 / 1M tokens"),
|
|
950
|
+
},
|
|
935
951
|
},
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
{ base: 'oo', letters: '\uA74F' },
|
|
952
|
+
/**/
|
|
953
|
+
/**/
|
|
939
954
|
{
|
|
940
|
-
|
|
941
|
-
|
|
955
|
+
modelVariant: 'CHAT',
|
|
956
|
+
modelTitle: 'gpt-4-turbo-preview',
|
|
957
|
+
modelName: 'gpt-4-turbo-preview',
|
|
958
|
+
pricing: {
|
|
959
|
+
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
960
|
+
output: computeUsage("$30.00 / 1M tokens"), // <- Not sure, just for gpt-4-turbo
|
|
961
|
+
},
|
|
942
962
|
},
|
|
943
|
-
|
|
963
|
+
/**/
|
|
964
|
+
/**/
|
|
944
965
|
{
|
|
945
|
-
|
|
946
|
-
|
|
966
|
+
modelVariant: 'EMBEDDING',
|
|
967
|
+
modelTitle: 'text-embedding-3-large',
|
|
968
|
+
modelName: 'text-embedding-3-large',
|
|
969
|
+
pricing: {
|
|
970
|
+
prompt: computeUsage("$0.13 / 1M tokens"),
|
|
971
|
+
// TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
|
|
972
|
+
output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
|
|
973
|
+
},
|
|
947
974
|
},
|
|
975
|
+
/**/
|
|
976
|
+
/**/
|
|
948
977
|
{
|
|
949
|
-
|
|
950
|
-
|
|
978
|
+
modelVariant: 'EMBEDDING',
|
|
979
|
+
modelTitle: 'text-embedding-3-small',
|
|
980
|
+
modelName: 'text-embedding-3-small',
|
|
981
|
+
pricing: {
|
|
982
|
+
prompt: computeUsage("$0.02 / 1M tokens"),
|
|
983
|
+
// TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
|
|
984
|
+
output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
|
|
985
|
+
},
|
|
951
986
|
},
|
|
987
|
+
/**/
|
|
988
|
+
/**/
|
|
952
989
|
{
|
|
953
|
-
|
|
954
|
-
|
|
990
|
+
modelVariant: 'CHAT',
|
|
991
|
+
modelTitle: 'gpt-3.5-turbo-0613',
|
|
992
|
+
modelName: 'gpt-3.5-turbo-0613',
|
|
993
|
+
pricing: {
|
|
994
|
+
prompt: computeUsage("$1.50 / 1M tokens"),
|
|
995
|
+
output: computeUsage("$2.00 / 1M tokens"),
|
|
996
|
+
},
|
|
955
997
|
},
|
|
956
|
-
|
|
998
|
+
/**/
|
|
999
|
+
/**/
|
|
957
1000
|
{
|
|
958
|
-
|
|
959
|
-
|
|
1001
|
+
modelVariant: 'EMBEDDING',
|
|
1002
|
+
modelTitle: 'text-embedding-ada-002',
|
|
1003
|
+
modelName: 'text-embedding-ada-002',
|
|
1004
|
+
pricing: {
|
|
1005
|
+
prompt: computeUsage("$0.1 / 1M tokens"),
|
|
1006
|
+
// TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
|
|
1007
|
+
output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
|
|
1008
|
+
},
|
|
960
1009
|
},
|
|
961
|
-
|
|
962
|
-
|
|
1010
|
+
/**/
|
|
1011
|
+
/*/
|
|
1012
|
+
{
|
|
1013
|
+
modelVariant: 'CHAT',
|
|
1014
|
+
modelTitle: 'gpt-4-1106-vision-preview',
|
|
1015
|
+
modelName: 'gpt-4-1106-vision-preview',
|
|
1016
|
+
},
|
|
1017
|
+
/**/
|
|
1018
|
+
/*/
|
|
1019
|
+
{
|
|
1020
|
+
modelVariant: 'CHAT',
|
|
1021
|
+
modelTitle: 'gpt-4-vision-preview',
|
|
1022
|
+
modelName: 'gpt-4-vision-preview',
|
|
1023
|
+
pricing: {
|
|
1024
|
+
prompt: computeUsage(`$10.00 / 1M tokens`),
|
|
1025
|
+
output: computeUsage(`$30.00 / 1M tokens`),
|
|
1026
|
+
},
|
|
1027
|
+
},
|
|
1028
|
+
/**/
|
|
1029
|
+
/**/
|
|
963
1030
|
{
|
|
964
|
-
|
|
965
|
-
|
|
1031
|
+
modelVariant: 'CHAT',
|
|
1032
|
+
modelTitle: 'gpt-4o-2024-05-13',
|
|
1033
|
+
modelName: 'gpt-4o-2024-05-13',
|
|
1034
|
+
pricing: {
|
|
1035
|
+
prompt: computeUsage("$5.00 / 1M tokens"),
|
|
1036
|
+
output: computeUsage("$15.00 / 1M tokens"),
|
|
1037
|
+
},
|
|
966
1038
|
},
|
|
967
|
-
|
|
1039
|
+
/**/
|
|
1040
|
+
/**/
|
|
968
1041
|
{
|
|
969
|
-
|
|
970
|
-
|
|
1042
|
+
modelVariant: 'CHAT',
|
|
1043
|
+
modelTitle: 'gpt-4o',
|
|
1044
|
+
modelName: 'gpt-4o',
|
|
1045
|
+
pricing: {
|
|
1046
|
+
prompt: computeUsage("$5.00 / 1M tokens"),
|
|
1047
|
+
output: computeUsage("$15.00 / 1M tokens"),
|
|
1048
|
+
},
|
|
971
1049
|
},
|
|
1050
|
+
/**/
|
|
1051
|
+
/**/
|
|
972
1052
|
{
|
|
973
|
-
|
|
974
|
-
|
|
1053
|
+
modelVariant: 'CHAT',
|
|
1054
|
+
modelTitle: 'gpt-3.5-turbo-16k-0613',
|
|
1055
|
+
modelName: 'gpt-3.5-turbo-16k-0613',
|
|
1056
|
+
pricing: {
|
|
1057
|
+
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
1058
|
+
output: computeUsage("$4.00 / 1M tokens"),
|
|
1059
|
+
},
|
|
975
1060
|
},
|
|
1061
|
+
/**/
|
|
976
1062
|
];
|
|
977
1063
|
/**
|
|
978
|
-
*
|
|
979
|
-
*
|
|
980
|
-
*
|
|
981
|
-
*
|
|
982
|
-
*
|
|
983
|
-
*
|
|
984
|
-
*
|
|
985
|
-
*
|
|
986
|
-
*
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
// tslint:disable-next-line: prefer-for-of
|
|
990
|
-
for (var i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
991
|
-
var letters = defaultDiacriticsRemovalMap[i].letters;
|
|
992
|
-
// tslint:disable-next-line: prefer-for-of
|
|
993
|
-
for (var j = 0; j < letters.length; j++) {
|
|
994
|
-
DIACRITIC_VARIANTS_LETTERS[letters[j]] = defaultDiacriticsRemovalMap[i].base;
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
// <- TODO: [🍓] Put to maker function to save execution time if not needed
|
|
998
|
-
/*
|
|
999
|
-
@see https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
|
|
1000
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
1001
|
-
you may not use this file except in compliance with the License.
|
|
1002
|
-
You may obtain a copy of the License at
|
|
1003
|
-
|
|
1004
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
1005
|
-
|
|
1006
|
-
Unless required by applicable law or agreed to in writing, software
|
|
1007
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
1008
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1009
|
-
See the License for the specific language governing permissions and
|
|
1010
|
-
limitations under the License.
|
|
1011
|
-
*/
|
|
1012
|
-
|
|
1013
|
-
/**
|
|
1014
|
-
* @@@
|
|
1015
|
-
*
|
|
1016
|
-
* @param input @@@
|
|
1017
|
-
* @returns @@@
|
|
1018
|
-
* @public exported from `@promptbook/utils`
|
|
1019
|
-
*/
|
|
1020
|
-
function removeDiacritics(input) {
|
|
1021
|
-
/*eslint no-control-regex: "off"*/
|
|
1022
|
-
return input.replace(/[^\u0000-\u007E]/g, function (a) {
|
|
1023
|
-
return DIACRITIC_VARIANTS_LETTERS[a] || a;
|
|
1024
|
-
});
|
|
1025
|
-
}
|
|
1026
|
-
/**
|
|
1027
|
-
* TODO: [Ж] Variant for cyrillic (and in general non-latin) letters
|
|
1028
|
-
*/
|
|
1029
|
-
|
|
1030
|
-
/**
|
|
1031
|
-
* Counts number of words in the text
|
|
1032
|
-
*
|
|
1033
|
-
* @public exported from `@promptbook/utils`
|
|
1034
|
-
*/
|
|
1035
|
-
function countWords(text) {
|
|
1036
|
-
text = text.replace(/[\p{Extended_Pictographic}]/gu, 'a');
|
|
1037
|
-
text = removeDiacritics(text);
|
|
1038
|
-
return text.split(/[^a-zа-я0-9]+/i).filter(function (word) { return word.length > 0; }).length;
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
/**
|
|
1042
|
-
* Helper of usage compute
|
|
1043
|
-
*
|
|
1044
|
-
* @param content the content of prompt or response
|
|
1045
|
-
* @returns part of PromptResultUsageCounts
|
|
1046
|
-
*
|
|
1047
|
-
* @private internal utility of LlmExecutionTools
|
|
1048
|
-
*/
|
|
1049
|
-
function computeUsageCounts(content) {
|
|
1050
|
-
return {
|
|
1051
|
-
charactersCount: { value: countCharacters(content) },
|
|
1052
|
-
wordsCount: { value: countWords(content) },
|
|
1053
|
-
sentencesCount: { value: countSentences(content) },
|
|
1054
|
-
linesCount: { value: countLines(content) },
|
|
1055
|
-
paragraphsCount: { value: countParagraphs(content) },
|
|
1056
|
-
pagesCount: { value: countPages(content) },
|
|
1057
|
-
};
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
/**
|
|
1061
|
-
* Make UncertainNumber
|
|
1062
|
-
*
|
|
1063
|
-
* @param value
|
|
1064
|
-
*
|
|
1065
|
-
* @private utility for initializating UncertainNumber
|
|
1064
|
+
* Note: [🤖] Add models of new variant
|
|
1065
|
+
* TODO: [🧠] Some mechanism to propagate unsureness
|
|
1066
|
+
* TODO: [🎰] Some mechanism to auto-update available models
|
|
1067
|
+
* TODO: [🎰][👮♀️] Make this list dynamic - dynamically can be listed modelNames but not modelVariant, legacy status, context length and pricing
|
|
1068
|
+
* TODO: [🧠][👮♀️] Put here more info like description, isVision, trainingDateCutoff, languages, strengths ( Top-level performance, intelligence, fluency, and understanding), contextWindow,...
|
|
1069
|
+
* @see https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4
|
|
1070
|
+
* @see https://openai.com/api/pricing/
|
|
1071
|
+
* @see /other/playground/playground.ts
|
|
1072
|
+
* TODO: [🍓] Make better
|
|
1073
|
+
* TODO: Change model titles to human eg: "gpt-4-turbo-2024-04-09" -> "GPT-4 Turbo (2024-04-09)"
|
|
1074
|
+
* TODO: [🚸] Not all models are compatible with JSON mode, add this information here and use it
|
|
1066
1075
|
*/
|
|
1067
|
-
function uncertainNumber(value) {
|
|
1068
|
-
if (value === null || value === undefined || Number.isNaN(value)) {
|
|
1069
|
-
return { value: 0, isUncertain: true };
|
|
1070
|
-
}
|
|
1071
|
-
return { value: value };
|
|
1072
|
-
}
|
|
1073
1076
|
|
|
1074
1077
|
/**
|
|
1075
1078
|
* Computes the usage of the OpenAI API based on the response from OpenAI
|
|
@@ -1080,7 +1083,7 @@ function uncertainNumber(value) {
|
|
|
1080
1083
|
* @throws {PipelineExecutionError} If the usage is not defined in the response from OpenAI
|
|
1081
1084
|
* @private internal utility of `OpenAiExecutionTools`
|
|
1082
1085
|
*/
|
|
1083
|
-
function
|
|
1086
|
+
function computeOpenAiUsage(promptContent, // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer
|
|
1084
1087
|
resultContent, rawResponse) {
|
|
1085
1088
|
var _a, _b;
|
|
1086
1089
|
if (rawResponse.usage === undefined) {
|
|
@@ -1105,9 +1108,12 @@ resultContent, rawResponse) {
|
|
|
1105
1108
|
output: __assign({ tokensCount: uncertainNumber(outputTokens) }, computeUsageCounts(resultContent)),
|
|
1106
1109
|
};
|
|
1107
1110
|
}
|
|
1111
|
+
/**
|
|
1112
|
+
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
1113
|
+
*/
|
|
1108
1114
|
|
|
1109
1115
|
/**
|
|
1110
|
-
* Execution Tools for calling OpenAI API
|
|
1116
|
+
* Execution Tools for calling OpenAI API
|
|
1111
1117
|
*
|
|
1112
1118
|
* @public exported from `@promptbook/openai`
|
|
1113
1119
|
*/
|
|
@@ -1125,6 +1131,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
1125
1131
|
delete openAiOptions.isVerbose;
|
|
1126
1132
|
delete openAiOptions.user;
|
|
1127
1133
|
this.client = new OpenAI(__assign({}, openAiOptions));
|
|
1134
|
+
// <- TODO: !!!!!! Lazy-load client
|
|
1128
1135
|
}
|
|
1129
1136
|
Object.defineProperty(OpenAiExecutionTools.prototype, "title", {
|
|
1130
1137
|
get: function () {
|
|
@@ -1205,7 +1212,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
1205
1212
|
resultContent = rawResponse.choices[0].message.content;
|
|
1206
1213
|
// eslint-disable-next-line prefer-const
|
|
1207
1214
|
complete = getCurrentIsoDate();
|
|
1208
|
-
usage =
|
|
1215
|
+
usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
|
|
1209
1216
|
if (resultContent === null) {
|
|
1210
1217
|
throw new PipelineExecutionError('No response message from OpenAI');
|
|
1211
1218
|
}
|
|
@@ -1274,7 +1281,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
1274
1281
|
resultContent = rawResponse.choices[0].text;
|
|
1275
1282
|
// eslint-disable-next-line prefer-const
|
|
1276
1283
|
complete = getCurrentIsoDate();
|
|
1277
|
-
usage =
|
|
1284
|
+
usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
|
|
1278
1285
|
return [2 /*return*/, {
|
|
1279
1286
|
content: resultContent,
|
|
1280
1287
|
modelName: rawResponse.model || modelName,
|
|
@@ -1331,7 +1338,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
1331
1338
|
resultContent = rawResponse.data[0].embedding;
|
|
1332
1339
|
// eslint-disable-next-line prefer-const
|
|
1333
1340
|
complete = getCurrentIsoDate();
|
|
1334
|
-
usage =
|
|
1341
|
+
usage = computeOpenAiUsage(content, '', rawResponse);
|
|
1335
1342
|
return [2 /*return*/, {
|
|
1336
1343
|
content: resultContent,
|
|
1337
1344
|
modelName: rawResponse.model || modelName,
|
|
@@ -1405,10 +1412,71 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
1405
1412
|
/**
|
|
1406
1413
|
* TODO: [🧠][🧙♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
|
|
1407
1414
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
1408
|
-
* TODO: Maybe make custom
|
|
1415
|
+
* TODO: Maybe make custom OpenAiError
|
|
1409
1416
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
1410
1417
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
1411
1418
|
*/
|
|
1412
1419
|
|
|
1413
|
-
|
|
1420
|
+
/**
|
|
1421
|
+
* Execution Tools for calling OpenAI API
|
|
1422
|
+
*
|
|
1423
|
+
* @public exported from `@promptbook/openai`
|
|
1424
|
+
*/
|
|
1425
|
+
var createOpenAiExecutionTools = Object.assign(function (options) {
|
|
1426
|
+
// TODO: !!!!!! If browser, auto add `dangerouslyAllowBrowser`
|
|
1427
|
+
return new OpenAiExecutionTools(options);
|
|
1428
|
+
}, {
|
|
1429
|
+
packageName: '@promptbook/openai',
|
|
1430
|
+
className: 'OpenAiExecutionTools',
|
|
1431
|
+
});
|
|
1432
|
+
/**
|
|
1433
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
1434
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
1435
|
+
*/
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* Register is @@@
|
|
1439
|
+
*
|
|
1440
|
+
* @private internal utility, exported are only signleton instances of this class
|
|
1441
|
+
*/
|
|
1442
|
+
var Register = /** @class */ (function () {
|
|
1443
|
+
function Register(storage) {
|
|
1444
|
+
this.storage = storage;
|
|
1445
|
+
}
|
|
1446
|
+
Register.prototype.list = function () {
|
|
1447
|
+
// <- TODO: ReadonlyDeep<Array<TRegistered>>
|
|
1448
|
+
return this.storage;
|
|
1449
|
+
};
|
|
1450
|
+
Register.prototype.register = function (registered) {
|
|
1451
|
+
// !!!!!! <- TODO: What to return here
|
|
1452
|
+
// TODO: !!!!!! Compare if same is not already registered
|
|
1453
|
+
this.storage.push(registered);
|
|
1454
|
+
};
|
|
1455
|
+
return Register;
|
|
1456
|
+
}());
|
|
1457
|
+
|
|
1458
|
+
/**
|
|
1459
|
+
* @@@
|
|
1460
|
+
*
|
|
1461
|
+
* Note: `$` is used to indicate that this interacts with the global scope
|
|
1462
|
+
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
1463
|
+
* @public exported from `@promptbook/core`
|
|
1464
|
+
*/
|
|
1465
|
+
var $llmToolsRegister = new Register([
|
|
1466
|
+
// TODO: !!!!!! Take from global scope
|
|
1467
|
+
]);
|
|
1468
|
+
|
|
1469
|
+
/**
|
|
1470
|
+
* @@@ registration2
|
|
1471
|
+
*
|
|
1472
|
+
* Note: [🏐] Configurations registrations are done in @@@ BUT constructor @@@
|
|
1473
|
+
*
|
|
1474
|
+
* @public exported from `@promptbook/openai`
|
|
1475
|
+
*/
|
|
1476
|
+
var _OpenAiRegistration = $llmToolsRegister.register(createOpenAiExecutionTools);
|
|
1477
|
+
/**
|
|
1478
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
1479
|
+
*/
|
|
1480
|
+
|
|
1481
|
+
export { OPENAI_MODELS, OpenAiExecutionTools, PROMPTBOOK_VERSION, _OpenAiRegistration, createOpenAiExecutionTools };
|
|
1414
1482
|
//# sourceMappingURL=index.es.js.map
|