@promptbook/cli 0.84.0-15 → 0.84.0-17

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 CHANGED
@@ -14,9 +14,9 @@
14
14
 
15
15
 
16
16
 
17
- ## New Features
17
+ ## 🌟 New Features
18
18
 
19
- - 🐋 **Support of [DeepSeek models](https://www.deepseek.com/)**
19
+ - 🐋 **Support of [DeepSeek models](https://www.npmjs.com/package/@promptbook/deepseek)**
20
20
  - 💙 Working [the **Book** language v1.0.0](https://github.com/webgptorg/book)
21
21
  - 🖤 Run books from CLI - `npx ptbk run path/to/your/book`
22
22
  - 📚 Support of `.docx`, `.doc` and `.pdf` documents as knowledge
@@ -320,8 +320,9 @@ Or you can install them separately:
320
320
  - **[@promptbook/anthropic-claude](https://www.npmjs.com/package/@promptbook/anthropic-claude)** - Execution tools for Anthropic Claude API, wrapper around Anthropic Claude SDK
321
321
  - **[@promptbook/vercel](https://www.npmjs.com/package/@promptbook/vercel)** - Adapter for Vercel functionalities
322
322
  - **[@promptbook/google](https://www.npmjs.com/package/@promptbook/google)** - Integration with Google's Gemini API
323
+ - **[@promptbook/deepseek](https://www.npmjs.com/package/@promptbook/deepseek)** - Integration with [DeepSeek API](https://www.deepseek.com/)
323
324
  - **[@promptbook/azure-openai](https://www.npmjs.com/package/@promptbook/azure-openai)** - Execution tools for Azure OpenAI API
324
- - **[@promptbook/langtail](https://www.npmjs.com/package/@promptbook/langtail)** - Execution tools for Langtail API, wrapper around Langtail SDK
325
+
325
326
  - **[@promptbook/fake-llm](https://www.npmjs.com/package/@promptbook/fake-llm)** - Mocked execution tools for testing the library and saving the tokens
326
327
  - **[@promptbook/remote-client](https://www.npmjs.com/package/@promptbook/remote-client)** - Remote client for remote execution of promptbooks
327
328
  - **[@promptbook/remote-server](https://www.npmjs.com/package/@promptbook/remote-server)** - Remote server for remote execution of promptbooks
@@ -491,6 +492,12 @@ See [TODO.md](./TODO.md)
491
492
 
492
493
 
493
494
 
495
+
496
+ ## 🤝 Partners
497
+
498
+ [![Technology Incubation](./other/partners/CI-Technology-Incubation.png)](https://technologickainkubace.org/en/about-technology-incubation/about-the-project/)
499
+
500
+
494
501
  ## 🖋️ Contributing
495
502
 
496
503
  I am open to pull requests, feedback, and suggestions. Or if you like this utility, you can [☕ buy me a coffee](https://www.buymeacoffee.com/hejny) or [donate via cryptocurrencies](https://github.com/hejny/hejny/blob/main/documents/crypto.md).
package/esm/index.es.js CHANGED
@@ -38,7 +38,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
38
38
  * @generated
39
39
  * @see https://github.com/webgptorg/promptbook
40
40
  */
41
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-14';
41
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-16';
42
42
  /**
43
43
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
44
44
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -235,6 +235,12 @@ var DEFAULT_TASK_TITLE = "Task";
235
235
  * @public exported from `@promptbook/core`
236
236
  */
237
237
  var DEFAULT_BOOK_OUTPUT_PARAMETER_NAME = 'result';
238
+ /**
239
+ * Maximum file size limit
240
+ *
241
+ * @public exported from `@promptbook/core`
242
+ */
243
+ var DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
238
244
  /**
239
245
  * Warning message for the generated sections and files files
240
246
  *
@@ -6527,11 +6533,10 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
6527
6533
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6528
6534
  var _a;
6529
6535
  return __awaiter(this, void 0, void 0, function () {
6530
- var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, _f, _g, _h, _j, _k, filename_1, fileExtension, mimeType;
6531
- return __generator(this, function (_l) {
6532
- switch (_l.label) {
6536
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, fileContent, _f, _g, filename_1, fileExtension, mimeType;
6537
+ return __generator(this, function (_h) {
6538
+ switch (_h.label) {
6533
6539
  case 0:
6534
- console.log('!!! makeKnowledgeSourceHandler', knowledgeSource);
6535
6540
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
6536
6541
  knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
6537
6542
  name = knowledgeSource.name;
@@ -6543,7 +6548,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6543
6548
  url = knowledgeSourceContent;
6544
6549
  return [4 /*yield*/, fetch(url)];
6545
6550
  case 1:
6546
- response_1 = _l.sent();
6551
+ response_1 = _h.sent();
6547
6552
  mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
6548
6553
  if (tools.fs === undefined || !url.endsWith('.pdf' /* <- TODO: [💵] */)) {
6549
6554
  return [2 /*return*/, {
@@ -6593,17 +6598,19 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6593
6598
  filepath = 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));
6594
6599
  return [4 /*yield*/, tools.fs.mkdir(dirname(join(rootDirname_1, filepath)), { recursive: true })];
6595
6600
  case 2:
6596
- _l.sent();
6597
- _g = (_f = tools.fs).writeFile;
6598
- _h = [join(rootDirname_1, filepath)];
6599
- _k = (_j = Buffer).from;
6601
+ _h.sent();
6602
+ _g = (_f = Buffer).from;
6600
6603
  return [4 /*yield*/, response_1.arrayBuffer()];
6601
- case 3: return [4 /*yield*/, _g.apply(_f, _h.concat([_k.apply(_j, [_l.sent()])]))];
6604
+ case 3:
6605
+ fileContent = _g.apply(_f, [_h.sent()]);
6606
+ if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
6607
+ 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."));
6608
+ }
6609
+ return [4 /*yield*/, tools.fs.writeFile(join(rootDirname_1, filepath), fileContent)];
6602
6610
  case 4:
6603
- _l.sent();
6611
+ _h.sent();
6604
6612
  // TODO: [💵] Check the file security
6605
- // TODO: !!!!!!!! Check the file size (if it is not too big)
6606
- // TODO: !!!!!!!! Delete the file after the scraping is done
6613
+ // TODO: [🧹][🧠] Delete the file after the scraping is done
6607
6614
  return [2 /*return*/, makeKnowledgeSourceHandler({ name: name, knowledgeSourceContent: filepath }, tools, __assign(__assign({}, options), { rootDirname: rootDirname_1 }))];
6608
6615
  case 5:
6609
6616
  if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 7];
@@ -6620,7 +6627,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6620
6627
  mimeType = extensionToMimeType(fileExtension || '');
6621
6628
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
6622
6629
  case 6:
6623
- if (!(_l.sent())) {
6630
+ if (!(_h.sent())) {
6624
6631
  throw new NotFoundError(spaceTrim(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 "); }));
6625
6632
  }
6626
6633
  // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
@@ -15058,16 +15065,16 @@ var _AzureOpenAiRegistration = $llmToolsRegister.register(createAzureOpenAiExecu
15058
15065
  * @public exported from `@promptbook/wizzard`
15059
15066
  * @public exported from `@promptbook/cli`
15060
15067
  */
15061
- var _GoogleMetadataRegistration = $llmToolsMetadataRegister.register({
15062
- title: 'Google Gemini',
15063
- packageName: '@promptbook/google',
15064
- className: 'GoogleExecutionTools',
15065
- envVariables: ['GOOGLE_GENERATIVE_AI_API_KEY'],
15068
+ var _DeepseekMetadataRegistration = $llmToolsMetadataRegister.register({
15069
+ title: 'Deepseek',
15070
+ packageName: '@promptbook/deepseek',
15071
+ className: 'DeepseekExecutionTools',
15072
+ envVariables: ['DEEPSEEK_GENERATIVE_AI_API_KEY'],
15066
15073
  getBoilerplateConfiguration: function () {
15067
15074
  return {
15068
- title: 'Google Gemini (boilerplate)',
15069
- packageName: '@promptbook/google',
15070
- className: 'GoogleExecutionTools',
15075
+ title: 'Deepseek (boilerplate)',
15076
+ packageName: '@promptbook/deepseek',
15077
+ className: 'DeepseekExecutionTools',
15071
15078
  options: {
15072
15079
  apiKey: 'AI',
15073
15080
  },
@@ -15077,17 +15084,17 @@ var _GoogleMetadataRegistration = $llmToolsMetadataRegister.register({
15077
15084
  if ($isRunningInJest()
15078
15085
  // <- TODO: Maybe check `env.JEST_WORKER_ID` directly here or pass `env` into `$isRunningInJest`
15079
15086
  ) {
15080
- // Note: [🔘] Gemini makes problems in Jest environment
15087
+ // Note: [🔘] Maybe same problem as Gemini
15081
15088
  return null;
15082
15089
  }
15083
15090
  // Note: Note using `process.env` BUT `env` to pass in the environment variables dynamically
15084
- if (typeof env.GOOGLE_GENERATIVE_AI_API_KEY === 'string') {
15091
+ if (typeof env.DEEPSEEK_GENERATIVE_AI_API_KEY === 'string') {
15085
15092
  return {
15086
- title: 'Google Gemini (from env)',
15087
- packageName: '@promptbook/google',
15088
- className: 'GoogleExecutionTools',
15093
+ title: 'Deepseek (from env)',
15094
+ packageName: '@promptbook/deepseek',
15095
+ className: 'DeepseekExecutionTools',
15089
15096
  options: {
15090
- apiKey: env.GOOGLE_GENERATIVE_AI_API_KEY,
15097
+ apiKey: env.DEEPSEEK_GENERATIVE_AI_API_KEY,
15091
15098
  },
15092
15099
  };
15093
15100
  }
@@ -15268,6 +15275,98 @@ function createExecutionToolsFromVercelProvider(options) {
15268
15275
  };
15269
15276
  }
15270
15277
 
15278
+ /**
15279
+ * Execution Tools for calling Deepseek API.
15280
+ *
15281
+ * @public exported from `@promptbook/deepseek`
15282
+ */
15283
+ var createDeepseekExecutionTools = Object.assign(function (options) {
15284
+ if ($isRunningInJest()) {
15285
+ // Note: [🔘]
15286
+ throw new Error('DeepseekExecutionTools are not supported in Jest environment');
15287
+ }
15288
+ // Note: [🔘] Maybe there is same compatibility problem as in '@ai-sdk/deepseek'
15289
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
15290
+ var createDeepSeek = require('@ai-sdk/deepseek').createDeepSeek;
15291
+ var deepseekVercelProvider = createDeepSeek(__assign({}, options));
15292
+ return createExecutionToolsFromVercelProvider(__assign({ title: 'Deepseek', description: 'Implementation of Deepseek models', vercelProvider: deepseekVercelProvider, availableModels: [
15293
+ // TODO: [🕘] Maybe list models in same way as in other providers - in separate file with metadata
15294
+ 'deepseek-chat',
15295
+ 'deepseek-reasoner',
15296
+ // <- TODO: How picking of the default model looks like in `createExecutionToolsFromVercelProvider`
15297
+ ].map(function (modelName) { return ({ modelName: modelName, modelVariant: 'CHAT' }); }) }, options));
15298
+ }, {
15299
+ packageName: '@promptbook/deepseek',
15300
+ className: 'DeepseekExecutionTools',
15301
+ });
15302
+ /**
15303
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
15304
+ */
15305
+
15306
+ /**
15307
+ * Registration of LLM provider
15308
+ *
15309
+ * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
15310
+ *
15311
+ * @public exported from `@promptbook/deepseek`
15312
+ * @public exported from `@promptbook/wizzard`
15313
+ * @public exported from `@promptbook/cli`
15314
+ */
15315
+ var _DeepseekRegistration = $llmToolsRegister.register(createDeepseekExecutionTools);
15316
+ /**
15317
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
15318
+ * Note: [💞] Ignore a discrepancy between file name and entity name
15319
+ */
15320
+
15321
+ /**
15322
+ * Registration of LLM provider metadata
15323
+ *
15324
+ * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
15325
+ *
15326
+ * @public exported from `@promptbook/core`
15327
+ * @public exported from `@promptbook/wizzard`
15328
+ * @public exported from `@promptbook/cli`
15329
+ */
15330
+ var _GoogleMetadataRegistration = $llmToolsMetadataRegister.register({
15331
+ title: 'Google Gemini',
15332
+ packageName: '@promptbook/google',
15333
+ className: 'GoogleExecutionTools',
15334
+ envVariables: ['GOOGLE_GENERATIVE_AI_API_KEY'],
15335
+ getBoilerplateConfiguration: function () {
15336
+ return {
15337
+ title: 'Google Gemini (boilerplate)',
15338
+ packageName: '@promptbook/google',
15339
+ className: 'GoogleExecutionTools',
15340
+ options: {
15341
+ apiKey: 'AI',
15342
+ },
15343
+ };
15344
+ },
15345
+ createConfigurationFromEnv: function (env) {
15346
+ if ($isRunningInJest()
15347
+ // <- TODO: Maybe check `env.JEST_WORKER_ID` directly here or pass `env` into `$isRunningInJest`
15348
+ ) {
15349
+ // Note: [🔘] Gemini makes problems in Jest environment
15350
+ return null;
15351
+ }
15352
+ // Note: Note using `process.env` BUT `env` to pass in the environment variables dynamically
15353
+ if (typeof env.GOOGLE_GENERATIVE_AI_API_KEY === 'string') {
15354
+ return {
15355
+ title: 'Google Gemini (from env)',
15356
+ packageName: '@promptbook/google',
15357
+ className: 'GoogleExecutionTools',
15358
+ options: {
15359
+ apiKey: env.GOOGLE_GENERATIVE_AI_API_KEY,
15360
+ },
15361
+ };
15362
+ }
15363
+ return null;
15364
+ },
15365
+ });
15366
+ /**
15367
+ * Note: [💞] Ignore a discrepancy between file name and entity name
15368
+ */
15369
+
15271
15370
  /**
15272
15371
  * Execution Tools for calling Google Gemini API.
15273
15372
  *
@@ -17020,7 +17119,7 @@ var MarkitdownScraper = /** @class */ (function () {
17020
17119
  // Note: Module `markitdown-ts` has no types available, so it is imported using `require`
17021
17120
  // eslint-disable-next-line @typescript-eslint/no-var-requires
17022
17121
  var MarkItDown = require('markitdown-ts').MarkItDown;
17023
- // <- TODO: 'Use Markitdown directly not through this package
17122
+ // <- TODO: [🍀] Use Markitdown directly not through this package
17024
17123
  this.markitdown = new MarkItDown();
17025
17124
  }
17026
17125
  Object.defineProperty(MarkitdownScraper.prototype, "metadata", {
@@ -17065,7 +17164,7 @@ var MarkitdownScraper = /** @class */ (function () {
17065
17164
  case 2:
17066
17165
  if (!!(_f.sent())) return [3 /*break*/, 5];
17067
17166
  src = source.filename || source.url || null;
17068
- // console.log('!!!', { src, source, cacheFilehandler });
17167
+ // console.log('!!', { src, source, cacheFilehandler });
17069
17168
  if (src === null) {
17070
17169
  throw new UnexpectedError('Source has no filename or url');
17071
17170
  }
@@ -17078,12 +17177,12 @@ var MarkitdownScraper = /** @class */ (function () {
17078
17177
  result = _f.sent();
17079
17178
  if (result === null || result === undefined) {
17080
17179
  throw new Error("Markitdown could not convert the \"".concat(source.source, "\""));
17081
- // <- TODO: !!! Make MarkitdownError
17180
+ // <- TODO: [🍀] Make MarkitdownError
17082
17181
  }
17083
- // console.log('!!!', { result, cacheFilehandler });
17182
+ // console.log('!!', { result, cacheFilehandler });
17084
17183
  return [4 /*yield*/, this.tools.fs.writeFile(cacheFilehandler.filename, result.text_content)];
17085
17184
  case 4:
17086
- // console.log('!!!', { result, cacheFilehandler });
17185
+ // console.log('!!', { result, cacheFilehandler });
17087
17186
  _f.sent();
17088
17187
  _f.label = 5;
17089
17188
  case 5: return [2 /*return*/, cacheFilehandler];
@@ -17501,5 +17600,5 @@ var _WebsiteScraperRegistration = $scrapersRegister.register(createWebsiteScrape
17501
17600
  * Note: [💞] Ignore a discrepancy between file name and entity name
17502
17601
  */
17503
17602
 
17504
- export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, _AnthropicClaudeMetadataRegistration, _AnthropicClaudeRegistration, _AzureOpenAiMetadataRegistration, _AzureOpenAiRegistration, _BoilerplateScraperMetadataRegistration, _BoilerplateScraperRegistration, _CLI, _DocumentScraperMetadataRegistration, _DocumentScraperRegistration, _GoogleMetadataRegistration, _GoogleRegistration, _LegacyDocumentScraperMetadataRegistration, _LegacyDocumentScraperRegistration, _MarkdownScraperMetadataRegistration, _MarkdownScraperRegistration, _MarkitdownScraperMetadataRegistration, _MarkitdownScraperRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiAssistantRegistration, _OpenAiMetadataRegistration, _OpenAiRegistration, _PdfScraperMetadataRegistration, _PdfScraperRegistration, _WebsiteScraperMetadataRegistration, _WebsiteScraperRegistration };
17603
+ export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, _AnthropicClaudeMetadataRegistration, _AnthropicClaudeRegistration, _AzureOpenAiMetadataRegistration, _AzureOpenAiRegistration, _BoilerplateScraperMetadataRegistration, _BoilerplateScraperRegistration, _CLI, _DeepseekMetadataRegistration, _DeepseekRegistration, _DocumentScraperMetadataRegistration, _DocumentScraperRegistration, _GoogleMetadataRegistration, _GoogleRegistration, _LegacyDocumentScraperMetadataRegistration, _LegacyDocumentScraperRegistration, _MarkdownScraperMetadataRegistration, _MarkdownScraperRegistration, _MarkitdownScraperMetadataRegistration, _MarkitdownScraperRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiAssistantRegistration, _OpenAiMetadataRegistration, _OpenAiRegistration, _PdfScraperMetadataRegistration, _PdfScraperRegistration, _WebsiteScraperMetadataRegistration, _WebsiteScraperRegistration };
17505
17604
  //# sourceMappingURL=index.es.js.map