@promptbook/core 0.80.0 → 0.81.0-6
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 +6 -0
- package/esm/index.es.js +158 -210
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +15 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -6
- package/esm/typings/src/_packages/editable.index.d.ts +10 -0
- package/esm/typings/src/_packages/templates.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +4 -0
- package/esm/typings/src/_packages/utils.index.d.ts +10 -2
- package/esm/typings/src/config.d.ts +26 -0
- package/esm/typings/src/execution/ExecutionTools.d.ts +7 -0
- package/esm/typings/src/execution/PromptbookFetch.d.ts +5 -0
- package/esm/typings/src/execution/PromptbookFetch.test-type.d.ts +5 -0
- package/esm/typings/src/expectations/drafts/isDomainNameFree.d.ts +2 -1
- package/esm/typings/src/expectations/drafts/isGithubNameFree.d.ts +2 -1
- package/esm/typings/src/high-level-abstractions/index.d.ts +10 -0
- package/esm/typings/src/other/templates/getBookTemplate.d.ts +12 -0
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +10 -0
- package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +10 -0
- package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/utils/scraperFetch.d.ts +7 -0
- package/esm/typings/src/utils/editable/types/PipelineEditableSerialized.d.ts +27 -0
- package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.d.ts +3 -3
- package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.d.ts +3 -3
- package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.d.ts +2 -2
- package/esm/typings/src/utils/parameters/numberToString.d.ts +7 -0
- package/esm/typings/src/utils/parameters/{replaceParameters.d.ts → templateParameters.d.ts} +6 -2
- package/esm/typings/src/utils/parameters/valueToString.d.ts +17 -0
- package/esm/typings/src/utils/parameters/valueToString.test.d.ts +1 -0
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +4 -0
- package/package.json +1 -2
- package/umd/index.umd.js +158 -212
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/utils/formatNumber.d.ts +0 -6
- /package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.test.d.ts +0 -0
- /package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.test.d.ts +0 -0
- /package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.test.d.ts +0 -0
- /package/esm/typings/src/utils/{formatNumber.test.d.ts → parameters/numberToString.test.d.ts} +0 -0
- /package/esm/typings/src/utils/parameters/{replaceParameters.test.d.ts → templateParameters.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
<blockquote style="color: #ff8811">
|
|
27
|
+
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
28
|
+
</blockquote>
|
|
29
|
+
|
|
26
30
|
## 📦 Package `@promptbook/core`
|
|
27
31
|
|
|
28
32
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
@@ -251,6 +255,8 @@ Or you can install them separately:
|
|
|
251
255
|
- **[@promptbook/documents](https://www.npmjs.com/package/@promptbook/documents)** - Read knowledge from documents like `.docx`, `.odt`,…
|
|
252
256
|
- **[@promptbook/legacy-documents](https://www.npmjs.com/package/@promptbook/legacy-documents)** - Read knowledge from legacy documents like `.doc`, `.rtf`,…
|
|
253
257
|
- **[@promptbook/website-crawler](https://www.npmjs.com/package/@promptbook/website-crawler)** - Crawl knowledge from the web
|
|
258
|
+
- **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API
|
|
259
|
+
- **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Usefull templates and examples of books which can be used as a starting point
|
|
254
260
|
- **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
|
|
255
261
|
- **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
|
|
256
262
|
|
package/esm/index.es.js
CHANGED
|
@@ -23,7 +23,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
23
23
|
*
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
26
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-5';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -509,6 +509,26 @@ var DEFAULT_TITLE = "Untitled";
|
|
|
509
509
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
510
510
|
*/
|
|
511
511
|
var LOOP_LIMIT = 1000;
|
|
512
|
+
/**
|
|
513
|
+
* Strings to represent various values in the context of parameter values
|
|
514
|
+
*
|
|
515
|
+
* @public exported from `@promptbook/utils`
|
|
516
|
+
*/
|
|
517
|
+
var VALUE_STRINGS = {
|
|
518
|
+
empty: '(nothing; empty string)',
|
|
519
|
+
null: '(no value; null)',
|
|
520
|
+
undefined: '(unknown value; undefined)',
|
|
521
|
+
nan: '(not a number; NaN)',
|
|
522
|
+
infinity: '(infinity; ∞)',
|
|
523
|
+
negativeInfinity: '(negative infinity; -∞)',
|
|
524
|
+
unserializable: '(unserializable value)',
|
|
525
|
+
};
|
|
526
|
+
/**
|
|
527
|
+
* Small number limit
|
|
528
|
+
*
|
|
529
|
+
* @public exported from `@promptbook/utils`
|
|
530
|
+
*/
|
|
531
|
+
var SMALL_NUMBER = 0.001;
|
|
512
532
|
/**
|
|
513
533
|
* Short time interval to prevent race conditions in milliseconds
|
|
514
534
|
*
|
|
@@ -638,6 +658,12 @@ function SET_IS_VERBOSE(isVerbose) {
|
|
|
638
658
|
* @public exported from `@promptbook/core`
|
|
639
659
|
*/
|
|
640
660
|
var DEFAULT_IS_AUTO_INSTALLED = false;
|
|
661
|
+
/**
|
|
662
|
+
* Function name for generated function via `ptbk make` to get the pipeline collection
|
|
663
|
+
*
|
|
664
|
+
* @public exported from `@promptbook/core`
|
|
665
|
+
*/
|
|
666
|
+
var DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = "getPipelineCollection";
|
|
641
667
|
/**
|
|
642
668
|
* @@@
|
|
643
669
|
*
|
|
@@ -924,6 +950,7 @@ function exportJson(options) {
|
|
|
924
950
|
* @public exported from `@promptbook/core`
|
|
925
951
|
*/
|
|
926
952
|
var ORDER_OF_PIPELINE_JSON = [
|
|
953
|
+
// Note: [🍙] In this order will be pipeline serialized
|
|
927
954
|
'title',
|
|
928
955
|
'pipelineUrl',
|
|
929
956
|
'bookVersion',
|
|
@@ -935,6 +962,7 @@ var ORDER_OF_PIPELINE_JSON = [
|
|
|
935
962
|
'preparations',
|
|
936
963
|
'knowledgeSources',
|
|
937
964
|
'knowledgePieces',
|
|
965
|
+
'sources', // <- TODO: [🧠] Where should the `sources` be
|
|
938
966
|
];
|
|
939
967
|
/**
|
|
940
968
|
* Nonce which is used for replacing things in strings
|
|
@@ -2464,7 +2492,7 @@ function joinLlmExecutionTools() {
|
|
|
2464
2492
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2465
2493
|
*/
|
|
2466
2494
|
|
|
2467
|
-
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:[],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:[],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare 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- Title should be concise and clear\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:[],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",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:[],sourceFile:"./books/prepare-persona.book.md"}];
|
|
2495
|
+
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 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- Title should be concise and clear\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 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- Title should be concise and clear\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 Keywords",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 Keywords\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"}];
|
|
2468
2496
|
|
|
2469
2497
|
/**
|
|
2470
2498
|
* This error indicates problems parsing the format value
|
|
@@ -3443,16 +3471,94 @@ function arrayableToArray(input) {
|
|
|
3443
3471
|
return [input];
|
|
3444
3472
|
}
|
|
3445
3473
|
|
|
3474
|
+
/**
|
|
3475
|
+
* Format either small or big number
|
|
3476
|
+
*
|
|
3477
|
+
* @public exported from `@promptbook/utils`
|
|
3478
|
+
*/
|
|
3479
|
+
function numberToString(value) {
|
|
3480
|
+
if (value === 0) {
|
|
3481
|
+
return '0';
|
|
3482
|
+
}
|
|
3483
|
+
else if (Number.isNaN(value)) {
|
|
3484
|
+
return VALUE_STRINGS.nan;
|
|
3485
|
+
}
|
|
3486
|
+
else if (value === Infinity) {
|
|
3487
|
+
return VALUE_STRINGS.infinity;
|
|
3488
|
+
}
|
|
3489
|
+
else if (value === -Infinity) {
|
|
3490
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
3491
|
+
}
|
|
3492
|
+
for (var exponent = 0; exponent < 15; exponent++) {
|
|
3493
|
+
var factor = Math.pow(10, exponent);
|
|
3494
|
+
var valueRounded = Math.round(value * factor) / factor;
|
|
3495
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
3496
|
+
return valueRounded.toFixed(exponent);
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
return value.toString();
|
|
3500
|
+
}
|
|
3501
|
+
|
|
3502
|
+
/**
|
|
3503
|
+
* Function `valueToString` will convert the given value to string
|
|
3504
|
+
* This is useful and used in the `templateParameters` function
|
|
3505
|
+
*
|
|
3506
|
+
* Note: This function is not just calling `toString` method
|
|
3507
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
3508
|
+
* See `VALUE_STRINGS`
|
|
3509
|
+
*
|
|
3510
|
+
* Note: There are 2 similar functions
|
|
3511
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
3512
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
3513
|
+
*
|
|
3514
|
+
* @public exported from `@promptbook/utils`
|
|
3515
|
+
*/
|
|
3516
|
+
function valueToString(value) {
|
|
3517
|
+
try {
|
|
3518
|
+
if (value === '') {
|
|
3519
|
+
return VALUE_STRINGS.empty;
|
|
3520
|
+
}
|
|
3521
|
+
else if (value === null) {
|
|
3522
|
+
return VALUE_STRINGS.null;
|
|
3523
|
+
}
|
|
3524
|
+
else if (value === undefined) {
|
|
3525
|
+
return VALUE_STRINGS.undefined;
|
|
3526
|
+
}
|
|
3527
|
+
else if (typeof value === 'string') {
|
|
3528
|
+
return value;
|
|
3529
|
+
}
|
|
3530
|
+
else if (typeof value === 'number') {
|
|
3531
|
+
return numberToString(value);
|
|
3532
|
+
}
|
|
3533
|
+
else if (value instanceof Date) {
|
|
3534
|
+
return value.toISOString();
|
|
3535
|
+
}
|
|
3536
|
+
else {
|
|
3537
|
+
return JSON.stringify(value);
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
catch (error) {
|
|
3541
|
+
if (!(error instanceof Error)) {
|
|
3542
|
+
throw error;
|
|
3543
|
+
}
|
|
3544
|
+
console.error(error);
|
|
3545
|
+
return VALUE_STRINGS.unserializable;
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
|
|
3446
3549
|
/**
|
|
3447
3550
|
* Replaces parameters in template with values from parameters object
|
|
3448
3551
|
*
|
|
3552
|
+
* Note: This function is not places strings into string,
|
|
3553
|
+
* It's more complex and can handle this operation specifically for LLM models
|
|
3554
|
+
*
|
|
3449
3555
|
* @param template the template with parameters in {curly} braces
|
|
3450
3556
|
* @param parameters the object with parameters
|
|
3451
3557
|
* @returns the template with replaced parameters
|
|
3452
3558
|
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
3453
3559
|
* @public exported from `@promptbook/utils`
|
|
3454
3560
|
*/
|
|
3455
|
-
function
|
|
3561
|
+
function templateParameters(template, parameters) {
|
|
3456
3562
|
var e_1, _a;
|
|
3457
3563
|
try {
|
|
3458
3564
|
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -3478,7 +3584,7 @@ function replaceParameters(template, parameters) {
|
|
|
3478
3584
|
var loopLimit = LOOP_LIMIT;
|
|
3479
3585
|
var _loop_1 = function () {
|
|
3480
3586
|
if (loopLimit-- < 0) {
|
|
3481
|
-
throw new LimitReachedError('Loop limit reached during parameters replacement in `
|
|
3587
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `templateParameters`');
|
|
3482
3588
|
}
|
|
3483
3589
|
var precol = match.groups.precol;
|
|
3484
3590
|
var parameterName = match.groups.parameterName;
|
|
@@ -3495,7 +3601,7 @@ function replaceParameters(template, parameters) {
|
|
|
3495
3601
|
if (parameterValue === undefined) {
|
|
3496
3602
|
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
3497
3603
|
}
|
|
3498
|
-
parameterValue = parameterValue
|
|
3604
|
+
parameterValue = valueToString(parameterValue);
|
|
3499
3605
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
3500
3606
|
parameterValue = parameterValue
|
|
3501
3607
|
.split('\n')
|
|
@@ -4013,7 +4119,7 @@ function executeAttempts(options) {
|
|
|
4013
4119
|
}
|
|
4014
4120
|
return [3 /*break*/, 24];
|
|
4015
4121
|
case 2:
|
|
4016
|
-
$ongoingTaskResult.$resultString =
|
|
4122
|
+
$ongoingTaskResult.$resultString = templateParameters(preparedContent, parameters);
|
|
4017
4123
|
return [3 /*break*/, 25];
|
|
4018
4124
|
case 3:
|
|
4019
4125
|
modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
|
|
@@ -4136,8 +4242,8 @@ function executeAttempts(options) {
|
|
|
4136
4242
|
_j = $ongoingTaskResult;
|
|
4137
4243
|
return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
|
|
4138
4244
|
promptTitle: task.title,
|
|
4139
|
-
promptMessage:
|
|
4140
|
-
defaultValue:
|
|
4245
|
+
promptMessage: templateParameters(task.description || '', parameters),
|
|
4246
|
+
defaultValue: templateParameters(preparedContent, parameters),
|
|
4141
4247
|
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
4142
4248
|
placeholder: undefined,
|
|
4143
4249
|
priority: priority,
|
|
@@ -4261,7 +4367,7 @@ function executeAttempts(options) {
|
|
|
4261
4367
|
if (!isJokerAttempt &&
|
|
4262
4368
|
task.taskType === 'PROMPT_TASK' &&
|
|
4263
4369
|
$ongoingTaskResult.$prompt
|
|
4264
|
-
// <- Note: [2] When some expected parameter is not defined, error will occur in
|
|
4370
|
+
// <- Note: [2] When some expected parameter is not defined, error will occur in templateParameters
|
|
4265
4371
|
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
4266
4372
|
) {
|
|
4267
4373
|
// TODO: [🧠] Maybe put other taskTypes into report
|
|
@@ -5594,6 +5700,30 @@ function isValidFilePath(filename) {
|
|
|
5594
5700
|
return false;
|
|
5595
5701
|
}
|
|
5596
5702
|
|
|
5703
|
+
/**
|
|
5704
|
+
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
5705
|
+
*
|
|
5706
|
+
* @private as default `fetch` function used in Promptbook scrapers
|
|
5707
|
+
*/
|
|
5708
|
+
var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
5709
|
+
var error_1;
|
|
5710
|
+
return __generator(this, function (_a) {
|
|
5711
|
+
switch (_a.label) {
|
|
5712
|
+
case 0:
|
|
5713
|
+
_a.trys.push([0, 2, , 3]);
|
|
5714
|
+
return [4 /*yield*/, fetch(url, init)];
|
|
5715
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5716
|
+
case 2:
|
|
5717
|
+
error_1 = _a.sent();
|
|
5718
|
+
if (!(error_1 instanceof Error)) {
|
|
5719
|
+
throw error_1;
|
|
5720
|
+
}
|
|
5721
|
+
throw new KnowledgeScrapeError(spaceTrim(function (block) { return "\n Can not fetch \"".concat(url, "\"\n\n Fetch error:\n ").concat(block(error_1.message), "\n\n "); }));
|
|
5722
|
+
case 3: return [2 /*return*/];
|
|
5723
|
+
}
|
|
5724
|
+
});
|
|
5725
|
+
}); };
|
|
5726
|
+
|
|
5597
5727
|
/**
|
|
5598
5728
|
* @@@
|
|
5599
5729
|
*
|
|
@@ -5602,13 +5732,14 @@ function isValidFilePath(filename) {
|
|
|
5602
5732
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
5603
5733
|
var _a;
|
|
5604
5734
|
return __awaiter(this, void 0, void 0, function () {
|
|
5605
|
-
var sourceContent, name,
|
|
5606
|
-
return __generator(this, function (
|
|
5607
|
-
switch (
|
|
5735
|
+
var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
5736
|
+
return __generator(this, function (_f) {
|
|
5737
|
+
switch (_f.label) {
|
|
5608
5738
|
case 0:
|
|
5739
|
+
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
5609
5740
|
sourceContent = knowledgeSource.sourceContent;
|
|
5610
5741
|
name = knowledgeSource.name;
|
|
5611
|
-
|
|
5742
|
+
_c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
|
|
5612
5743
|
if (!name) {
|
|
5613
5744
|
name = sourceContentToName(sourceContent);
|
|
5614
5745
|
}
|
|
@@ -5616,7 +5747,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5616
5747
|
url = sourceContent;
|
|
5617
5748
|
return [4 /*yield*/, fetch(url)];
|
|
5618
5749
|
case 1:
|
|
5619
|
-
response_1 =
|
|
5750
|
+
response_1 = _f.sent();
|
|
5620
5751
|
mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
|
|
5621
5752
|
return [2 /*return*/, {
|
|
5622
5753
|
source: name,
|
|
@@ -5673,7 +5804,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5673
5804
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
5674
5805
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
5675
5806
|
case 3:
|
|
5676
|
-
if (!(
|
|
5807
|
+
if (!(_f.sent())) {
|
|
5677
5808
|
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(filename_1), "\n "); }));
|
|
5678
5809
|
}
|
|
5679
5810
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
@@ -8976,6 +9107,14 @@ function precompilePipeline(pipelineString) {
|
|
|
8976
9107
|
knowledgePieces: [],
|
|
8977
9108
|
personas: [],
|
|
8978
9109
|
preparations: [],
|
|
9110
|
+
sources: [
|
|
9111
|
+
{
|
|
9112
|
+
type: 'BOOK',
|
|
9113
|
+
path: null,
|
|
9114
|
+
// <- TODO: !!!!!! Pass here path of the file
|
|
9115
|
+
content: pipelineString,
|
|
9116
|
+
},
|
|
9117
|
+
],
|
|
8979
9118
|
};
|
|
8980
9119
|
function getPipelineIdentification() {
|
|
8981
9120
|
// Note: This is a 😐 implementation of [🚞]
|
|
@@ -9383,7 +9522,6 @@ function precompilePipeline(pipelineString) {
|
|
|
9383
9522
|
$pipelineJson.formfactorName = 'GENERIC';
|
|
9384
9523
|
}
|
|
9385
9524
|
// =============================================================
|
|
9386
|
-
// TODO: [🍙] Maybe do reorder of `$pipelineJson` here
|
|
9387
9525
|
return exportJson({
|
|
9388
9526
|
name: 'pipelineJson',
|
|
9389
9527
|
message: "Result of `precompilePipeline`",
|
|
@@ -9581,176 +9719,6 @@ function prettifyPipelineString(pipelineString, options) {
|
|
|
9581
9719
|
* TODO: [🕌] When more than 2 functionalities, split into separate functions
|
|
9582
9720
|
*/
|
|
9583
9721
|
|
|
9584
|
-
/**
|
|
9585
|
-
* Function `removePipelineCommand` will remove one command from pipeline string
|
|
9586
|
-
*
|
|
9587
|
-
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
9588
|
-
*/
|
|
9589
|
-
function removePipelineCommand(options) {
|
|
9590
|
-
var e_1, _a;
|
|
9591
|
-
var command = options.command, pipeline = options.pipeline;
|
|
9592
|
-
var lines = pipeline.split('\n');
|
|
9593
|
-
// TODO: [🧽] DRY
|
|
9594
|
-
var currentType = 'MARKDOWN';
|
|
9595
|
-
var newLines = [];
|
|
9596
|
-
try {
|
|
9597
|
-
for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
|
|
9598
|
-
var line = lines_1_1.value;
|
|
9599
|
-
if (currentType === 'MARKDOWN') {
|
|
9600
|
-
if (line.startsWith('```')) {
|
|
9601
|
-
currentType = 'CODE_BLOCK';
|
|
9602
|
-
}
|
|
9603
|
-
else if (line.includes('<!--')) {
|
|
9604
|
-
currentType = 'COMMENT';
|
|
9605
|
-
}
|
|
9606
|
-
}
|
|
9607
|
-
else if (currentType === 'CODE_BLOCK') {
|
|
9608
|
-
if (line.startsWith('```')) {
|
|
9609
|
-
currentType = 'MARKDOWN';
|
|
9610
|
-
}
|
|
9611
|
-
}
|
|
9612
|
-
else if (currentType === 'COMMENT') {
|
|
9613
|
-
if (line.includes('-->')) {
|
|
9614
|
-
currentType = 'MARKDOWN';
|
|
9615
|
-
}
|
|
9616
|
-
}
|
|
9617
|
-
if (currentType === 'MARKDOWN' && /^(-|\d\))/m.test(line) && line.toUpperCase().includes(command)) {
|
|
9618
|
-
continue;
|
|
9619
|
-
}
|
|
9620
|
-
newLines.push(line);
|
|
9621
|
-
}
|
|
9622
|
-
}
|
|
9623
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
9624
|
-
finally {
|
|
9625
|
-
try {
|
|
9626
|
-
if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
|
|
9627
|
-
}
|
|
9628
|
-
finally { if (e_1) throw e_1.error; }
|
|
9629
|
-
}
|
|
9630
|
-
var newPipeline = spaceTrim(newLines.join('\n'));
|
|
9631
|
-
return newPipeline;
|
|
9632
|
-
}
|
|
9633
|
-
|
|
9634
|
-
/**
|
|
9635
|
-
* Function `renamePipelineParameter` will find all usable parameters for given task
|
|
9636
|
-
* In other words, it will find all parameters that are not used in the task itseld and all its dependencies
|
|
9637
|
-
*
|
|
9638
|
-
* @throws {PipelineLogicError} If the new parameter name is already used in the pipeline
|
|
9639
|
-
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
9640
|
-
*/
|
|
9641
|
-
function renamePipelineParameter(options) {
|
|
9642
|
-
var e_1, _a, e_2, _b;
|
|
9643
|
-
var pipeline = options.pipeline, oldParameterName = options.oldParameterName, newParameterName = options.newParameterName;
|
|
9644
|
-
if (pipeline.parameters.some(function (parameter) { return parameter.name === newParameterName; })) {
|
|
9645
|
-
throw new PipelineLogicError("Can not replace {".concat(oldParameterName, "} to {").concat(newParameterName, "} because {").concat(newParameterName, "} is already used in the pipeline"));
|
|
9646
|
-
}
|
|
9647
|
-
var renamedPipeline = __assign(__assign({}, pipeline), {
|
|
9648
|
-
// <- TODO: [🪓] This should be without `as $PipelineJson`
|
|
9649
|
-
parameters: __spreadArray([], __read(pipeline.parameters), false), tasks: __spreadArray([], __read(pipeline.tasks), false) });
|
|
9650
|
-
try {
|
|
9651
|
-
for (var _c = __values(renamedPipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
9652
|
-
var parameter = _d.value;
|
|
9653
|
-
if (parameter.name !== oldParameterName) {
|
|
9654
|
-
continue;
|
|
9655
|
-
}
|
|
9656
|
-
parameter.name = newParameterName;
|
|
9657
|
-
}
|
|
9658
|
-
}
|
|
9659
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
9660
|
-
finally {
|
|
9661
|
-
try {
|
|
9662
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
9663
|
-
}
|
|
9664
|
-
finally { if (e_1) throw e_1.error; }
|
|
9665
|
-
}
|
|
9666
|
-
try {
|
|
9667
|
-
for (var _e = __values(renamedPipeline.tasks), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
9668
|
-
var task = _f.value;
|
|
9669
|
-
if (task.resultingParameterName === oldParameterName) {
|
|
9670
|
-
task.resultingParameterName = newParameterName;
|
|
9671
|
-
}
|
|
9672
|
-
task.dependentParameterNames = task.dependentParameterNames.map(function (dependentParameterName) {
|
|
9673
|
-
return dependentParameterName === oldParameterName ? newParameterName : dependentParameterName;
|
|
9674
|
-
});
|
|
9675
|
-
task.content = task.content.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
|
|
9676
|
-
task.title = task.title.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
|
|
9677
|
-
task.description =
|
|
9678
|
-
task.description === undefined
|
|
9679
|
-
? undefined
|
|
9680
|
-
: task.description.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
|
|
9681
|
-
}
|
|
9682
|
-
}
|
|
9683
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
9684
|
-
finally {
|
|
9685
|
-
try {
|
|
9686
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
9687
|
-
}
|
|
9688
|
-
finally { if (e_2) throw e_2.error; }
|
|
9689
|
-
}
|
|
9690
|
-
return renamedPipeline;
|
|
9691
|
-
}
|
|
9692
|
-
|
|
9693
|
-
// <- TODO: !!!!!!! Auto convert to type `import { ... } from 'type-fest';`
|
|
9694
|
-
/**
|
|
9695
|
-
* Tests if the value is [🚉] serializable as JSON
|
|
9696
|
-
*
|
|
9697
|
-
* - Almost all primitives are serializable BUT:
|
|
9698
|
-
* - `undefined` is not serializable
|
|
9699
|
-
* - `NaN` is not serializable
|
|
9700
|
-
* - Objects and arrays are serializable if all their properties are serializable
|
|
9701
|
-
* - Functions are not serializable
|
|
9702
|
-
* - Circular references are not serializable
|
|
9703
|
-
* - `Date` objects are not serializable
|
|
9704
|
-
* - `Map` and `Set` objects are not serializable
|
|
9705
|
-
* - `RegExp` objects are not serializable
|
|
9706
|
-
* - `Error` objects are not serializable
|
|
9707
|
-
* - `Symbol` objects are not serializable
|
|
9708
|
-
* - And much more...
|
|
9709
|
-
*
|
|
9710
|
-
*
|
|
9711
|
-
* @public exported from `@promptbook/utils`
|
|
9712
|
-
*/
|
|
9713
|
-
function isSerializableAsJson(value) {
|
|
9714
|
-
try {
|
|
9715
|
-
checkSerializableAsJson({ value: value });
|
|
9716
|
-
return true;
|
|
9717
|
-
}
|
|
9718
|
-
catch (error) {
|
|
9719
|
-
return false;
|
|
9720
|
-
}
|
|
9721
|
-
}
|
|
9722
|
-
/**
|
|
9723
|
-
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
9724
|
-
* TODO: [🧠][💺] Can be done this on type-level?
|
|
9725
|
-
*/
|
|
9726
|
-
|
|
9727
|
-
/**
|
|
9728
|
-
* Stringify the PipelineJson with proper formatting
|
|
9729
|
-
*
|
|
9730
|
-
* Note: [0] It can be used for more JSON types like whole collection of pipelines, single knowledge piece, etc.
|
|
9731
|
-
* Note: In contrast to JSON.stringify, this function ensures that **embedding index** is on single line
|
|
9732
|
-
*
|
|
9733
|
-
* @public exported from `@promptbook/core`
|
|
9734
|
-
*/
|
|
9735
|
-
function stringifyPipelineJson(pipeline) {
|
|
9736
|
-
if (!isSerializableAsJson(pipeline)) {
|
|
9737
|
-
throw new UnexpectedError(spaceTrim("\n Cannot stringify the pipeline, because it is not serializable as JSON\n\n There can be multiple reasons:\n 1) The pipeline contains circular references\n 2) It is not a valid PipelineJson\n "));
|
|
9738
|
-
}
|
|
9739
|
-
var pipelineJsonStringified = JSON.stringify(pipeline, null, 4);
|
|
9740
|
-
for (var i = 0; i < LOOP_LIMIT; i++) {
|
|
9741
|
-
pipelineJsonStringified = pipelineJsonStringified.replace(/(-?0\.\d+),[\n\s]+(-?0\.\d+)/gms, "$1".concat(REPLACING_NONCE, "$2"));
|
|
9742
|
-
}
|
|
9743
|
-
pipelineJsonStringified = pipelineJsonStringified.split(REPLACING_NONCE).join(', ');
|
|
9744
|
-
pipelineJsonStringified += '\n';
|
|
9745
|
-
return pipelineJsonStringified;
|
|
9746
|
-
}
|
|
9747
|
-
/**
|
|
9748
|
-
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.book.md
|
|
9749
|
-
* TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
|
|
9750
|
-
* TODO: [🧠] Maybe more elegant solution than replacing via regex
|
|
9751
|
-
* TODO: [🍙] Make some standard order of json properties
|
|
9752
|
-
*/
|
|
9753
|
-
|
|
9754
9722
|
/**
|
|
9755
9723
|
* Delagates the user interaction to a async callback function
|
|
9756
9724
|
* You need to provide your own implementation of this callback function and its bind to UI.
|
|
@@ -9812,26 +9780,6 @@ function embeddingVectorToString(embeddingVector) {
|
|
|
9812
9780
|
return "[EmbeddingVector; ".concat(embeddingVector.length, " dimensions; length: ").concat(vectorLength.toFixed(2), "; ").concat(embeddingVector.slice(0, 3).join(', '), "...]");
|
|
9813
9781
|
}
|
|
9814
9782
|
|
|
9815
|
-
/**
|
|
9816
|
-
* Format either small or big number
|
|
9817
|
-
*
|
|
9818
|
-
* @private within the repository
|
|
9819
|
-
*/
|
|
9820
|
-
function formatNumber(value) {
|
|
9821
|
-
if (value === 0) {
|
|
9822
|
-
return '0';
|
|
9823
|
-
}
|
|
9824
|
-
for (var exponent = 0; exponent < 15; exponent++) {
|
|
9825
|
-
var factor = Math.pow(10, exponent);
|
|
9826
|
-
var valueRounded = Math.round(value * factor) / factor;
|
|
9827
|
-
if (Math.abs(value - valueRounded) / value <
|
|
9828
|
-
0.001 /* <- TODO: Pass as option, pass to executionReportJsonToString as option */) {
|
|
9829
|
-
return valueRounded.toFixed(exponent);
|
|
9830
|
-
}
|
|
9831
|
-
}
|
|
9832
|
-
return value.toString();
|
|
9833
|
-
}
|
|
9834
|
-
|
|
9835
9783
|
/**
|
|
9836
9784
|
* Create a markdown table from a 2D array of strings
|
|
9837
9785
|
*
|
|
@@ -9891,7 +9839,7 @@ function createMarkdownChart(options) {
|
|
|
9891
9839
|
}
|
|
9892
9840
|
finally { if (e_1) throw e_1.error; }
|
|
9893
9841
|
}
|
|
9894
|
-
var legend = "_Note: Each \u2588 represents ".concat(
|
|
9842
|
+
var legend = "_Note: Each \u2588 represents ".concat(numberToString(1 / scale), " ").concat(unitName, ", width of ").concat(valueHeader.toLowerCase(), " is ").concat(numberToString(to - from), " ").concat(unitName, " = ").concat(width, " squares_");
|
|
9895
9843
|
return createMarkdownTable(table) + '\n\n' + legend;
|
|
9896
9844
|
}
|
|
9897
9845
|
/**
|
|
@@ -10010,7 +9958,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
10010
9958
|
headerList.push("COMPLETED AT ".concat(moment(completedAt).format("YYYY-MM-DD HH:mm:ss")));
|
|
10011
9959
|
headerList.push("TOTAL DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
|
|
10012
9960
|
headerList.push("TOTAL LLM DURATION ".concat(llmDuration.humanize(MOMENT_ARG_THRESHOLDS)));
|
|
10013
|
-
headerList.push("TOTAL COST $".concat(
|
|
9961
|
+
headerList.push("TOTAL COST $".concat(numberToString(cost * (1 + taxRate))) +
|
|
10014
9962
|
(executionsWithKnownCost.length === executionReportJson.promptExecutions.length
|
|
10015
9963
|
? ''
|
|
10016
9964
|
: " *(Some cost is unknown)*") +
|
|
@@ -10068,7 +10016,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
10068
10016
|
// > taskList.push(`STARTED AT ${moment(startedAt).calendar()}`);
|
|
10069
10017
|
taskList.push("DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
|
|
10070
10018
|
if (typeof ((_g = (_f = promptExecution.result) === null || _f === void 0 ? void 0 : _f.usage) === null || _g === void 0 ? void 0 : _g.price) === 'number') {
|
|
10071
|
-
taskList.push("COST $".concat(
|
|
10019
|
+
taskList.push("COST $".concat(numberToString(promptExecution.result.usage.price * (1 + taxRate))) +
|
|
10072
10020
|
(taxRate !== 0 ? " *(with tax ".concat(taxRate * 100, "%)*") : ''));
|
|
10073
10021
|
}
|
|
10074
10022
|
else {
|
|
@@ -11130,5 +11078,5 @@ var PrefixStorage = /** @class */ (function () {
|
|
|
11130
11078
|
return PrefixStorage;
|
|
11131
11079
|
}());
|
|
11132
11080
|
|
|
11133
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, KnowledgeScrapeError, LOGO_DARK_SRC, LOGO_LIGHT_SRC, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, compilePipeline, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, precompilePipeline, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString,
|
|
11081
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, KnowledgeScrapeError, LOGO_DARK_SRC, LOGO_LIGHT_SRC, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, compilePipeline, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, precompilePipeline, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
11134
11082
|
//# sourceMappingURL=index.es.js.map
|