@promptbook/openai 0.71.0-0 โ 0.72.0-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/README.md +5 -0
- package/esm/index.es.js +306 -28
- 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 +6 -2
- package/esm/typings/src/_packages/openai.index.d.ts +8 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +1 -1
- package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +1 -1
- package/esm/typings/src/execution/utils/addUsage.d.ts +0 -56
- package/esm/typings/src/execution/utils/usage-constants.d.ts +127 -0
- package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceTools.d.ts +1 -1
- package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -2
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +3 -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/openai/OpenAiAssistantExecutionTools.d.ts +37 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +14 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +12 -2
- 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/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/python/PythonExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/typescript/TypescriptExecutionTools.d.ts +1 -1
- package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +2 -9
- package/package.json +2 -2
- package/umd/index.umd.js +312 -31
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -83,6 +83,11 @@ const { isSuccessful, errors, outputParameters, executionReport } = result;
|
|
|
83
83
|
console.info(outputParameters);
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
+
## ๐คบ Usage with OpenAI`s Assistants (GPTs)
|
|
87
|
+
|
|
88
|
+
!!!!!!
|
|
89
|
+
OpenAiExecutionTools.createAssistantSubtools
|
|
90
|
+
|
|
86
91
|
## ๐งโโ๏ธ Connect to LLM providers automatically
|
|
87
92
|
|
|
88
93
|
You can just use `createLlmToolsFromEnv` function to create LLM tools from environment variables like `OPENAI_API_KEY` and `ANTHROPIC_CLAUDE_API_KEY` automatically.
|
package/esm/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import colors from 'colors';
|
|
2
|
-
import OpenAI from 'openai';
|
|
3
2
|
import spaceTrim$1, { spaceTrim } from 'spacetrim';
|
|
3
|
+
import OpenAI from 'openai';
|
|
4
4
|
|
|
5
5
|
// โ ๏ธ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
6
6
|
/**
|
|
7
7
|
* The version of the Promptbook library
|
|
8
8
|
*/
|
|
9
|
-
var PROMPTBOOK_VERSION = '0.
|
|
9
|
+
var PROMPTBOOK_VERSION = '0.72.0-0';
|
|
10
10
|
// TODO:[main] !!!! List here all the versions and annotate + put into script
|
|
11
11
|
|
|
12
12
|
/*! *****************************************************************************
|
|
@@ -147,46 +147,37 @@ var $isRunningInBrowser = new Function("\n try {\n return this === win
|
|
|
147
147
|
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");
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
|
-
* This error indicates
|
|
150
|
+
* This error type indicates that some part of the code is not implemented yet
|
|
151
151
|
*
|
|
152
152
|
* @public exported from `@promptbook/core`
|
|
153
153
|
*/
|
|
154
|
-
var
|
|
155
|
-
__extends(
|
|
156
|
-
function
|
|
157
|
-
var _this = _super.call(this, message) || this;
|
|
158
|
-
_this.name = '
|
|
159
|
-
Object.setPrototypeOf(_this,
|
|
154
|
+
var NotYetImplementedError = /** @class */ (function (_super) {
|
|
155
|
+
__extends(NotYetImplementedError, _super);
|
|
156
|
+
function NotYetImplementedError(message) {
|
|
157
|
+
var _this = _super.call(this, 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;
|
|
158
|
+
_this.name = 'NotYetImplementedError';
|
|
159
|
+
Object.setPrototypeOf(_this, NotYetImplementedError.prototype);
|
|
160
160
|
return _this;
|
|
161
161
|
}
|
|
162
|
-
return
|
|
162
|
+
return NotYetImplementedError;
|
|
163
163
|
}(Error));
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
|
-
* This error
|
|
166
|
+
* This error indicates errors during the execution of the pipeline
|
|
167
167
|
*
|
|
168
168
|
* @public exported from `@promptbook/core`
|
|
169
169
|
*/
|
|
170
|
-
var
|
|
171
|
-
__extends(
|
|
172
|
-
function
|
|
173
|
-
var _this = _super.call(this,
|
|
174
|
-
_this.name = '
|
|
175
|
-
Object.setPrototypeOf(_this,
|
|
170
|
+
var PipelineExecutionError = /** @class */ (function (_super) {
|
|
171
|
+
__extends(PipelineExecutionError, _super);
|
|
172
|
+
function PipelineExecutionError(message) {
|
|
173
|
+
var _this = _super.call(this, message) || this;
|
|
174
|
+
_this.name = 'PipelineExecutionError';
|
|
175
|
+
Object.setPrototypeOf(_this, PipelineExecutionError.prototype);
|
|
176
176
|
return _this;
|
|
177
177
|
}
|
|
178
|
-
return
|
|
178
|
+
return PipelineExecutionError;
|
|
179
179
|
}(Error));
|
|
180
180
|
|
|
181
|
-
/**
|
|
182
|
-
* Get current date in ISO 8601 format
|
|
183
|
-
*
|
|
184
|
-
* @private internal utility
|
|
185
|
-
*/
|
|
186
|
-
function getCurrentIsoDate() {
|
|
187
|
-
return new Date().toISOString();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
181
|
/**
|
|
191
182
|
* @@@
|
|
192
183
|
*
|
|
@@ -221,6 +212,84 @@ function $deepFreeze(objectValue) {
|
|
|
221
212
|
* TODO: [๐ง ] Is there a way how to meaningfully test this utility
|
|
222
213
|
*/
|
|
223
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Represents the usage with no resources consumed
|
|
217
|
+
*
|
|
218
|
+
* @public exported from `@promptbook/core`
|
|
219
|
+
*/
|
|
220
|
+
$deepFreeze({
|
|
221
|
+
price: { value: 0 },
|
|
222
|
+
input: {
|
|
223
|
+
tokensCount: { value: 0 },
|
|
224
|
+
charactersCount: { value: 0 },
|
|
225
|
+
wordsCount: { value: 0 },
|
|
226
|
+
sentencesCount: { value: 0 },
|
|
227
|
+
linesCount: { value: 0 },
|
|
228
|
+
paragraphsCount: { value: 0 },
|
|
229
|
+
pagesCount: { value: 0 },
|
|
230
|
+
},
|
|
231
|
+
output: {
|
|
232
|
+
tokensCount: { value: 0 },
|
|
233
|
+
charactersCount: { value: 0 },
|
|
234
|
+
wordsCount: { value: 0 },
|
|
235
|
+
sentencesCount: { value: 0 },
|
|
236
|
+
linesCount: { value: 0 },
|
|
237
|
+
paragraphsCount: { value: 0 },
|
|
238
|
+
pagesCount: { value: 0 },
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
/**
|
|
242
|
+
* Represents the usage with unknown resources consumed
|
|
243
|
+
*
|
|
244
|
+
* @public exported from `@promptbook/core`
|
|
245
|
+
*/
|
|
246
|
+
var UNCERTAIN_USAGE = $deepFreeze({
|
|
247
|
+
price: { value: 0, isUncertain: true },
|
|
248
|
+
input: {
|
|
249
|
+
tokensCount: { value: 0, isUncertain: true },
|
|
250
|
+
charactersCount: { value: 0, isUncertain: true },
|
|
251
|
+
wordsCount: { value: 0, isUncertain: true },
|
|
252
|
+
sentencesCount: { value: 0, isUncertain: true },
|
|
253
|
+
linesCount: { value: 0, isUncertain: true },
|
|
254
|
+
paragraphsCount: { value: 0, isUncertain: true },
|
|
255
|
+
pagesCount: { value: 0, isUncertain: true },
|
|
256
|
+
},
|
|
257
|
+
output: {
|
|
258
|
+
tokensCount: { value: 0, isUncertain: true },
|
|
259
|
+
charactersCount: { value: 0, isUncertain: true },
|
|
260
|
+
wordsCount: { value: 0, isUncertain: true },
|
|
261
|
+
sentencesCount: { value: 0, isUncertain: true },
|
|
262
|
+
linesCount: { value: 0, isUncertain: true },
|
|
263
|
+
paragraphsCount: { value: 0, isUncertain: true },
|
|
264
|
+
pagesCount: { value: 0, isUncertain: true },
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Get current date in ISO 8601 format
|
|
270
|
+
*
|
|
271
|
+
* @private internal utility
|
|
272
|
+
*/
|
|
273
|
+
function getCurrentIsoDate() {
|
|
274
|
+
return new Date().toISOString();
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
279
|
+
*
|
|
280
|
+
* @public exported from `@promptbook/core`
|
|
281
|
+
*/
|
|
282
|
+
var UnexpectedError = /** @class */ (function (_super) {
|
|
283
|
+
__extends(UnexpectedError, _super);
|
|
284
|
+
function UnexpectedError(message) {
|
|
285
|
+
var _this = _super.call(this, 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;
|
|
286
|
+
_this.name = 'UnexpectedError';
|
|
287
|
+
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
288
|
+
return _this;
|
|
289
|
+
}
|
|
290
|
+
return UnexpectedError;
|
|
291
|
+
}(Error));
|
|
292
|
+
|
|
224
293
|
/**
|
|
225
294
|
* Checks if the value is [๐] serializable as JSON
|
|
226
295
|
* If not, throws an UnexpectedError with a rich error message and tracking
|
|
@@ -1379,6 +1448,15 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
1379
1448
|
});
|
|
1380
1449
|
});
|
|
1381
1450
|
};
|
|
1451
|
+
/**
|
|
1452
|
+
* Create (sub)tools for calling OpenAI API Assistants
|
|
1453
|
+
*
|
|
1454
|
+
* @param assistantId Which assistant to use
|
|
1455
|
+
* @returns Tools for calling OpenAI API Assistants with same token
|
|
1456
|
+
*/
|
|
1457
|
+
OpenAiExecutionTools.prototype.createAssistantSubtools = function (assistantId) {
|
|
1458
|
+
return new OpenAiAssistantExecutionTools(__assign(__assign({}, this.options), { assistantId: assistantId }));
|
|
1459
|
+
};
|
|
1382
1460
|
/**
|
|
1383
1461
|
* Check the `options` passed to `constructor`
|
|
1384
1462
|
*/
|
|
@@ -1674,6 +1752,197 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
1674
1752
|
* TODO: [๐ง ][๐ฐ] Allow to pass `title` for tracking purposes
|
|
1675
1753
|
*/
|
|
1676
1754
|
|
|
1755
|
+
/**
|
|
1756
|
+
* Execution Tools for calling OpenAI API Assistants
|
|
1757
|
+
*
|
|
1758
|
+
* This is usefull for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
|
|
1759
|
+
*
|
|
1760
|
+
* @public exported from `@promptbook/openai`
|
|
1761
|
+
*/
|
|
1762
|
+
var OpenAiAssistantExecutionTools = /** @class */ (function (_super) {
|
|
1763
|
+
__extends(OpenAiAssistantExecutionTools, _super);
|
|
1764
|
+
/**
|
|
1765
|
+
* Creates OpenAI Execution Tools.
|
|
1766
|
+
*
|
|
1767
|
+
* @param options which are relevant are directly passed to the OpenAI client
|
|
1768
|
+
*/
|
|
1769
|
+
function OpenAiAssistantExecutionTools(options) {
|
|
1770
|
+
var _this = _super.call(this, options) || this;
|
|
1771
|
+
_this.assistantId = options.assistantId;
|
|
1772
|
+
return _this;
|
|
1773
|
+
}
|
|
1774
|
+
Object.defineProperty(OpenAiAssistantExecutionTools.prototype, "title", {
|
|
1775
|
+
get: function () {
|
|
1776
|
+
return 'OpenAI Assistant';
|
|
1777
|
+
},
|
|
1778
|
+
enumerable: false,
|
|
1779
|
+
configurable: true
|
|
1780
|
+
});
|
|
1781
|
+
Object.defineProperty(OpenAiAssistantExecutionTools.prototype, "description", {
|
|
1782
|
+
get: function () {
|
|
1783
|
+
return 'Use single assistant provided by OpenAI';
|
|
1784
|
+
},
|
|
1785
|
+
enumerable: false,
|
|
1786
|
+
configurable: true
|
|
1787
|
+
});
|
|
1788
|
+
/**
|
|
1789
|
+
* Calls OpenAI API to use a chat model.
|
|
1790
|
+
*/
|
|
1791
|
+
OpenAiAssistantExecutionTools.prototype.callChatModel = function (prompt) {
|
|
1792
|
+
var _a, _b, _c;
|
|
1793
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1794
|
+
var content, parameters, modelRequirements /*, format*/, client, _d, _e, key, rawPromptContent, rawRequest, start, complete, stream, rawResponse, resultContent, usage;
|
|
1795
|
+
var e_1, _f;
|
|
1796
|
+
var _this = this;
|
|
1797
|
+
return __generator(this, function (_g) {
|
|
1798
|
+
switch (_g.label) {
|
|
1799
|
+
case 0:
|
|
1800
|
+
if (this.options.isVerbose) {
|
|
1801
|
+
console.info('๐ฌ OpenAI callChatModel call', { prompt: prompt });
|
|
1802
|
+
}
|
|
1803
|
+
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
|
|
1804
|
+
return [4 /*yield*/, this.getClient()];
|
|
1805
|
+
case 1:
|
|
1806
|
+
client = _g.sent();
|
|
1807
|
+
// TODO: [โ] Use here more modelRequirements
|
|
1808
|
+
if (modelRequirements.modelVariant !== 'CHAT') {
|
|
1809
|
+
throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
|
|
1810
|
+
}
|
|
1811
|
+
try {
|
|
1812
|
+
// TODO: [๐จโ๐จโ๐งโ๐ง] Remove:
|
|
1813
|
+
for (_d = __values(['maxTokens', 'modelName', 'seed', 'temperature']), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1814
|
+
key = _e.value;
|
|
1815
|
+
if (modelRequirements[key] !== undefined) {
|
|
1816
|
+
throw new NotYetImplementedError("In `OpenAiAssistantExecutionTools` you cannot specify `".concat(key, "`"));
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1821
|
+
finally {
|
|
1822
|
+
try {
|
|
1823
|
+
if (_e && !_e.done && (_f = _d.return)) _f.call(_d);
|
|
1824
|
+
}
|
|
1825
|
+
finally { if (e_1) throw e_1.error; }
|
|
1826
|
+
}
|
|
1827
|
+
rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: 'assistant' }));
|
|
1828
|
+
rawRequest = {
|
|
1829
|
+
// [๐จโ๐จโ๐งโ๐ง] ...modelSettings,
|
|
1830
|
+
assistant_id: 'asst_CJCZzFCbBL0f2D4OWMXVTdBB',
|
|
1831
|
+
// <- Note: This is not a private information, just ID of the assistant which is accessible only with correct API key
|
|
1832
|
+
thread: {
|
|
1833
|
+
messages: [
|
|
1834
|
+
// TODO: !!!!!! Unhardcode
|
|
1835
|
+
// TODO: !!!!!! Allow threads to be passed
|
|
1836
|
+
{ role: 'user', content: 'What is the meaning of life? I want breathtaking speech.' },
|
|
1837
|
+
],
|
|
1838
|
+
},
|
|
1839
|
+
// !!!!!! user: this.options.user,
|
|
1840
|
+
};
|
|
1841
|
+
start = getCurrentIsoDate();
|
|
1842
|
+
if (this.options.isVerbose) {
|
|
1843
|
+
console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
1844
|
+
}
|
|
1845
|
+
return [4 /*yield*/, client.beta.threads.createAndRunStream(rawRequest)];
|
|
1846
|
+
case 2:
|
|
1847
|
+
stream = _g.sent();
|
|
1848
|
+
stream.on('connect', function () {
|
|
1849
|
+
if (_this.options.isVerbose) {
|
|
1850
|
+
console.info('connect', stream.currentEvent);
|
|
1851
|
+
}
|
|
1852
|
+
});
|
|
1853
|
+
stream.on('messageDelta', function (messageDelta) {
|
|
1854
|
+
var _a;
|
|
1855
|
+
if (_this.options.isVerbose &&
|
|
1856
|
+
messageDelta &&
|
|
1857
|
+
messageDelta.content &&
|
|
1858
|
+
messageDelta.content[0] &&
|
|
1859
|
+
messageDelta.content[0].type === 'text') {
|
|
1860
|
+
console.info('messageDelta', (_a = messageDelta.content[0].text) === null || _a === void 0 ? void 0 : _a.value);
|
|
1861
|
+
}
|
|
1862
|
+
// TODO: !!!!!! report progress
|
|
1863
|
+
});
|
|
1864
|
+
stream.on('messageCreated', function (message) {
|
|
1865
|
+
if (_this.options.isVerbose) {
|
|
1866
|
+
console.info('messageCreated', message);
|
|
1867
|
+
}
|
|
1868
|
+
});
|
|
1869
|
+
stream.on('messageDone', function (message) {
|
|
1870
|
+
if (_this.options.isVerbose) {
|
|
1871
|
+
console.info('messageDone', message);
|
|
1872
|
+
}
|
|
1873
|
+
});
|
|
1874
|
+
return [4 /*yield*/, stream.finalMessages()];
|
|
1875
|
+
case 3:
|
|
1876
|
+
rawResponse = _g.sent();
|
|
1877
|
+
if (this.options.isVerbose) {
|
|
1878
|
+
console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
1879
|
+
}
|
|
1880
|
+
if (rawResponse.length !== 1) {
|
|
1881
|
+
throw new PipelineExecutionError("There is NOT 1 BUT ".concat(rawResponse.length, " finalMessages from OpenAI"));
|
|
1882
|
+
}
|
|
1883
|
+
if (rawResponse[0].content.length !== 1) {
|
|
1884
|
+
throw new PipelineExecutionError("There is NOT 1 BUT ".concat(rawResponse[0].content.length, " finalMessages content from OpenAI"));
|
|
1885
|
+
}
|
|
1886
|
+
if (((_a = rawResponse[0].content[0]) === null || _a === void 0 ? void 0 : _a.type) !== 'text') {
|
|
1887
|
+
throw new PipelineExecutionError("There is NOT 'text' BUT ".concat((_b = rawResponse[0].content[0]) === null || _b === void 0 ? void 0 : _b.type, " finalMessages content type from OpenAI"));
|
|
1888
|
+
}
|
|
1889
|
+
resultContent = (_c = rawResponse[0].content[0]) === null || _c === void 0 ? void 0 : _c.text.value;
|
|
1890
|
+
// <- TODO: !!!!!! There are also annotations, maybe use them
|
|
1891
|
+
// eslint-disable-next-line prefer-const
|
|
1892
|
+
complete = getCurrentIsoDate();
|
|
1893
|
+
usage = UNCERTAIN_USAGE;
|
|
1894
|
+
// TODO: !!!!!!> = computeOpenAiUsage(content, resultContent || '', rawResponse);
|
|
1895
|
+
if (resultContent === null) {
|
|
1896
|
+
throw new PipelineExecutionError('No response message from OpenAI');
|
|
1897
|
+
}
|
|
1898
|
+
return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiAssistantExecutionTools ChatPromptResult', {
|
|
1899
|
+
content: resultContent,
|
|
1900
|
+
modelName: 'assistant',
|
|
1901
|
+
// <- TODO: !!!!!! Can we detect really used model: rawResponse.model || modelName,
|
|
1902
|
+
timing: {
|
|
1903
|
+
start: start,
|
|
1904
|
+
complete: complete,
|
|
1905
|
+
},
|
|
1906
|
+
usage: usage,
|
|
1907
|
+
rawPromptContent: rawPromptContent,
|
|
1908
|
+
rawRequest: rawRequest,
|
|
1909
|
+
rawResponse: rawResponse,
|
|
1910
|
+
// <- [๐ฏ]
|
|
1911
|
+
})];
|
|
1912
|
+
}
|
|
1913
|
+
});
|
|
1914
|
+
});
|
|
1915
|
+
};
|
|
1916
|
+
return OpenAiAssistantExecutionTools;
|
|
1917
|
+
}(OpenAiExecutionTools));
|
|
1918
|
+
/**
|
|
1919
|
+
* TODO: !!!!!! DO not use colors - can be used in browser
|
|
1920
|
+
* TODO: [๐ง ][๐งโโ๏ธ] Maybe there can be some wizzard for thoose who want to use just OpenAI
|
|
1921
|
+
* TODO: Maybe make custom OpenAiError
|
|
1922
|
+
* TODO: [๐ง ][๐] Maybe use `isDeterministic` from options
|
|
1923
|
+
* TODO: [๐ง ][๐ฐ] Allow to pass `title` for tracking purposes
|
|
1924
|
+
*/
|
|
1925
|
+
|
|
1926
|
+
/**
|
|
1927
|
+
* Execution Tools for calling OpenAI API
|
|
1928
|
+
*
|
|
1929
|
+
* @public exported from `@promptbook/openai`
|
|
1930
|
+
*/
|
|
1931
|
+
var createOpenAiAssistantExecutionTools = Object.assign(function (options) {
|
|
1932
|
+
// TODO: [๐ง ][main] !!!! If browser, auto add `dangerouslyAllowBrowser`
|
|
1933
|
+
if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
|
|
1934
|
+
options = __assign(__assign({}, options), { dangerouslyAllowBrowser: true });
|
|
1935
|
+
}
|
|
1936
|
+
return new OpenAiAssistantExecutionTools(options);
|
|
1937
|
+
}, {
|
|
1938
|
+
packageName: '@promptbook/openai',
|
|
1939
|
+
className: 'OpenAiAssistantExecutionTools',
|
|
1940
|
+
});
|
|
1941
|
+
/**
|
|
1942
|
+
* TODO: [๐ฆบ] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
1943
|
+
* TODO: [๐ถ] Naming "constructor" vs "creator" vs "factory"
|
|
1944
|
+
*/
|
|
1945
|
+
|
|
1677
1946
|
/**
|
|
1678
1947
|
* Execution Tools for calling OpenAI API
|
|
1679
1948
|
*
|
|
@@ -1762,9 +2031,18 @@ var $llmToolsRegister = new $Register('llm_execution_tools_constructors');
|
|
|
1762
2031
|
* @public exported from `@promptbook/cli`
|
|
1763
2032
|
*/
|
|
1764
2033
|
var _OpenAiRegistration = $llmToolsRegister.register(createOpenAiExecutionTools);
|
|
2034
|
+
/**
|
|
2035
|
+
* @@@ registration2
|
|
2036
|
+
*
|
|
2037
|
+
* Note: [๐] Configurations registrations are done in @@@ BUT constructor @@@
|
|
2038
|
+
*
|
|
2039
|
+
* @public exported from `@promptbook/openai`
|
|
2040
|
+
* @public exported from `@promptbook/cli`
|
|
2041
|
+
*/
|
|
2042
|
+
var _OpenAiAssistantRegistration = $llmToolsRegister.register(createOpenAiAssistantExecutionTools);
|
|
1765
2043
|
/**
|
|
1766
2044
|
* TODO: [๐ถ] Naming "constructor" vs "creator" vs "factory"
|
|
1767
2045
|
*/
|
|
1768
2046
|
|
|
1769
|
-
export { OPENAI_MODELS, OpenAiExecutionTools, PROMPTBOOK_VERSION, _OpenAiRegistration, createOpenAiExecutionTools };
|
|
2047
|
+
export { OPENAI_MODELS, OpenAiAssistantExecutionTools, OpenAiExecutionTools, PROMPTBOOK_VERSION, _OpenAiAssistantRegistration, _OpenAiRegistration, createOpenAiAssistantExecutionTools, createOpenAiExecutionTools };
|
|
1770
2048
|
//# sourceMappingURL=index.es.js.map
|