@promptbook/openai 0.72.0-0 → 0.72.0-2
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/README.md +10 -6
- package/esm/index.es.js +176 -122
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +11 -1
- package/esm/typings/src/_packages/openai.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +12 -0
- package/esm/typings/src/_packages/utils.index.d.ts +4 -4
- package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +3 -2
- package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +23 -0
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +16 -1
- package/esm/typings/src/config.d.ts +14 -1
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -0
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +2 -1
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +5 -0
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +9 -8
- package/esm/typings/src/execution/createPipelineExecutor/$OngoingTemplateResult.d.ts +45 -0
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +20 -0
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +40 -0
- package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +10 -0
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +55 -0
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +62 -0
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatCells.d.ts +19 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +74 -0
- package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +34 -0
- package/esm/typings/src/execution/createPipelineExecutor/getContextForTemplate.d.ts +10 -0
- package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTemplate.d.ts +27 -0
- package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTemplate.d.ts +30 -0
- package/esm/typings/src/execution/createPipelineExecutor/getSamplesForTemplate.d.ts +10 -0
- package/esm/typings/src/execution/utils/checkExpectations.d.ts +2 -0
- package/esm/typings/src/execution/utils/usageToHuman.d.ts +3 -4
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +14 -15
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +30 -0
- package/esm/typings/src/formats/csv/{ListFormatDefinition.d.ts → CsvFormatDefinition.d.ts} +6 -3
- package/esm/typings/src/formats/csv/CsvSettings.d.ts +13 -0
- package/esm/typings/src/formats/index.d.ts +1 -1
- package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +4 -3
- package/esm/typings/src/formats/text/TextFormatDefinition.d.ts +19 -0
- package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +4 -3
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +9 -0
- package/esm/typings/src/llm-providers/openai/createOpenAiAssistantExecutionTools.d.ts +15 -0
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +9 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +9 -0
- package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +1 -0
- package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +5 -0
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/index.d.ts +3 -0
- package/esm/typings/src/utils/organization/{f.d.ts → empty_object.d.ts} +5 -1
- package/esm/typings/src/utils/organization/just_empty_object.d.ts +12 -0
- package/esm/typings/src/utils/{extractParameterNames.d.ts → parameters/extractParameterNames.d.ts} +2 -2
- package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +27 -0
- package/esm/typings/src/utils/{replaceParameters.d.ts → parameters/replaceParameters.d.ts} +2 -2
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +10 -0
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.test.d.ts +1 -0
- package/package.json +17 -13
- package/umd/index.umd.js +181 -125
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +0 -72
- package/esm/typings/src/formats/list/ListFormatDefinition.d.ts +0 -16
- /package/esm/typings/src/utils/{extractParameterNames.test.d.ts → parameters/extractParameterNames.test.d.ts} +0 -0
- /package/esm/typings/src/{execution/utils/usageToHuman.test.d.ts → utils/parameters/mapAvailableToExpectedParameters.test.d.ts} +0 -0
- /package/esm/typings/src/utils/{replaceParameters.test.d.ts → parameters/replaceParameters.test.d.ts} +0 -0
package/umd/index.umd.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'colors', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-openai"] = {}, global.colors, global.
|
|
5
|
-
})(this, (function (exports, colors,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('spacetrim'), require('openai')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'spacetrim', 'openai'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-openai"] = {}, global.colors, global.spaceTrim, global.OpenAI));
|
|
5
|
+
})(this, (function (exports, colors, spaceTrim, OpenAI) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
10
|
-
var OpenAI__default = /*#__PURE__*/_interopDefaultLegacy(OpenAI);
|
|
11
10
|
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
|
|
11
|
+
var OpenAI__default = /*#__PURE__*/_interopDefaultLegacy(OpenAI);
|
|
12
12
|
|
|
13
13
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
14
14
|
/**
|
|
15
15
|
* The version of the Promptbook library
|
|
16
16
|
*/
|
|
17
|
-
var PROMPTBOOK_VERSION = '0.
|
|
17
|
+
var PROMPTBOOK_VERSION = '0.72.0-1';
|
|
18
18
|
// TODO:[main] !!!! List here all the versions and annotate + put into script
|
|
19
19
|
|
|
20
20
|
/*! *****************************************************************************
|
|
@@ -155,46 +155,37 @@
|
|
|
155
155
|
var $isRunningInWebWorker = new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {\n return true;\n } else {\n return false;\n }\n } catch (e) {\n return false;\n }\n");
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
|
-
* This error indicates
|
|
158
|
+
* This error type indicates that some part of the code is not implemented yet
|
|
159
159
|
*
|
|
160
160
|
* @public exported from `@promptbook/core`
|
|
161
161
|
*/
|
|
162
|
-
var
|
|
163
|
-
__extends(
|
|
164
|
-
function
|
|
165
|
-
var _this = _super.call(this, message) || this;
|
|
166
|
-
_this.name = '
|
|
167
|
-
Object.setPrototypeOf(_this,
|
|
162
|
+
var NotYetImplementedError = /** @class */ (function (_super) {
|
|
163
|
+
__extends(NotYetImplementedError, _super);
|
|
164
|
+
function NotYetImplementedError(message) {
|
|
165
|
+
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
166
|
+
_this.name = 'NotYetImplementedError';
|
|
167
|
+
Object.setPrototypeOf(_this, NotYetImplementedError.prototype);
|
|
168
168
|
return _this;
|
|
169
169
|
}
|
|
170
|
-
return
|
|
170
|
+
return NotYetImplementedError;
|
|
171
171
|
}(Error));
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
|
-
* This error
|
|
174
|
+
* This error indicates errors during the execution of the pipeline
|
|
175
175
|
*
|
|
176
176
|
* @public exported from `@promptbook/core`
|
|
177
177
|
*/
|
|
178
|
-
var
|
|
179
|
-
__extends(
|
|
180
|
-
function
|
|
181
|
-
var _this = _super.call(this,
|
|
182
|
-
_this.name = '
|
|
183
|
-
Object.setPrototypeOf(_this,
|
|
178
|
+
var PipelineExecutionError = /** @class */ (function (_super) {
|
|
179
|
+
__extends(PipelineExecutionError, _super);
|
|
180
|
+
function PipelineExecutionError(message) {
|
|
181
|
+
var _this = _super.call(this, message) || this;
|
|
182
|
+
_this.name = 'PipelineExecutionError';
|
|
183
|
+
Object.setPrototypeOf(_this, PipelineExecutionError.prototype);
|
|
184
184
|
return _this;
|
|
185
185
|
}
|
|
186
|
-
return
|
|
186
|
+
return PipelineExecutionError;
|
|
187
187
|
}(Error));
|
|
188
188
|
|
|
189
|
-
/**
|
|
190
|
-
* Get current date in ISO 8601 format
|
|
191
|
-
*
|
|
192
|
-
* @private internal utility
|
|
193
|
-
*/
|
|
194
|
-
function getCurrentIsoDate() {
|
|
195
|
-
return new Date().toISOString();
|
|
196
|
-
}
|
|
197
|
-
|
|
198
189
|
/**
|
|
199
190
|
* @@@
|
|
200
191
|
*
|
|
@@ -229,6 +220,84 @@
|
|
|
229
220
|
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
230
221
|
*/
|
|
231
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Represents the usage with no resources consumed
|
|
225
|
+
*
|
|
226
|
+
* @public exported from `@promptbook/core`
|
|
227
|
+
*/
|
|
228
|
+
$deepFreeze({
|
|
229
|
+
price: { value: 0 },
|
|
230
|
+
input: {
|
|
231
|
+
tokensCount: { value: 0 },
|
|
232
|
+
charactersCount: { value: 0 },
|
|
233
|
+
wordsCount: { value: 0 },
|
|
234
|
+
sentencesCount: { value: 0 },
|
|
235
|
+
linesCount: { value: 0 },
|
|
236
|
+
paragraphsCount: { value: 0 },
|
|
237
|
+
pagesCount: { value: 0 },
|
|
238
|
+
},
|
|
239
|
+
output: {
|
|
240
|
+
tokensCount: { value: 0 },
|
|
241
|
+
charactersCount: { value: 0 },
|
|
242
|
+
wordsCount: { value: 0 },
|
|
243
|
+
sentencesCount: { value: 0 },
|
|
244
|
+
linesCount: { value: 0 },
|
|
245
|
+
paragraphsCount: { value: 0 },
|
|
246
|
+
pagesCount: { value: 0 },
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
/**
|
|
250
|
+
* Represents the usage with unknown resources consumed
|
|
251
|
+
*
|
|
252
|
+
* @public exported from `@promptbook/core`
|
|
253
|
+
*/
|
|
254
|
+
var UNCERTAIN_USAGE = $deepFreeze({
|
|
255
|
+
price: { value: 0, isUncertain: true },
|
|
256
|
+
input: {
|
|
257
|
+
tokensCount: { value: 0, isUncertain: true },
|
|
258
|
+
charactersCount: { value: 0, isUncertain: true },
|
|
259
|
+
wordsCount: { value: 0, isUncertain: true },
|
|
260
|
+
sentencesCount: { value: 0, isUncertain: true },
|
|
261
|
+
linesCount: { value: 0, isUncertain: true },
|
|
262
|
+
paragraphsCount: { value: 0, isUncertain: true },
|
|
263
|
+
pagesCount: { value: 0, isUncertain: true },
|
|
264
|
+
},
|
|
265
|
+
output: {
|
|
266
|
+
tokensCount: { value: 0, isUncertain: true },
|
|
267
|
+
charactersCount: { value: 0, isUncertain: true },
|
|
268
|
+
wordsCount: { value: 0, isUncertain: true },
|
|
269
|
+
sentencesCount: { value: 0, isUncertain: true },
|
|
270
|
+
linesCount: { value: 0, isUncertain: true },
|
|
271
|
+
paragraphsCount: { value: 0, isUncertain: true },
|
|
272
|
+
pagesCount: { value: 0, isUncertain: true },
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Get current date in ISO 8601 format
|
|
278
|
+
*
|
|
279
|
+
* @private internal utility
|
|
280
|
+
*/
|
|
281
|
+
function getCurrentIsoDate() {
|
|
282
|
+
return new Date().toISOString();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
287
|
+
*
|
|
288
|
+
* @public exported from `@promptbook/core`
|
|
289
|
+
*/
|
|
290
|
+
var UnexpectedError = /** @class */ (function (_super) {
|
|
291
|
+
__extends(UnexpectedError, _super);
|
|
292
|
+
function UnexpectedError(message) {
|
|
293
|
+
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
294
|
+
_this.name = 'UnexpectedError';
|
|
295
|
+
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
296
|
+
return _this;
|
|
297
|
+
}
|
|
298
|
+
return UnexpectedError;
|
|
299
|
+
}(Error));
|
|
300
|
+
|
|
232
301
|
/**
|
|
233
302
|
* Checks if the value is [🚉] serializable as JSON
|
|
234
303
|
* If not, throws an UnexpectedError with a rich error message and tracking
|
|
@@ -397,6 +466,7 @@
|
|
|
397
466
|
'samples',
|
|
398
467
|
'modelName',
|
|
399
468
|
'currentDate',
|
|
469
|
+
// <- TODO: !!!!! list here all command names
|
|
400
470
|
// <- TODO: Add more like 'date', 'modelName',...
|
|
401
471
|
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
402
472
|
]);
|
|
@@ -412,6 +482,18 @@
|
|
|
412
482
|
* @private within the repository
|
|
413
483
|
*/
|
|
414
484
|
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
485
|
+
// <- TODO: [🧜♂️]
|
|
486
|
+
/**
|
|
487
|
+
* @@@
|
|
488
|
+
*
|
|
489
|
+
* @public exported from `@promptbook/core`
|
|
490
|
+
*/
|
|
491
|
+
Object.freeze({
|
|
492
|
+
delimiter: ',',
|
|
493
|
+
quoteChar: '"',
|
|
494
|
+
newline: '\n',
|
|
495
|
+
skipEmptyLines: true,
|
|
496
|
+
});
|
|
415
497
|
/**
|
|
416
498
|
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
417
499
|
*/
|
|
@@ -1374,6 +1456,15 @@
|
|
|
1374
1456
|
});
|
|
1375
1457
|
});
|
|
1376
1458
|
};
|
|
1459
|
+
/**
|
|
1460
|
+
* Create (sub)tools for calling OpenAI API Assistants
|
|
1461
|
+
*
|
|
1462
|
+
* @param assistantId Which assistant to use
|
|
1463
|
+
* @returns Tools for calling OpenAI API Assistants with same token
|
|
1464
|
+
*/
|
|
1465
|
+
OpenAiExecutionTools.prototype.createAssistantSubtools = function (assistantId) {
|
|
1466
|
+
return new OpenAiAssistantExecutionTools(__assign(__assign({}, this.options), { assistantId: assistantId }));
|
|
1467
|
+
};
|
|
1377
1468
|
/**
|
|
1378
1469
|
* Check the `options` passed to `constructor`
|
|
1379
1470
|
*/
|
|
@@ -1470,7 +1561,7 @@
|
|
|
1470
1561
|
resultContent = rawResponse.choices[0].message.content;
|
|
1471
1562
|
// eslint-disable-next-line prefer-const
|
|
1472
1563
|
complete = getCurrentIsoDate();
|
|
1473
|
-
usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
|
|
1564
|
+
usage = computeOpenAiUsage(content || '', resultContent || '', rawResponse);
|
|
1474
1565
|
if (resultContent === null) {
|
|
1475
1566
|
throw new PipelineExecutionError('No response message from OpenAI');
|
|
1476
1567
|
}
|
|
@@ -1542,7 +1633,7 @@
|
|
|
1542
1633
|
resultContent = rawResponse.choices[0].text;
|
|
1543
1634
|
// eslint-disable-next-line prefer-const
|
|
1544
1635
|
complete = getCurrentIsoDate();
|
|
1545
|
-
usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
|
|
1636
|
+
usage = computeOpenAiUsage(content || '', resultContent || '', rawResponse);
|
|
1546
1637
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiExecutionTools CompletionPromptResult', {
|
|
1547
1638
|
content: resultContent,
|
|
1548
1639
|
modelName: rawResponse.model || modelName,
|
|
@@ -1602,7 +1693,9 @@
|
|
|
1602
1693
|
resultContent = rawResponse.data[0].embedding;
|
|
1603
1694
|
// eslint-disable-next-line prefer-const
|
|
1604
1695
|
complete = getCurrentIsoDate();
|
|
1605
|
-
usage = computeOpenAiUsage(content, '',
|
|
1696
|
+
usage = computeOpenAiUsage(content || '', '',
|
|
1697
|
+
// <- Note: Embedding does not have result content
|
|
1698
|
+
rawResponse);
|
|
1606
1699
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiExecutionTools EmbeddingPromptResult', {
|
|
1607
1700
|
content: resultContent,
|
|
1608
1701
|
modelName: rawResponse.model || modelName,
|
|
@@ -1667,95 +1760,6 @@
|
|
|
1667
1760
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
1668
1761
|
*/
|
|
1669
1762
|
|
|
1670
|
-
/**
|
|
1671
|
-
* Execution Tools for calling OpenAI API
|
|
1672
|
-
*
|
|
1673
|
-
* @public exported from `@promptbook/openai`
|
|
1674
|
-
*/
|
|
1675
|
-
var createOpenAiExecutionTools = Object.assign(function (options) {
|
|
1676
|
-
// TODO: [🧠][main] !!!! If browser, auto add `dangerouslyAllowBrowser`
|
|
1677
|
-
if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
|
|
1678
|
-
options = __assign(__assign({}, options), { dangerouslyAllowBrowser: true });
|
|
1679
|
-
}
|
|
1680
|
-
return new OpenAiExecutionTools(options);
|
|
1681
|
-
}, {
|
|
1682
|
-
packageName: '@promptbook/openai',
|
|
1683
|
-
className: 'OpenAiExecutionTools',
|
|
1684
|
-
});
|
|
1685
|
-
/**
|
|
1686
|
-
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
1687
|
-
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
1688
|
-
*/
|
|
1689
|
-
|
|
1690
|
-
/**
|
|
1691
|
-
* This error type indicates that some part of the code is not implemented yet
|
|
1692
|
-
*
|
|
1693
|
-
* @public exported from `@promptbook/core`
|
|
1694
|
-
*/
|
|
1695
|
-
var NotYetImplementedError = /** @class */ (function (_super) {
|
|
1696
|
-
__extends(NotYetImplementedError, _super);
|
|
1697
|
-
function NotYetImplementedError(message) {
|
|
1698
|
-
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
1699
|
-
_this.name = 'NotYetImplementedError';
|
|
1700
|
-
Object.setPrototypeOf(_this, NotYetImplementedError.prototype);
|
|
1701
|
-
return _this;
|
|
1702
|
-
}
|
|
1703
|
-
return NotYetImplementedError;
|
|
1704
|
-
}(Error));
|
|
1705
|
-
|
|
1706
|
-
/**
|
|
1707
|
-
* Represents the usage with no resources consumed
|
|
1708
|
-
*
|
|
1709
|
-
* @public exported from `@promptbook/core`
|
|
1710
|
-
*/
|
|
1711
|
-
$deepFreeze({
|
|
1712
|
-
price: { value: 0 },
|
|
1713
|
-
input: {
|
|
1714
|
-
tokensCount: { value: 0 },
|
|
1715
|
-
charactersCount: { value: 0 },
|
|
1716
|
-
wordsCount: { value: 0 },
|
|
1717
|
-
sentencesCount: { value: 0 },
|
|
1718
|
-
linesCount: { value: 0 },
|
|
1719
|
-
paragraphsCount: { value: 0 },
|
|
1720
|
-
pagesCount: { value: 0 },
|
|
1721
|
-
},
|
|
1722
|
-
output: {
|
|
1723
|
-
tokensCount: { value: 0 },
|
|
1724
|
-
charactersCount: { value: 0 },
|
|
1725
|
-
wordsCount: { value: 0 },
|
|
1726
|
-
sentencesCount: { value: 0 },
|
|
1727
|
-
linesCount: { value: 0 },
|
|
1728
|
-
paragraphsCount: { value: 0 },
|
|
1729
|
-
pagesCount: { value: 0 },
|
|
1730
|
-
},
|
|
1731
|
-
});
|
|
1732
|
-
/**
|
|
1733
|
-
* Represents the usage with unknown resources consumed
|
|
1734
|
-
*
|
|
1735
|
-
* @public exported from `@promptbook/core`
|
|
1736
|
-
*/
|
|
1737
|
-
var UNCERTAIN_USAGE = $deepFreeze({
|
|
1738
|
-
price: { value: 0, isUncertain: true },
|
|
1739
|
-
input: {
|
|
1740
|
-
tokensCount: { value: 0, isUncertain: true },
|
|
1741
|
-
charactersCount: { value: 0, isUncertain: true },
|
|
1742
|
-
wordsCount: { value: 0, isUncertain: true },
|
|
1743
|
-
sentencesCount: { value: 0, isUncertain: true },
|
|
1744
|
-
linesCount: { value: 0, isUncertain: true },
|
|
1745
|
-
paragraphsCount: { value: 0, isUncertain: true },
|
|
1746
|
-
pagesCount: { value: 0, isUncertain: true },
|
|
1747
|
-
},
|
|
1748
|
-
output: {
|
|
1749
|
-
tokensCount: { value: 0, isUncertain: true },
|
|
1750
|
-
charactersCount: { value: 0, isUncertain: true },
|
|
1751
|
-
wordsCount: { value: 0, isUncertain: true },
|
|
1752
|
-
sentencesCount: { value: 0, isUncertain: true },
|
|
1753
|
-
linesCount: { value: 0, isUncertain: true },
|
|
1754
|
-
paragraphsCount: { value: 0, isUncertain: true },
|
|
1755
|
-
pagesCount: { value: 0, isUncertain: true },
|
|
1756
|
-
},
|
|
1757
|
-
});
|
|
1758
|
-
|
|
1759
1763
|
/**
|
|
1760
1764
|
* Execution Tools for calling OpenAI API Assistants
|
|
1761
1765
|
*
|
|
@@ -1771,8 +1775,9 @@
|
|
|
1771
1775
|
* @param options which are relevant are directly passed to the OpenAI client
|
|
1772
1776
|
*/
|
|
1773
1777
|
function OpenAiAssistantExecutionTools(options) {
|
|
1774
|
-
|
|
1775
|
-
|
|
1778
|
+
var _this = _super.call(this, options) || this;
|
|
1779
|
+
_this.assistantId = options.assistantId;
|
|
1780
|
+
return _this;
|
|
1776
1781
|
}
|
|
1777
1782
|
Object.defineProperty(OpenAiAssistantExecutionTools.prototype, "title", {
|
|
1778
1783
|
get: function () {
|
|
@@ -1926,6 +1931,46 @@
|
|
|
1926
1931
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
1927
1932
|
*/
|
|
1928
1933
|
|
|
1934
|
+
/**
|
|
1935
|
+
* Execution Tools for calling OpenAI API
|
|
1936
|
+
*
|
|
1937
|
+
* @public exported from `@promptbook/openai`
|
|
1938
|
+
*/
|
|
1939
|
+
var createOpenAiAssistantExecutionTools = Object.assign(function (options) {
|
|
1940
|
+
// TODO: [🧠][main] !!!! If browser, auto add `dangerouslyAllowBrowser`
|
|
1941
|
+
if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
|
|
1942
|
+
options = __assign(__assign({}, options), { dangerouslyAllowBrowser: true });
|
|
1943
|
+
}
|
|
1944
|
+
return new OpenAiAssistantExecutionTools(options);
|
|
1945
|
+
}, {
|
|
1946
|
+
packageName: '@promptbook/openai',
|
|
1947
|
+
className: 'OpenAiAssistantExecutionTools',
|
|
1948
|
+
});
|
|
1949
|
+
/**
|
|
1950
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
1951
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
1952
|
+
*/
|
|
1953
|
+
|
|
1954
|
+
/**
|
|
1955
|
+
* Execution Tools for calling OpenAI API
|
|
1956
|
+
*
|
|
1957
|
+
* @public exported from `@promptbook/openai`
|
|
1958
|
+
*/
|
|
1959
|
+
var createOpenAiExecutionTools = Object.assign(function (options) {
|
|
1960
|
+
// TODO: [🧠][main] !!!! If browser, auto add `dangerouslyAllowBrowser`
|
|
1961
|
+
if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
|
|
1962
|
+
options = __assign(__assign({}, options), { dangerouslyAllowBrowser: true });
|
|
1963
|
+
}
|
|
1964
|
+
return new OpenAiExecutionTools(options);
|
|
1965
|
+
}, {
|
|
1966
|
+
packageName: '@promptbook/openai',
|
|
1967
|
+
className: 'OpenAiExecutionTools',
|
|
1968
|
+
});
|
|
1969
|
+
/**
|
|
1970
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
1971
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
1972
|
+
*/
|
|
1973
|
+
|
|
1929
1974
|
/**
|
|
1930
1975
|
* @@@
|
|
1931
1976
|
*
|
|
@@ -1994,6 +2039,15 @@
|
|
|
1994
2039
|
* @public exported from `@promptbook/cli`
|
|
1995
2040
|
*/
|
|
1996
2041
|
var _OpenAiRegistration = $llmToolsRegister.register(createOpenAiExecutionTools);
|
|
2042
|
+
/**
|
|
2043
|
+
* @@@ registration2
|
|
2044
|
+
*
|
|
2045
|
+
* Note: [🏐] Configurations registrations are done in @@@ BUT constructor @@@
|
|
2046
|
+
*
|
|
2047
|
+
* @public exported from `@promptbook/openai`
|
|
2048
|
+
* @public exported from `@promptbook/cli`
|
|
2049
|
+
*/
|
|
2050
|
+
var _OpenAiAssistantRegistration = $llmToolsRegister.register(createOpenAiAssistantExecutionTools);
|
|
1997
2051
|
/**
|
|
1998
2052
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
1999
2053
|
*/
|
|
@@ -2002,7 +2056,9 @@
|
|
|
2002
2056
|
exports.OpenAiAssistantExecutionTools = OpenAiAssistantExecutionTools;
|
|
2003
2057
|
exports.OpenAiExecutionTools = OpenAiExecutionTools;
|
|
2004
2058
|
exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
|
|
2059
|
+
exports._OpenAiAssistantRegistration = _OpenAiAssistantRegistration;
|
|
2005
2060
|
exports._OpenAiRegistration = _OpenAiRegistration;
|
|
2061
|
+
exports.createOpenAiAssistantExecutionTools = createOpenAiAssistantExecutionTools;
|
|
2006
2062
|
exports.createOpenAiExecutionTools = createOpenAiExecutionTools;
|
|
2007
2063
|
|
|
2008
2064
|
Object.defineProperty(exports, '__esModule', { value: true });
|