@promptbook/pdf 0.84.0-21 → 0.84.0-9

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.
Files changed (38) hide show
  1. package/README.md +5 -21
  2. package/esm/index.es.js +71 -170
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/cli.index.d.ts +0 -4
  5. package/esm/typings/src/_packages/core.index.d.ts +2 -12
  6. package/esm/typings/src/_packages/types.index.d.ts +0 -2
  7. package/esm/typings/src/_packages/utils.index.d.ts +0 -2
  8. package/esm/typings/src/_packages/wizzard.index.d.ts +0 -4
  9. package/esm/typings/src/cli/cli-commands/about.d.ts +1 -3
  10. package/esm/typings/src/cli/cli-commands/hello.d.ts +1 -3
  11. package/esm/typings/src/cli/cli-commands/list-models.d.ts +1 -3
  12. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -3
  13. package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -3
  14. package/esm/typings/src/cli/cli-commands/run.d.ts +1 -3
  15. package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +1 -1
  16. package/esm/typings/src/cli/cli-commands/test-command.d.ts +1 -3
  17. package/esm/typings/src/config.d.ts +1 -27
  18. package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +1 -1
  19. package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
  20. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -3
  21. package/esm/typings/src/pipeline/book-notation.d.ts +2 -3
  22. package/esm/typings/src/pipeline/prompt-notation.d.ts +5 -18
  23. package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +1 -1
  24. package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +2 -5
  25. package/esm/typings/src/wizzard/wizzard.d.ts +1 -7
  26. package/package.json +16 -9
  27. package/umd/index.umd.js +74 -173
  28. package/umd/index.umd.js.map +1 -1
  29. package/esm/typings/src/_packages/deepseek.index.d.ts +0 -8
  30. package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +0 -13
  31. package/esm/typings/src/llm-providers/deepseek/DeepseekExecutionToolsOptions.d.ts +0 -9
  32. package/esm/typings/src/llm-providers/deepseek/createDeepseekExecutionTools.d.ts +0 -14
  33. package/esm/typings/src/llm-providers/deepseek/register-configuration.d.ts +0 -14
  34. package/esm/typings/src/llm-providers/deepseek/register-constructor.d.ts +0 -15
  35. package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.test.d.ts +0 -1
  36. package/esm/typings/src/utils/editable/utils/isFlatPipeline.test.d.ts +0 -1
  37. package/esm/typings/src/utils/files/mimeTypeToExtension.d.ts +0 -10
  38. package/esm/typings/src/utils/files/mimeTypeToExtension.test.d.ts +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <!-- ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten -->
2
2
 
3
- # Promptbook
3
+ # Promptbook
4
4
 
5
5
 
6
6
 
@@ -14,13 +14,12 @@
14
14
 
15
15
 
16
16
 
17
- ## 🌟 New Features
17
+ ## New Features
18
18
 
19
- - 💫 Support of [`o3-mini` model by OpenAI](https://openai.com/index/openai-o3-mini/)
20
- - 🐋 **Support of [DeepSeek models](https://www.npmjs.com/package/@promptbook/deepseek)**
21
19
  - 💙 Working [the **Book** language v1.0.0](https://github.com/webgptorg/book)
22
20
  - 🖤 Run books from CLI - `npx ptbk run path/to/your/book`
23
- - 📚 Support of `.docx`, `.doc` and `.pdf` documents as knowledge
21
+ - 📚 Support of `.docx`, `.doc` and `.pdf` documents
22
+ - ✨ **Support of [OpenAI o1 model](https://openai.com/o1/)**
24
23
 
25
24
 
26
25
 
@@ -266,9 +265,8 @@ Or you can install them separately:
266
265
  - **[@promptbook/anthropic-claude](https://www.npmjs.com/package/@promptbook/anthropic-claude)** - Execution tools for Anthropic Claude API, wrapper around Anthropic Claude SDK
267
266
  - **[@promptbook/vercel](https://www.npmjs.com/package/@promptbook/vercel)** - Adapter for Vercel functionalities
268
267
  - **[@promptbook/google](https://www.npmjs.com/package/@promptbook/google)** - Integration with Google's Gemini API
269
- - **[@promptbook/deepseek](https://www.npmjs.com/package/@promptbook/deepseek)** - Integration with [DeepSeek API](https://www.deepseek.com/)
270
268
  - **[@promptbook/azure-openai](https://www.npmjs.com/package/@promptbook/azure-openai)** - Execution tools for Azure OpenAI API
271
-
269
+ - **[@promptbook/langtail](https://www.npmjs.com/package/@promptbook/langtail)** - Execution tools for Langtail API, wrapper around Langtail SDK
272
270
  - **[@promptbook/fake-llm](https://www.npmjs.com/package/@promptbook/fake-llm)** - Mocked execution tools for testing the library and saving the tokens
273
271
  - **[@promptbook/remote-client](https://www.npmjs.com/package/@promptbook/remote-client)** - Remote client for remote execution of promptbooks
274
272
  - **[@promptbook/remote-server](https://www.npmjs.com/package/@promptbook/remote-server)** - Remote server for remote execution of promptbooks
@@ -438,20 +436,6 @@ See [TODO.md](./TODO.md)
438
436
 
439
437
 
440
438
 
441
- ## 🤝 Partners
442
-
443
- <div style="display: flex; align-items: center; gap: 20px;">
444
-
445
- <a href="https://promptbook.studio/">
446
- <img src="./other/design/promptbook-studio-logo.png" alt="Partner 3" height="100">
447
- </a>
448
-
449
- <a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
450
- <img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="100">
451
- </a>
452
-
453
- </div>
454
-
455
439
  ## 🖋️ Contributing
456
440
 
457
441
  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
@@ -6,8 +6,7 @@ import { basename, join, dirname } from 'path';
6
6
  import { format } from 'prettier';
7
7
  import parserHtml from 'prettier/parser-html';
8
8
  import { forTime } from 'waitasecond';
9
- import sha256 from 'crypto-js/sha256';
10
- import { lookup, extension } from 'mime-types';
9
+ import { lookup } from 'mime-types';
11
10
  import { unparse, parse } from 'papaparse';
12
11
 
13
12
  // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
@@ -24,7 +23,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
24
23
  * @generated
25
24
  * @see https://github.com/webgptorg/promptbook
26
25
  */
27
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-20';
26
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-8';
28
27
  /**
29
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
30
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -195,12 +194,6 @@ var ADMIN_GITHUB_NAME = 'hejny';
195
194
  * @public exported from `@promptbook/core`
196
195
  */
197
196
  var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
198
- /**
199
- * Maximum file size limit
200
- *
201
- * @public exported from `@promptbook/core`
202
- */
203
- var DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
204
197
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
205
198
  /**
206
199
  * The maximum number of iterations for a loops
@@ -234,12 +227,6 @@ var SMALL_NUMBER = 0.001;
234
227
  * @private within the repository - too low-level in comparison with other `MAX_...`
235
228
  */
236
229
  var IMMEDIATE_TIME = 10;
237
- /**
238
- * The maximum length of the (generated) filename
239
- *
240
- * @public exported from `@promptbook/core`
241
- */
242
- var MAX_FILENAME_LENGTH = 30;
243
230
  /**
244
231
  * Strategy for caching the intermediate results for knowledge sources
245
232
  *
@@ -259,15 +246,6 @@ var DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹‍♂️]
259
246
  * @public exported from `@promptbook/core`
260
247
  */
261
248
  var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹‍♂️]
262
- // <- TODO: [🕝] Make also `BOOKS_DIRNAME_ALTERNATIVES`
263
- /**
264
- * Where to store the temporary downloads
265
- *
266
- * Note: When the folder does not exist, it is created recursively
267
- *
268
- * @public exported from `@promptbook/core`
269
- */
270
- var DEFAULT_DOWNLOAD_CACHE_DIRNAME = './.promptbook/download-cache';
271
249
  /**
272
250
  * Where to store the scrape cache
273
251
  *
@@ -962,18 +940,24 @@ function getScraperIntermediateSource(source, options) {
962
940
  var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book.md`\n- INPUT PARAMETER `{availableModelNames}` List of available model names separated by comma (,)\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n\\`\\`\\`json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelRequirements}`\n"}],sourceFile:"./books/prepare-persona.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book.md",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book.md`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book.md"}];
963
941
 
964
942
  /**
965
- * Checks if value is valid email
943
+ * Function isValidJsonString will tell you if the string is valid JSON or not
966
944
  *
967
945
  * @public exported from `@promptbook/utils`
968
946
  */
969
- function isValidEmail(email) {
970
- if (typeof email !== 'string') {
971
- return false;
947
+ function isValidJsonString(value /* <- [👨‍⚖️] */) {
948
+ try {
949
+ JSON.parse(value);
950
+ return true;
972
951
  }
973
- if (email.split('\n').length > 1) {
952
+ catch (error) {
953
+ if (!(error instanceof Error)) {
954
+ throw error;
955
+ }
956
+ if (error.message.includes('Unexpected token')) {
957
+ return false;
958
+ }
974
959
  return false;
975
960
  }
976
- return /^.+@.+\..+$/.test(email);
977
961
  }
978
962
 
979
963
  /**
@@ -995,27 +979,6 @@ var ParseError = /** @class */ (function (_super) {
995
979
  * TODO: Maybe split `ParseError` and `ApplyError`
996
980
  */
997
981
 
998
- /**
999
- * Function isValidJsonString will tell you if the string is valid JSON or not
1000
- *
1001
- * @public exported from `@promptbook/utils`
1002
- */
1003
- function isValidJsonString(value /* <- [👨‍⚖️] */) {
1004
- try {
1005
- JSON.parse(value);
1006
- return true;
1007
- }
1008
- catch (error) {
1009
- if (!(error instanceof Error)) {
1010
- throw error;
1011
- }
1012
- if (error.message.includes('Unexpected token')) {
1013
- return false;
1014
- }
1015
- return false;
1016
- }
1017
- }
1018
-
1019
982
  /**
1020
983
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
1021
984
  * 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.
@@ -1029,15 +992,6 @@ function validatePipelineString(pipelineString) {
1029
992
  if (isValidJsonString(pipelineString)) {
1030
993
  throw new ParseError('Expected a book, but got a JSON string');
1031
994
  }
1032
- else if (isValidUrl(pipelineString)) {
1033
- throw new ParseError("Expected a book, but got just the URL \"".concat(pipelineString, "\""));
1034
- }
1035
- else if (isValidFilePath(pipelineString)) {
1036
- throw new ParseError("Expected a book, but got just the file path \"".concat(pipelineString, "\""));
1037
- }
1038
- else if (isValidEmail(pipelineString)) {
1039
- throw new ParseError("Expected a book, but got just the email \"".concat(pipelineString, "\""));
1040
- }
1041
995
  // <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
1042
996
  return pipelineString;
1043
997
  }
@@ -2419,28 +2373,12 @@ function deserializeError(error) {
2419
2373
  /**
2420
2374
  * Asserts that the execution of a Promptbook is successful
2421
2375
  *
2422
- * Note: If there are only warnings, the execution is still successful but the warnings are logged in the console
2423
- *
2424
2376
  * @param executionResult - The partial result of the Promptbook execution
2425
2377
  * @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
2426
2378
  * @public exported from `@promptbook/core`
2427
2379
  */
2428
2380
  function assertsExecutionSuccessful(executionResult) {
2429
- var e_1, _a;
2430
- var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors, warnings = executionResult.warnings;
2431
- try {
2432
- for (var warnings_1 = __values(warnings), warnings_1_1 = warnings_1.next(); !warnings_1_1.done; warnings_1_1 = warnings_1.next()) {
2433
- var warning = warnings_1_1.value;
2434
- console.warn(warning.message);
2435
- }
2436
- }
2437
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2438
- finally {
2439
- try {
2440
- if (warnings_1_1 && !warnings_1_1.done && (_a = warnings_1.return)) _a.call(warnings_1);
2441
- }
2442
- finally { if (e_1) throw e_1.error; }
2443
- }
2381
+ var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
2444
2382
  if (isSuccessful === true) {
2445
2383
  return;
2446
2384
  }
@@ -3077,7 +3015,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
3077
3015
  if (!(error_1 instanceof Error) || error_1 instanceof UnexpectedError) {
3078
3016
  throw error_1;
3079
3017
  }
3080
- errors.push({ llmExecutionTools: llmExecutionTools, error: error_1 });
3018
+ errors.push(error_1);
3081
3019
  return [3 /*break*/, 13];
3082
3020
  case 13:
3083
3021
  _b = _a.next();
@@ -3104,10 +3042,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
3104
3042
  // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
3105
3043
  // 3) ...
3106
3044
  spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
3107
- .map(function (_a, i) {
3108
- var error = _a.error, llmExecutionTools = _a.llmExecutionTools;
3109
- return "".concat(i + 1, ") **").concat(llmExecutionTools.title, "** thrown **").concat(error.name || 'Error', ":** ").concat(error.message);
3110
- })
3045
+ .map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
3111
3046
  .join('\n')), "\n\n "); }));
3112
3047
  }
3113
3048
  else if (this.llmExecutionTools.length === 0) {
@@ -3589,17 +3524,6 @@ function getFileExtension(value) {
3589
3524
  return match ? match[1].toLowerCase() : null;
3590
3525
  }
3591
3526
 
3592
- /**
3593
- * Convert mime type to file extension
3594
- *
3595
- * Note: If the mime type is invalid, `null` is returned
3596
- *
3597
- * @private within the repository
3598
- */
3599
- function mimeTypeToExtension(value) {
3600
- return extension(value) || null;
3601
- }
3602
-
3603
3527
  /**
3604
3528
  * The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
3605
3529
  *
@@ -3635,9 +3559,9 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
3635
3559
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3636
3560
  var _a;
3637
3561
  return __awaiter(this, void 0, void 0, function () {
3638
- var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, fileContent, _f, _g, filename_1, fileExtension, mimeType;
3639
- return __generator(this, function (_h) {
3640
- switch (_h.label) {
3562
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3563
+ return __generator(this, function (_f) {
3564
+ switch (_f.label) {
3641
3565
  case 0:
3642
3566
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
3643
3567
  knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
@@ -3646,76 +3570,54 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3646
3570
  if (!name) {
3647
3571
  name = knowledgeSourceContentToName(knowledgeSourceContent);
3648
3572
  }
3649
- if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 5];
3573
+ if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
3650
3574
  url = knowledgeSourceContent;
3651
3575
  return [4 /*yield*/, fetch(url)];
3652
3576
  case 1:
3653
- response_1 = _h.sent();
3577
+ response_1 = _f.sent();
3654
3578
  mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
3655
- if (tools.fs === undefined || !url.endsWith('.pdf' /* <- TODO: [💵] */)) {
3656
- return [2 /*return*/, {
3657
- source: name,
3658
- filename: null,
3659
- url: url,
3660
- mimeType: mimeType,
3661
- /*
3662
- TODO: [🥽]
3663
- > async asBlob() {
3664
- > // TODO: [👨🏻‍🤝‍👨🏻] This can be called multiple times BUT when called second time, response in already consumed
3665
- > const content = await response.blob();
3666
- > return content;
3667
- > },
3668
- */
3669
- asJson: function () {
3670
- return __awaiter(this, void 0, void 0, function () {
3671
- var content;
3672
- return __generator(this, function (_a) {
3673
- switch (_a.label) {
3674
- case 0: return [4 /*yield*/, response_1.json()];
3675
- case 1:
3676
- content = _a.sent();
3677
- return [2 /*return*/, content];
3678
- }
3679
- });
3579
+ return [2 /*return*/, {
3580
+ source: name,
3581
+ filename: null,
3582
+ url: url,
3583
+ mimeType: mimeType,
3584
+ /*
3585
+ TODO: [🥽]
3586
+ > async asBlob() {
3587
+ > // TODO: [👨🏻‍🤝‍👨🏻] This can be called multiple times BUT when called second time, response in already consumed
3588
+ > const content = await response.blob();
3589
+ > return content;
3590
+ > },
3591
+ */
3592
+ asJson: function () {
3593
+ return __awaiter(this, void 0, void 0, function () {
3594
+ var content;
3595
+ return __generator(this, function (_a) {
3596
+ switch (_a.label) {
3597
+ case 0: return [4 /*yield*/, response_1.json()];
3598
+ case 1:
3599
+ content = _a.sent();
3600
+ return [2 /*return*/, content];
3601
+ }
3680
3602
  });
3681
- },
3682
- asText: function () {
3683
- return __awaiter(this, void 0, void 0, function () {
3684
- var content;
3685
- return __generator(this, function (_a) {
3686
- switch (_a.label) {
3687
- case 0: return [4 /*yield*/, response_1.text()];
3688
- case 1:
3689
- content = _a.sent();
3690
- return [2 /*return*/, content];
3691
- }
3692
- });
3603
+ });
3604
+ },
3605
+ asText: function () {
3606
+ return __awaiter(this, void 0, void 0, function () {
3607
+ var content;
3608
+ return __generator(this, function (_a) {
3609
+ switch (_a.label) {
3610
+ case 0: return [4 /*yield*/, response_1.text()];
3611
+ case 1:
3612
+ content = _a.sent();
3613
+ return [2 /*return*/, content];
3614
+ }
3693
3615
  });
3694
- },
3695
- }];
3696
- }
3697
- basename = url.split('/').pop() || titleToName(url);
3698
- hash = sha256(hexEncoder.parse(url)).toString( /* hex */);
3699
- rootDirname_1 = join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
3700
- 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));
3701
- return [4 /*yield*/, tools.fs.mkdir(dirname(join(rootDirname_1, filepath)), { recursive: true })];
3616
+ });
3617
+ },
3618
+ }];
3702
3619
  case 2:
3703
- _h.sent();
3704
- _g = (_f = Buffer).from;
3705
- return [4 /*yield*/, response_1.arrayBuffer()];
3706
- case 3:
3707
- fileContent = _g.apply(_f, [_h.sent()]);
3708
- if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
3709
- 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."));
3710
- }
3711
- return [4 /*yield*/, tools.fs.writeFile(join(rootDirname_1, filepath), fileContent)];
3712
- case 4:
3713
- _h.sent();
3714
- // TODO: [💵] Check the file security
3715
- // TODO: [🧹][🧠] Delete the file after the scraping is done
3716
- return [2 /*return*/, makeKnowledgeSourceHandler({ name: name, knowledgeSourceContent: filepath }, tools, __assign(__assign({}, options), { rootDirname: rootDirname_1 }))];
3717
- case 5:
3718
- if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 7];
3620
+ if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
3719
3621
  if (tools.fs === undefined) {
3720
3622
  throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
3721
3623
  // <- TODO: [🧠] What is the best error type here`
@@ -3728,8 +3630,8 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3728
3630
  fileExtension = getFileExtension(filename_1);
3729
3631
  mimeType = extensionToMimeType(fileExtension || '');
3730
3632
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
3731
- case 6:
3732
- if (!(_h.sent())) {
3633
+ case 3:
3634
+ if (!(_f.sent())) {
3733
3635
  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 "); }));
3734
3636
  }
3735
3637
  // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
@@ -3775,7 +3677,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3775
3677
  });
3776
3678
  },
3777
3679
  }];
3778
- case 7: return [2 /*return*/, {
3680
+ case 4: return [2 /*return*/, {
3779
3681
  source: name,
3780
3682
  filename: null,
3781
3683
  url: null,
@@ -6331,7 +6233,7 @@ var markitdownScraperMetadata = $deepFreeze({
6331
6233
  className: 'MarkitdownScraper',
6332
6234
  mimeTypes: [
6333
6235
  'application/pdf',
6334
- // TODO: [💵] Make priority for scrapers and than analyze which mime-types can Markitdown scrape and allow all mime types here:
6236
+ // TODO: Make priority for scrapers and than allow all mime types here:
6335
6237
  // 'text/html',
6336
6238
  // 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
6337
6239
  ],
@@ -6367,10 +6269,10 @@ var MarkitdownScraper = /** @class */ (function () {
6367
6269
  this.tools = tools;
6368
6270
  this.options = options;
6369
6271
  this.markdownScraper = new MarkdownScraper(tools, options);
6370
- // Note: Module `markitdown-ts` has no types available, so it is imported using `require`
6371
6272
  // eslint-disable-next-line @typescript-eslint/no-var-requires
6372
6273
  var MarkItDown = require('markitdown-ts').MarkItDown;
6373
- // <- TODO: [🍀] Use Markitdown directly not through this package
6274
+ // <- TODO: !!! Use Markitdown directly not through this package
6275
+ // <- Note: !!!!!!!
6374
6276
  this.markitdown = new MarkItDown();
6375
6277
  }
6376
6278
  Object.defineProperty(MarkitdownScraper.prototype, "metadata", {
@@ -6415,12 +6317,12 @@ var MarkitdownScraper = /** @class */ (function () {
6415
6317
  case 2:
6416
6318
  if (!!(_f.sent())) return [3 /*break*/, 5];
6417
6319
  src = source.filename || source.url || null;
6418
- // console.log('!!', { src, source, cacheFilehandler });
6320
+ console.log('!!!', { src: src, source: source, cacheFilehandler: cacheFilehandler });
6419
6321
  if (src === null) {
6420
6322
  throw new UnexpectedError('Source has no filename or url');
6421
6323
  }
6422
6324
  return [4 /*yield*/, this.markitdown.convert(src, {
6423
- // TODO: Pass when sacraping Youtube
6325
+ // TODO: !!!!!! Pass when sacraping Youtube
6424
6326
  // enableYoutubeTranscript: true,
6425
6327
  // youtubeTranscriptLanguage: 'en',
6426
6328
  })];
@@ -6428,12 +6330,11 @@ var MarkitdownScraper = /** @class */ (function () {
6428
6330
  result = _f.sent();
6429
6331
  if (result === null || result === undefined) {
6430
6332
  throw new Error("Markitdown could not convert the \"".concat(source.source, "\""));
6431
- // <- TODO: [🍀] Make MarkitdownError
6333
+ // <- TODO: !!! Make MarkitdownError
6432
6334
  }
6433
- // console.log('!!', { result, cacheFilehandler });
6335
+ console.log('!!!', { result: result, cacheFilehandler: cacheFilehandler });
6434
6336
  return [4 /*yield*/, this.tools.fs.writeFile(cacheFilehandler.filename, result.text_content)];
6435
6337
  case 4:
6436
- // console.log('!!', { result, cacheFilehandler });
6437
6338
  _f.sent();
6438
6339
  _f.label = 5;
6439
6340
  case 5: return [2 /*return*/, cacheFilehandler];