@promptbook/core 0.84.0-9 → 0.84.0
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 +21 -9
- package/esm/index.es.js +394 -192
- 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 +12 -2
- package/esm/typings/src/_packages/deepseek.index.d.ts +8 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/_packages/wizzard.index.d.ts +4 -0
- package/esm/typings/src/cli/cli-commands/about.d.ts +4 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +13 -0
- package/esm/typings/src/cli/cli-commands/make.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +3 -1
- package/esm/typings/src/config.d.ts +27 -1
- package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +1 -1
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +3 -1
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +9 -0
- package/esm/typings/src/llm-providers/deepseek/DeepseekExecutionToolsOptions.d.ts +9 -0
- package/esm/typings/src/llm-providers/deepseek/createDeepseekExecutionTools.d.ts +14 -0
- package/esm/typings/src/llm-providers/deepseek/register-configuration.d.ts +14 -0
- package/esm/typings/src/llm-providers/deepseek/register-constructor.d.ts +15 -0
- package/esm/typings/src/pipeline/book-notation.d.ts +3 -2
- package/esm/typings/src/pipeline/prompt-notation.d.ts +18 -5
- package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +1 -1
- package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +5 -2
- package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.test.d.ts +1 -0
- package/esm/typings/src/utils/editable/utils/isFlatPipeline.test.d.ts +1 -0
- package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +3 -0
- package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +3 -0
- package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +3 -0
- package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +3 -0
- package/esm/typings/src/utils/files/mimeTypeToExtension.d.ts +10 -0
- package/esm/typings/src/utils/files/mimeTypeToExtension.test.d.ts +1 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +7 -1
- package/package.json +8 -15
- package/umd/index.umd.js +400 -193
- package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('waitasecond'), require('papaparse'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'waitasecond', 'papaparse', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.waitasecond, global.papaparse, global.
|
|
5
|
-
})(this, (function (exports, spaceTrim, prettier, parserHtml, waitasecond, papaparse, path, cryptoJs,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('waitasecond'), require('papaparse'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('path'), require('crypto-js'), require('mime-types'), require('moment'), require('colors')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'waitasecond', 'papaparse', 'crypto-js/enc-hex', 'crypto-js/sha256', 'path', 'crypto-js', 'mime-types', 'moment', 'colors'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.waitasecond, global.papaparse, global.hexEncoder, global.sha256, global.path, global.cryptoJs, global.mimeTypes, global.moment, global.colors));
|
|
5
|
+
})(this, (function (exports, spaceTrim, prettier, parserHtml, waitasecond, papaparse, hexEncoder, sha256, path, cryptoJs, mimeTypes, moment, colors) { '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 spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
|
|
10
10
|
var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
|
|
11
11
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
12
|
+
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
12
13
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
13
14
|
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
14
|
-
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
15
15
|
|
|
16
16
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
17
17
|
/**
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.84.0-
|
|
30
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.84.0-21';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -180,22 +180,94 @@
|
|
|
180
180
|
*/
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
|
-
*
|
|
183
|
+
* Checks if value is valid email
|
|
184
184
|
*
|
|
185
185
|
* @public exported from `@promptbook/utils`
|
|
186
186
|
*/
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
function isValidEmail(email) {
|
|
188
|
+
if (typeof email !== 'string') {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
if (email.split('\n').length > 1) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
return /^.+@.+\..+$/.test(email);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Tests if given string is valid URL.
|
|
199
|
+
*
|
|
200
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
201
|
+
* @public exported from `@promptbook/utils`
|
|
202
|
+
*/
|
|
203
|
+
function isValidFilePath(filename) {
|
|
204
|
+
if (typeof filename !== 'string') {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
if (filename.split('\n').length > 1) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
if (filename.split(' ').length >
|
|
211
|
+
5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
var filenameSlashes = filename.split('\\').join('/');
|
|
215
|
+
// Absolute Unix path: /hello.txt
|
|
216
|
+
if (/^(\/)/i.test(filenameSlashes)) {
|
|
217
|
+
// console.log(filename, 'Absolute Unix path: /hello.txt');
|
|
190
218
|
return true;
|
|
191
219
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
220
|
+
// Absolute Windows path: /hello.txt
|
|
221
|
+
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
222
|
+
// console.log(filename, 'Absolute Windows path: /hello.txt');
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
// Relative path: ./hello.txt
|
|
226
|
+
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
227
|
+
// console.log(filename, 'Relative path: ./hello.txt');
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
// Allow paths like foo/hello
|
|
231
|
+
if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
|
|
232
|
+
// console.log(filename, 'Allow paths like foo/hello');
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
// Allow paths like hello.book
|
|
236
|
+
if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
|
|
237
|
+
// console.log(filename, 'Allow paths like hello.book');
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* TODO: [🍏] Implement for MacOs
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Tests if given string is valid URL.
|
|
248
|
+
*
|
|
249
|
+
* Note: Dataurl are considered perfectly valid.
|
|
250
|
+
* Note: There are two simmilar functions:
|
|
251
|
+
* - `isValidUrl` which tests any URL
|
|
252
|
+
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
253
|
+
*
|
|
254
|
+
* @public exported from `@promptbook/utils`
|
|
255
|
+
*/
|
|
256
|
+
function isValidUrl(url) {
|
|
257
|
+
if (typeof url !== 'string') {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
try {
|
|
261
|
+
if (url.startsWith('blob:')) {
|
|
262
|
+
url = url.replace(/^blob:/, '');
|
|
195
263
|
}
|
|
196
|
-
|
|
264
|
+
var urlObject = new URL(url /* because fail is handled */);
|
|
265
|
+
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
197
266
|
return false;
|
|
198
267
|
}
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
199
271
|
return false;
|
|
200
272
|
}
|
|
201
273
|
}
|
|
@@ -219,6 +291,27 @@
|
|
|
219
291
|
* TODO: Maybe split `ParseError` and `ApplyError`
|
|
220
292
|
*/
|
|
221
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
296
|
+
*
|
|
297
|
+
* @public exported from `@promptbook/utils`
|
|
298
|
+
*/
|
|
299
|
+
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
300
|
+
try {
|
|
301
|
+
JSON.parse(value);
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
catch (error) {
|
|
305
|
+
if (!(error instanceof Error)) {
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
if (error.message.includes('Unexpected token')) {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
222
315
|
/**
|
|
223
316
|
* Function `validatePipelineString` will validate the if the string is a valid pipeline string
|
|
224
317
|
* It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
|
|
@@ -232,6 +325,15 @@
|
|
|
232
325
|
if (isValidJsonString(pipelineString)) {
|
|
233
326
|
throw new ParseError('Expected a book, but got a JSON string');
|
|
234
327
|
}
|
|
328
|
+
else if (isValidUrl(pipelineString)) {
|
|
329
|
+
throw new ParseError("Expected a book, but got just the URL \"".concat(pipelineString, "\""));
|
|
330
|
+
}
|
|
331
|
+
else if (isValidFilePath(pipelineString)) {
|
|
332
|
+
throw new ParseError("Expected a book, but got just the file path \"".concat(pipelineString, "\""));
|
|
333
|
+
}
|
|
334
|
+
else if (isValidEmail(pipelineString)) {
|
|
335
|
+
throw new ParseError("Expected a book, but got just the email \"".concat(pipelineString, "\""));
|
|
336
|
+
}
|
|
235
337
|
// <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
|
|
236
338
|
return pipelineString;
|
|
237
339
|
}
|
|
@@ -572,6 +674,24 @@
|
|
|
572
674
|
* @public exported from `@promptbook/core`
|
|
573
675
|
*/
|
|
574
676
|
var DEFAULT_TASK_TITLE = "Task";
|
|
677
|
+
/**
|
|
678
|
+
* When the title of the prompt task is not provided, the default title is used
|
|
679
|
+
*
|
|
680
|
+
* @public exported from `@promptbook/core`
|
|
681
|
+
*/
|
|
682
|
+
var DEFAULT_PROMPT_TASK_TITLE = "Prompt";
|
|
683
|
+
/**
|
|
684
|
+
* When the pipeline is flat and no name of return parameter is provided, this name is used
|
|
685
|
+
*
|
|
686
|
+
* @public exported from `@promptbook/core`
|
|
687
|
+
*/
|
|
688
|
+
var DEFAULT_BOOK_OUTPUT_PARAMETER_NAME = 'result';
|
|
689
|
+
/**
|
|
690
|
+
* Maximum file size limit
|
|
691
|
+
*
|
|
692
|
+
* @public exported from `@promptbook/core`
|
|
693
|
+
*/
|
|
694
|
+
var DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
|
|
575
695
|
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
576
696
|
/**
|
|
577
697
|
* The maximum number of iterations for a loops
|
|
@@ -652,6 +772,14 @@
|
|
|
652
772
|
*/
|
|
653
773
|
var DEFAULT_BOOKS_DIRNAME = './books';
|
|
654
774
|
// <- TODO: [🕝] Make also `BOOKS_DIRNAME_ALTERNATIVES`
|
|
775
|
+
/**
|
|
776
|
+
* Where to store the temporary downloads
|
|
777
|
+
*
|
|
778
|
+
* Note: When the folder does not exist, it is created recursively
|
|
779
|
+
*
|
|
780
|
+
* @public exported from `@promptbook/core`
|
|
781
|
+
*/
|
|
782
|
+
var DEFAULT_DOWNLOAD_CACHE_DIRNAME = './.promptbook/download-cache';
|
|
655
783
|
/**
|
|
656
784
|
* Where to store the cache of executions for promptbook CLI
|
|
657
785
|
*
|
|
@@ -659,7 +787,7 @@
|
|
|
659
787
|
*
|
|
660
788
|
* @public exported from `@promptbook/core`
|
|
661
789
|
*/
|
|
662
|
-
var
|
|
790
|
+
var DEFAULT_EXECUTION_CACHE_DIRNAME = './.promptbook/execution-cache';
|
|
663
791
|
/**
|
|
664
792
|
* Where to store the scrape cache
|
|
665
793
|
*
|
|
@@ -1185,35 +1313,6 @@
|
|
|
1185
1313
|
return isHostnameOnPrivateNetwork(url.hostname);
|
|
1186
1314
|
}
|
|
1187
1315
|
|
|
1188
|
-
/**
|
|
1189
|
-
* Tests if given string is valid URL.
|
|
1190
|
-
*
|
|
1191
|
-
* Note: Dataurl are considered perfectly valid.
|
|
1192
|
-
* Note: There are two simmilar functions:
|
|
1193
|
-
* - `isValidUrl` which tests any URL
|
|
1194
|
-
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
1195
|
-
*
|
|
1196
|
-
* @public exported from `@promptbook/utils`
|
|
1197
|
-
*/
|
|
1198
|
-
function isValidUrl(url) {
|
|
1199
|
-
if (typeof url !== 'string') {
|
|
1200
|
-
return false;
|
|
1201
|
-
}
|
|
1202
|
-
try {
|
|
1203
|
-
if (url.startsWith('blob:')) {
|
|
1204
|
-
url = url.replace(/^blob:/, '');
|
|
1205
|
-
}
|
|
1206
|
-
var urlObject = new URL(url /* because fail is handled */);
|
|
1207
|
-
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
1208
|
-
return false;
|
|
1209
|
-
}
|
|
1210
|
-
return true;
|
|
1211
|
-
}
|
|
1212
|
-
catch (error) {
|
|
1213
|
-
return false;
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
1316
|
/**
|
|
1218
1317
|
* Tests if given string is valid pipeline URL URL.
|
|
1219
1318
|
*
|
|
@@ -2172,12 +2271,28 @@
|
|
|
2172
2271
|
/**
|
|
2173
2272
|
* Asserts that the execution of a Promptbook is successful
|
|
2174
2273
|
*
|
|
2274
|
+
* Note: If there are only warnings, the execution is still successful but the warnings are logged in the console
|
|
2275
|
+
*
|
|
2175
2276
|
* @param executionResult - The partial result of the Promptbook execution
|
|
2176
2277
|
* @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
|
|
2177
2278
|
* @public exported from `@promptbook/core`
|
|
2178
2279
|
*/
|
|
2179
2280
|
function assertsExecutionSuccessful(executionResult) {
|
|
2180
|
-
var
|
|
2281
|
+
var e_1, _a;
|
|
2282
|
+
var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors, warnings = executionResult.warnings;
|
|
2283
|
+
try {
|
|
2284
|
+
for (var warnings_1 = __values(warnings), warnings_1_1 = warnings_1.next(); !warnings_1_1.done; warnings_1_1 = warnings_1.next()) {
|
|
2285
|
+
var warning = warnings_1_1.value;
|
|
2286
|
+
console.warn(warning.message);
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2290
|
+
finally {
|
|
2291
|
+
try {
|
|
2292
|
+
if (warnings_1_1 && !warnings_1_1.done && (_a = warnings_1.return)) _a.call(warnings_1);
|
|
2293
|
+
}
|
|
2294
|
+
finally { if (e_1) throw e_1.error; }
|
|
2295
|
+
}
|
|
2181
2296
|
if (isSuccessful === true) {
|
|
2182
2297
|
return;
|
|
2183
2298
|
}
|
|
@@ -3187,7 +3302,7 @@
|
|
|
3187
3302
|
if (!(error_1 instanceof Error) || error_1 instanceof UnexpectedError) {
|
|
3188
3303
|
throw error_1;
|
|
3189
3304
|
}
|
|
3190
|
-
errors.push(error_1);
|
|
3305
|
+
errors.push({ llmExecutionTools: llmExecutionTools, error: error_1 });
|
|
3191
3306
|
return [3 /*break*/, 13];
|
|
3192
3307
|
case 13:
|
|
3193
3308
|
_b = _a.next();
|
|
@@ -3214,7 +3329,10 @@
|
|
|
3214
3329
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3215
3330
|
// 3) ...
|
|
3216
3331
|
spaceTrim__default["default"](function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
|
|
3217
|
-
.map(function (
|
|
3332
|
+
.map(function (_a, i) {
|
|
3333
|
+
var error = _a.error, llmExecutionTools = _a.llmExecutionTools;
|
|
3334
|
+
return "".concat(i + 1, ") **").concat(llmExecutionTools.title, "** thrown **").concat(error.name || 'Error', ":** ").concat(error.message);
|
|
3335
|
+
})
|
|
3218
3336
|
.join('\n')), "\n\n "); }));
|
|
3219
3337
|
}
|
|
3220
3338
|
else if (this.llmExecutionTools.length === 0) {
|
|
@@ -5662,6 +5780,15 @@
|
|
|
5662
5780
|
* TODO: [🐱🐉][🧠] Make some smart crop NOT source-i-m-pavol-a-develop-... BUT source-i-m-pavol-a-developer-...
|
|
5663
5781
|
*/
|
|
5664
5782
|
|
|
5783
|
+
/**
|
|
5784
|
+
* @@@
|
|
5785
|
+
*
|
|
5786
|
+
* @private for `FileCacheStorage`
|
|
5787
|
+
*/
|
|
5788
|
+
function nameToSubfolderPath(name) {
|
|
5789
|
+
return [name.substr(0, 1).toLowerCase(), name.substr(1, 1).toLowerCase()];
|
|
5790
|
+
}
|
|
5791
|
+
|
|
5665
5792
|
/**
|
|
5666
5793
|
* Convert file extension to mime type
|
|
5667
5794
|
*
|
|
@@ -5718,53 +5845,55 @@
|
|
|
5718
5845
|
*/
|
|
5719
5846
|
|
|
5720
5847
|
/**
|
|
5721
|
-
*
|
|
5848
|
+
* Convert mime type to file extension
|
|
5722
5849
|
*
|
|
5723
|
-
* Note:
|
|
5850
|
+
* Note: If the mime type is invalid, `null` is returned
|
|
5851
|
+
*
|
|
5852
|
+
* @private within the repository
|
|
5853
|
+
*/
|
|
5854
|
+
function mimeTypeToExtension(value) {
|
|
5855
|
+
return mimeTypes.extension(value) || null;
|
|
5856
|
+
}
|
|
5857
|
+
|
|
5858
|
+
/**
|
|
5859
|
+
* Removes emojis from a string and fix whitespaces
|
|
5860
|
+
*
|
|
5861
|
+
* @param text with emojis
|
|
5862
|
+
* @returns text without emojis
|
|
5724
5863
|
* @public exported from `@promptbook/utils`
|
|
5725
5864
|
*/
|
|
5726
|
-
function
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
}
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
if (filename.split(' ').length >
|
|
5734
|
-
5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
|
|
5735
|
-
return false;
|
|
5736
|
-
}
|
|
5737
|
-
var filenameSlashes = filename.split('\\').join('/');
|
|
5738
|
-
// Absolute Unix path: /hello.txt
|
|
5739
|
-
if (/^(\/)/i.test(filenameSlashes)) {
|
|
5740
|
-
// console.log(filename, 'Absolute Unix path: /hello.txt');
|
|
5741
|
-
return true;
|
|
5742
|
-
}
|
|
5743
|
-
// Absolute Windows path: /hello.txt
|
|
5744
|
-
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
5745
|
-
// console.log(filename, 'Absolute Windows path: /hello.txt');
|
|
5746
|
-
return true;
|
|
5747
|
-
}
|
|
5748
|
-
// Relative path: ./hello.txt
|
|
5749
|
-
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
5750
|
-
// console.log(filename, 'Relative path: ./hello.txt');
|
|
5751
|
-
return true;
|
|
5752
|
-
}
|
|
5753
|
-
// Allow paths like foo/hello
|
|
5754
|
-
if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
|
|
5755
|
-
// console.log(filename, 'Allow paths like foo/hello');
|
|
5756
|
-
return true;
|
|
5757
|
-
}
|
|
5758
|
-
// Allow paths like hello.book
|
|
5759
|
-
if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
|
|
5760
|
-
// console.log(filename, 'Allow paths like hello.book');
|
|
5761
|
-
return true;
|
|
5762
|
-
}
|
|
5763
|
-
return false;
|
|
5865
|
+
function removeEmojis(text) {
|
|
5866
|
+
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
5867
|
+
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
5868
|
+
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
5869
|
+
text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
|
|
5870
|
+
text = text.replace(/\p{Extended_Pictographic}/gu, '');
|
|
5871
|
+
return text;
|
|
5764
5872
|
}
|
|
5873
|
+
|
|
5765
5874
|
/**
|
|
5766
|
-
*
|
|
5875
|
+
* @@@
|
|
5876
|
+
*
|
|
5877
|
+
* @param value @@@
|
|
5878
|
+
* @returns @@@
|
|
5879
|
+
* @example @@@
|
|
5880
|
+
* @public exported from `@promptbook/utils`
|
|
5767
5881
|
*/
|
|
5882
|
+
function titleToName(value) {
|
|
5883
|
+
if (isValidUrl(value)) {
|
|
5884
|
+
value = value.replace(/^https?:\/\//, '');
|
|
5885
|
+
value = value.replace(/\.html$/, '');
|
|
5886
|
+
}
|
|
5887
|
+
else if (isValidFilePath(value)) {
|
|
5888
|
+
value = path.basename(value);
|
|
5889
|
+
// Note: Keeping extension in the name
|
|
5890
|
+
}
|
|
5891
|
+
value = value.split('/').join('-');
|
|
5892
|
+
value = removeEmojis(value);
|
|
5893
|
+
value = normalizeToKebabCase(value);
|
|
5894
|
+
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
5895
|
+
return value;
|
|
5896
|
+
}
|
|
5768
5897
|
|
|
5769
5898
|
/**
|
|
5770
5899
|
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
@@ -5801,9 +5930,9 @@
|
|
|
5801
5930
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
5802
5931
|
var _a;
|
|
5803
5932
|
return __awaiter(this, void 0, void 0, function () {
|
|
5804
|
-
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
5805
|
-
return __generator(this, function (
|
|
5806
|
-
switch (
|
|
5933
|
+
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, fileContent, _f, _g, filename_1, fileExtension, mimeType;
|
|
5934
|
+
return __generator(this, function (_h) {
|
|
5935
|
+
switch (_h.label) {
|
|
5807
5936
|
case 0:
|
|
5808
5937
|
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
5809
5938
|
knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
|
|
@@ -5812,54 +5941,76 @@
|
|
|
5812
5941
|
if (!name) {
|
|
5813
5942
|
name = knowledgeSourceContentToName(knowledgeSourceContent);
|
|
5814
5943
|
}
|
|
5815
|
-
if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/,
|
|
5944
|
+
if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 5];
|
|
5816
5945
|
url = knowledgeSourceContent;
|
|
5817
5946
|
return [4 /*yield*/, fetch(url)];
|
|
5818
5947
|
case 1:
|
|
5819
|
-
response_1 =
|
|
5948
|
+
response_1 = _h.sent();
|
|
5820
5949
|
mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5950
|
+
if (tools.fs === undefined || !url.endsWith('.pdf' /* <- TODO: [💵] */)) {
|
|
5951
|
+
return [2 /*return*/, {
|
|
5952
|
+
source: name,
|
|
5953
|
+
filename: null,
|
|
5954
|
+
url: url,
|
|
5955
|
+
mimeType: mimeType,
|
|
5956
|
+
/*
|
|
5957
|
+
TODO: [🥽]
|
|
5958
|
+
> async asBlob() {
|
|
5959
|
+
> // TODO: [👨🏻🤝👨🏻] This can be called multiple times BUT when called second time, response in already consumed
|
|
5960
|
+
> const content = await response.blob();
|
|
5961
|
+
> return content;
|
|
5962
|
+
> },
|
|
5963
|
+
*/
|
|
5964
|
+
asJson: function () {
|
|
5965
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5966
|
+
var content;
|
|
5967
|
+
return __generator(this, function (_a) {
|
|
5968
|
+
switch (_a.label) {
|
|
5969
|
+
case 0: return [4 /*yield*/, response_1.json()];
|
|
5970
|
+
case 1:
|
|
5971
|
+
content = _a.sent();
|
|
5972
|
+
return [2 /*return*/, content];
|
|
5973
|
+
}
|
|
5974
|
+
});
|
|
5844
5975
|
});
|
|
5845
|
-
}
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
}
|
|
5976
|
+
},
|
|
5977
|
+
asText: function () {
|
|
5978
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5979
|
+
var content;
|
|
5980
|
+
return __generator(this, function (_a) {
|
|
5981
|
+
switch (_a.label) {
|
|
5982
|
+
case 0: return [4 /*yield*/, response_1.text()];
|
|
5983
|
+
case 1:
|
|
5984
|
+
content = _a.sent();
|
|
5985
|
+
return [2 /*return*/, content];
|
|
5986
|
+
}
|
|
5987
|
+
});
|
|
5857
5988
|
});
|
|
5858
|
-
}
|
|
5859
|
-
}
|
|
5860
|
-
|
|
5989
|
+
},
|
|
5990
|
+
}];
|
|
5991
|
+
}
|
|
5992
|
+
basename = url.split('/').pop() || titleToName(url);
|
|
5993
|
+
hash = sha256__default["default"](hexEncoder__default["default"].parse(url)).toString( /* hex */);
|
|
5994
|
+
rootDirname_1 = path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
5995
|
+
filepath = path.join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), ["".concat(basename.substring(0, MAX_FILENAME_LENGTH), ".").concat(mimeTypeToExtension(mimeType))], false));
|
|
5996
|
+
return [4 /*yield*/, tools.fs.mkdir(path.dirname(path.join(rootDirname_1, filepath)), { recursive: true })];
|
|
5861
5997
|
case 2:
|
|
5862
|
-
|
|
5998
|
+
_h.sent();
|
|
5999
|
+
_g = (_f = Buffer).from;
|
|
6000
|
+
return [4 /*yield*/, response_1.arrayBuffer()];
|
|
6001
|
+
case 3:
|
|
6002
|
+
fileContent = _g.apply(_f, [_h.sent()]);
|
|
6003
|
+
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
6004
|
+
throw new LimitReachedError("File is too large (".concat(Math.round(fileContent.length / 1024 / 1024), "MB). Maximum allowed size is ").concat(Math.round(DEFAULT_MAX_FILE_SIZE / 1024 / 1024), "MB."));
|
|
6005
|
+
}
|
|
6006
|
+
return [4 /*yield*/, tools.fs.writeFile(path.join(rootDirname_1, filepath), fileContent)];
|
|
6007
|
+
case 4:
|
|
6008
|
+
_h.sent();
|
|
6009
|
+
// TODO: [💵] Check the file security
|
|
6010
|
+
// TODO: [🧹][🧠] Delete the file after the scraping is done
|
|
6011
|
+
return [2 /*return*/, makeKnowledgeSourceHandler({ name: name, knowledgeSourceContent: filepath }, tools, __assign(__assign({}, options), { rootDirname: rootDirname_1 }))];
|
|
6012
|
+
case 5:
|
|
6013
|
+
if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 7];
|
|
5863
6014
|
if (tools.fs === undefined) {
|
|
5864
6015
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
5865
6016
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -5872,8 +6023,8 @@
|
|
|
5872
6023
|
fileExtension = getFileExtension(filename_1);
|
|
5873
6024
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
5874
6025
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
5875
|
-
case
|
|
5876
|
-
if (!(
|
|
6026
|
+
case 6:
|
|
6027
|
+
if (!(_h.sent())) {
|
|
5877
6028
|
throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(knowledgeSourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
|
|
5878
6029
|
}
|
|
5879
6030
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
@@ -5919,7 +6070,7 @@
|
|
|
5919
6070
|
});
|
|
5920
6071
|
},
|
|
5921
6072
|
}];
|
|
5922
|
-
case
|
|
6073
|
+
case 7: return [2 /*return*/, {
|
|
5923
6074
|
source: name,
|
|
5924
6075
|
filename: null,
|
|
5925
6076
|
url: null,
|
|
@@ -7030,22 +7181,6 @@
|
|
|
7030
7181
|
* TODO: [🌺] Use some intermediate util splitWords
|
|
7031
7182
|
*/
|
|
7032
7183
|
|
|
7033
|
-
/**
|
|
7034
|
-
* Removes emojis from a string and fix whitespaces
|
|
7035
|
-
*
|
|
7036
|
-
* @param text with emojis
|
|
7037
|
-
* @returns text without emojis
|
|
7038
|
-
* @public exported from `@promptbook/utils`
|
|
7039
|
-
*/
|
|
7040
|
-
function removeEmojis(text) {
|
|
7041
|
-
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
7042
|
-
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
7043
|
-
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
7044
|
-
text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
|
|
7045
|
-
text = text.replace(/\p{Extended_Pictographic}/gu, '');
|
|
7046
|
-
return text;
|
|
7047
|
-
}
|
|
7048
|
-
|
|
7049
7184
|
/**
|
|
7050
7185
|
* Removes quotes from a string
|
|
7051
7186
|
*
|
|
@@ -8905,7 +9040,10 @@
|
|
|
8905
9040
|
description: 'Chatbot response',
|
|
8906
9041
|
isInput: false,
|
|
8907
9042
|
isOutput: true,
|
|
8908
|
-
exampleValues: [
|
|
9043
|
+
exampleValues: [
|
|
9044
|
+
'Hello, how can I help you?',
|
|
9045
|
+
// <- TODO: [🧠] Make this dynamic, async, prepare-phase HLAs
|
|
9046
|
+
],
|
|
8909
9047
|
});
|
|
8910
9048
|
// TODO: Use spaceTrim in multiline strings
|
|
8911
9049
|
$pipelineJson.tasks.push({
|
|
@@ -8993,12 +9131,15 @@
|
|
|
8993
9131
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
8994
9132
|
pipelineString = spaceTrim__default["default"](pipelineString);
|
|
8995
9133
|
var isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
8996
|
-
|
|
8997
|
-
|
|
9134
|
+
//const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
|
|
9135
|
+
var isBacktickBlockUsed = pipelineString.includes('```');
|
|
9136
|
+
var isQuoteBlocksUsed = /^>\s+/m.test(pipelineString);
|
|
9137
|
+
var isBlocksUsed = isBacktickBlockUsed || isQuoteBlocksUsed;
|
|
9138
|
+
// TODO: [🧉] Also (double)check
|
|
8998
9139
|
// > const usedCommands
|
|
8999
9140
|
// > const isBlocksUsed
|
|
9000
9141
|
// > const returnStatementCount
|
|
9001
|
-
var isFlat = !isMarkdownBeginningWithHeadline && isLastLineReturnStatement
|
|
9142
|
+
var isFlat = !isMarkdownBeginningWithHeadline && !isBlocksUsed; /* && isLastLineReturnStatement */
|
|
9002
9143
|
return isFlat;
|
|
9003
9144
|
}
|
|
9004
9145
|
|
|
@@ -9012,9 +9153,26 @@
|
|
|
9012
9153
|
return pipelineString;
|
|
9013
9154
|
}
|
|
9014
9155
|
var pipelineStringLines = pipelineString.split('\n');
|
|
9015
|
-
var
|
|
9156
|
+
var potentialReturnStatement = pipelineStringLines.pop();
|
|
9157
|
+
var returnStatement;
|
|
9158
|
+
if (/(-|=)>\s*\{.*\}/.test(potentialReturnStatement)) {
|
|
9159
|
+
// Note: Last line is return statement
|
|
9160
|
+
returnStatement = potentialReturnStatement;
|
|
9161
|
+
}
|
|
9162
|
+
else {
|
|
9163
|
+
// Note: Last line is not a return statement
|
|
9164
|
+
returnStatement = "-> {".concat(DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, "}");
|
|
9165
|
+
pipelineStringLines.push(potentialReturnStatement);
|
|
9166
|
+
}
|
|
9016
9167
|
var prompt = spaceTrim__default["default"](pipelineStringLines.join('\n'));
|
|
9017
|
-
|
|
9168
|
+
var quotedPrompt;
|
|
9169
|
+
if (prompt.split('\n').length <= 1) {
|
|
9170
|
+
quotedPrompt = "> ".concat(prompt);
|
|
9171
|
+
}
|
|
9172
|
+
else {
|
|
9173
|
+
quotedPrompt = spaceTrim__default["default"](function (block) { return "\n ```\n ".concat(block(prompt.split('`').join('\\`')), "\n ```\n "); });
|
|
9174
|
+
}
|
|
9175
|
+
pipelineString = validatePipelineString(spaceTrim__default["default"](function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ").concat(block(quotedPrompt), "\n\n ").concat(returnStatement, "\n "); }));
|
|
9018
9176
|
// <- TODO: Maybe use book` notation
|
|
9019
9177
|
return pipelineString;
|
|
9020
9178
|
}
|
|
@@ -9237,30 +9395,6 @@
|
|
|
9237
9395
|
* NOW we are working just with markdown string and its good enough
|
|
9238
9396
|
*/
|
|
9239
9397
|
|
|
9240
|
-
/**
|
|
9241
|
-
* @@@
|
|
9242
|
-
*
|
|
9243
|
-
* @param value @@@
|
|
9244
|
-
* @returns @@@
|
|
9245
|
-
* @example @@@
|
|
9246
|
-
* @public exported from `@promptbook/utils`
|
|
9247
|
-
*/
|
|
9248
|
-
function titleToName(value) {
|
|
9249
|
-
if (isValidUrl(value)) {
|
|
9250
|
-
value = value.replace(/^https?:\/\//, '');
|
|
9251
|
-
value = value.replace(/\.html$/, '');
|
|
9252
|
-
}
|
|
9253
|
-
else if (isValidFilePath(value)) {
|
|
9254
|
-
value = path.basename(value);
|
|
9255
|
-
// Note: Keeping extension in the name
|
|
9256
|
-
}
|
|
9257
|
-
value = value.split('/').join('-');
|
|
9258
|
-
value = removeEmojis(value);
|
|
9259
|
-
value = normalizeToKebabCase(value);
|
|
9260
|
-
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
9261
|
-
return value;
|
|
9262
|
-
}
|
|
9263
|
-
|
|
9264
9398
|
/**
|
|
9265
9399
|
* Compile pipeline from string (markdown) format to JSON format synchronously
|
|
9266
9400
|
*
|
|
@@ -10382,6 +10516,9 @@
|
|
|
10382
10516
|
* @public exported from `@promptbook/utils`
|
|
10383
10517
|
*/
|
|
10384
10518
|
var $isRunningInNode = new Function("\n try {\n return this === global;\n } catch (e) {\n return false;\n }\n");
|
|
10519
|
+
/**
|
|
10520
|
+
* TODO: [☑]
|
|
10521
|
+
*/
|
|
10385
10522
|
|
|
10386
10523
|
/**
|
|
10387
10524
|
* Creates a message with all registered LLM tools
|
|
@@ -10461,10 +10598,11 @@
|
|
|
10461
10598
|
// <- Note: [🗨]
|
|
10462
10599
|
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isFullyConfigured: isFullyConfigured, isPartiallyConfigured: isPartiallyConfigured });
|
|
10463
10600
|
});
|
|
10601
|
+
var usedEnvMessage = "Unknown `.env` file" ;
|
|
10464
10602
|
if (metadata.length === 0) {
|
|
10465
|
-
return "No LLM providers are available.";
|
|
10603
|
+
return spaceTrim__default["default"](function (block) { return "\n No LLM providers are available.\n\n ".concat(block(usedEnvMessage), "\n "); });
|
|
10466
10604
|
}
|
|
10467
|
-
return spaceTrim__default["default"](function (block) { return "\n Relevant environment variables:\n ".concat(block(Object.keys(env)
|
|
10605
|
+
return spaceTrim__default["default"](function (block) { return "\n\n ".concat(block(usedEnvMessage), "\n\n Relevant environment variables:\n ").concat(block(Object.keys(env)
|
|
10468
10606
|
.filter(function (envVariableName) {
|
|
10469
10607
|
return metadata.some(function (_a) {
|
|
10470
10608
|
var envVariables = _a.envVariables;
|
|
@@ -10912,6 +11050,58 @@
|
|
|
10912
11050
|
* @public exported from `@promptbook/utils`
|
|
10913
11051
|
*/
|
|
10914
11052
|
var $isRunningInJest = new Function("\n try {\n return process.env.JEST_WORKER_ID !== undefined;\n } catch (e) {\n return false;\n }\n");
|
|
11053
|
+
/**
|
|
11054
|
+
* TODO: [☑]
|
|
11055
|
+
*/
|
|
11056
|
+
|
|
11057
|
+
/**
|
|
11058
|
+
* Registration of LLM provider metadata
|
|
11059
|
+
*
|
|
11060
|
+
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
|
|
11061
|
+
*
|
|
11062
|
+
* @public exported from `@promptbook/core`
|
|
11063
|
+
* @public exported from `@promptbook/wizzard`
|
|
11064
|
+
* @public exported from `@promptbook/cli`
|
|
11065
|
+
*/
|
|
11066
|
+
var _DeepseekMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
11067
|
+
title: 'Deepseek',
|
|
11068
|
+
packageName: '@promptbook/deepseek',
|
|
11069
|
+
className: 'DeepseekExecutionTools',
|
|
11070
|
+
envVariables: ['DEEPSEEK_GENERATIVE_AI_API_KEY'],
|
|
11071
|
+
getBoilerplateConfiguration: function () {
|
|
11072
|
+
return {
|
|
11073
|
+
title: 'Deepseek (boilerplate)',
|
|
11074
|
+
packageName: '@promptbook/deepseek',
|
|
11075
|
+
className: 'DeepseekExecutionTools',
|
|
11076
|
+
options: {
|
|
11077
|
+
apiKey: 'AI',
|
|
11078
|
+
},
|
|
11079
|
+
};
|
|
11080
|
+
},
|
|
11081
|
+
createConfigurationFromEnv: function (env) {
|
|
11082
|
+
if ($isRunningInJest()
|
|
11083
|
+
// <- TODO: Maybe check `env.JEST_WORKER_ID` directly here or pass `env` into `$isRunningInJest`
|
|
11084
|
+
) {
|
|
11085
|
+
// Note: [🔘] Maybe same problem as Gemini
|
|
11086
|
+
return null;
|
|
11087
|
+
}
|
|
11088
|
+
// Note: Note using `process.env` BUT `env` to pass in the environment variables dynamically
|
|
11089
|
+
if (typeof env.DEEPSEEK_GENERATIVE_AI_API_KEY === 'string') {
|
|
11090
|
+
return {
|
|
11091
|
+
title: 'Deepseek (from env)',
|
|
11092
|
+
packageName: '@promptbook/deepseek',
|
|
11093
|
+
className: 'DeepseekExecutionTools',
|
|
11094
|
+
options: {
|
|
11095
|
+
apiKey: env.DEEPSEEK_GENERATIVE_AI_API_KEY,
|
|
11096
|
+
},
|
|
11097
|
+
};
|
|
11098
|
+
}
|
|
11099
|
+
return null;
|
|
11100
|
+
},
|
|
11101
|
+
});
|
|
11102
|
+
/**
|
|
11103
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
11104
|
+
*/
|
|
10915
11105
|
|
|
10916
11106
|
/**
|
|
10917
11107
|
* Registration of LLM provider metadata
|
|
@@ -11077,13 +11267,14 @@
|
|
|
11077
11267
|
/**
|
|
11078
11268
|
* Tag function for notating a prompt as template literal
|
|
11079
11269
|
*
|
|
11080
|
-
* Note: There are
|
|
11270
|
+
* Note: There are 3 similar functions:
|
|
11081
11271
|
* 1) `prompt` for notating single prompt exported from `@promptbook/utils`
|
|
11082
|
-
*
|
|
11272
|
+
* 2) `promptTemplate` alias for `prompt`
|
|
11273
|
+
* 3) `book` for notating and validating entire books exported from `@promptbook/utils`
|
|
11083
11274
|
*
|
|
11084
|
-
* @param strings
|
|
11085
|
-
* @param values
|
|
11086
|
-
* @returns the
|
|
11275
|
+
* @param strings
|
|
11276
|
+
* @param values
|
|
11277
|
+
* @returns the prompt string
|
|
11087
11278
|
* @public exported from `@promptbook/utils`
|
|
11088
11279
|
*/
|
|
11089
11280
|
function prompt(strings) {
|
|
@@ -11094,10 +11285,14 @@
|
|
|
11094
11285
|
if (values.length === 0) {
|
|
11095
11286
|
return spaceTrim__default["default"](strings.join(''));
|
|
11096
11287
|
}
|
|
11288
|
+
var stringsWithHiddenParameters = strings.map(function (stringsItem) {
|
|
11289
|
+
// TODO: [0] DRY
|
|
11290
|
+
return stringsItem.split('{').join("".concat(REPLACING_NONCE, "beginbracket")).split('}').join("".concat(REPLACING_NONCE, "endbracket"));
|
|
11291
|
+
});
|
|
11097
11292
|
var placeholderParameterNames = values.map(function (value, i) { return "".concat(REPLACING_NONCE).concat(i); });
|
|
11098
11293
|
var parameters = Object.fromEntries(values.map(function (value, i) { return [placeholderParameterNames[i], value]; }));
|
|
11099
11294
|
// Combine strings and values
|
|
11100
|
-
var pipelineString =
|
|
11295
|
+
var pipelineString = stringsWithHiddenParameters.reduce(function (result, stringsItem, i) {
|
|
11101
11296
|
return placeholderParameterNames[i] === undefined
|
|
11102
11297
|
? "".concat(result).concat(stringsItem)
|
|
11103
11298
|
: "".concat(result).concat(stringsItem, "{").concat(placeholderParameterNames[i], "}");
|
|
@@ -11113,6 +11308,12 @@
|
|
|
11113
11308
|
console.error({ pipelineString: pipelineString, parameters: parameters, placeholderParameterNames: placeholderParameterNames, error: error });
|
|
11114
11309
|
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n Internal error in prompt template literal\n \n ".concat(block(JSON.stringify({ strings: strings, values: values }, null, 4)), "}\n \n "); }));
|
|
11115
11310
|
}
|
|
11311
|
+
// TODO: [0] DRY
|
|
11312
|
+
pipelineString = pipelineString
|
|
11313
|
+
.split("".concat(REPLACING_NONCE, "beginbracket"))
|
|
11314
|
+
.join('{')
|
|
11315
|
+
.split("".concat(REPLACING_NONCE, "endbracket"))
|
|
11316
|
+
.join('}');
|
|
11116
11317
|
return pipelineString;
|
|
11117
11318
|
}
|
|
11118
11319
|
/**
|
|
@@ -11123,9 +11324,10 @@
|
|
|
11123
11324
|
/**
|
|
11124
11325
|
* Tag function for notating a pipeline with a book\`...\ notation as template literal
|
|
11125
11326
|
*
|
|
11126
|
-
* Note: There are
|
|
11327
|
+
* Note: There are 3 similar functions:
|
|
11127
11328
|
* 1) `prompt` for notating single prompt exported from `@promptbook/utils`
|
|
11128
|
-
*
|
|
11329
|
+
* 2) `promptTemplate` alias for `prompt`
|
|
11330
|
+
* 3) `book` for notating and validating entire books exported from `@promptbook/utils`
|
|
11129
11331
|
*
|
|
11130
11332
|
* @param strings @@@
|
|
11131
11333
|
* @param values @@@
|
|
@@ -11285,7 +11487,7 @@
|
|
|
11285
11487
|
className: 'MarkitdownScraper',
|
|
11286
11488
|
mimeTypes: [
|
|
11287
11489
|
'application/pdf',
|
|
11288
|
-
// TODO: Make priority for scrapers and than allow all mime types here:
|
|
11490
|
+
// TODO: [💵] Make priority for scrapers and than analyze which mime-types can Markitdown scrape and allow all mime types here:
|
|
11289
11491
|
// 'text/html',
|
|
11290
11492
|
// 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
11291
11493
|
],
|
|
@@ -11465,17 +11667,21 @@
|
|
|
11465
11667
|
exports.CsvFormatDefinition = CsvFormatDefinition;
|
|
11466
11668
|
exports.CsvFormatError = CsvFormatError;
|
|
11467
11669
|
exports.DEFAULT_BOOKS_DIRNAME = DEFAULT_BOOKS_DIRNAME;
|
|
11670
|
+
exports.DEFAULT_BOOK_OUTPUT_PARAMETER_NAME = DEFAULT_BOOK_OUTPUT_PARAMETER_NAME;
|
|
11468
11671
|
exports.DEFAULT_BOOK_TITLE = DEFAULT_BOOK_TITLE;
|
|
11469
11672
|
exports.DEFAULT_CSV_SETTINGS = DEFAULT_CSV_SETTINGS;
|
|
11470
|
-
exports.
|
|
11673
|
+
exports.DEFAULT_DOWNLOAD_CACHE_DIRNAME = DEFAULT_DOWNLOAD_CACHE_DIRNAME;
|
|
11674
|
+
exports.DEFAULT_EXECUTION_CACHE_DIRNAME = DEFAULT_EXECUTION_CACHE_DIRNAME;
|
|
11471
11675
|
exports.DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME;
|
|
11472
11676
|
exports.DEFAULT_INTERMEDIATE_FILES_STRATEGY = DEFAULT_INTERMEDIATE_FILES_STRATEGY;
|
|
11473
11677
|
exports.DEFAULT_IS_AUTO_INSTALLED = DEFAULT_IS_AUTO_INSTALLED;
|
|
11474
11678
|
exports.DEFAULT_MAX_EXECUTION_ATTEMPTS = DEFAULT_MAX_EXECUTION_ATTEMPTS;
|
|
11679
|
+
exports.DEFAULT_MAX_FILE_SIZE = DEFAULT_MAX_FILE_SIZE;
|
|
11475
11680
|
exports.DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH;
|
|
11476
11681
|
exports.DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL;
|
|
11477
11682
|
exports.DEFAULT_MAX_PARALLEL_COUNT = DEFAULT_MAX_PARALLEL_COUNT;
|
|
11478
11683
|
exports.DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME;
|
|
11684
|
+
exports.DEFAULT_PROMPT_TASK_TITLE = DEFAULT_PROMPT_TASK_TITLE;
|
|
11479
11685
|
exports.DEFAULT_REMOTE_URL = DEFAULT_REMOTE_URL;
|
|
11480
11686
|
exports.DEFAULT_REMOTE_URL_PATH = DEFAULT_REMOTE_URL_PATH;
|
|
11481
11687
|
exports.DEFAULT_SCRAPE_CACHE_DIRNAME = DEFAULT_SCRAPE_CACHE_DIRNAME;
|
|
@@ -11525,6 +11731,7 @@
|
|
|
11525
11731
|
exports._AnthropicClaudeMetadataRegistration = _AnthropicClaudeMetadataRegistration;
|
|
11526
11732
|
exports._AzureOpenAiMetadataRegistration = _AzureOpenAiMetadataRegistration;
|
|
11527
11733
|
exports._BoilerplateScraperMetadataRegistration = _BoilerplateScraperMetadataRegistration;
|
|
11734
|
+
exports._DeepseekMetadataRegistration = _DeepseekMetadataRegistration;
|
|
11528
11735
|
exports._DocumentScraperMetadataRegistration = _DocumentScraperMetadataRegistration;
|
|
11529
11736
|
exports._GoogleMetadataRegistration = _GoogleMetadataRegistration;
|
|
11530
11737
|
exports._LegacyDocumentScraperMetadataRegistration = _LegacyDocumentScraperMetadataRegistration;
|