@promptbook/node 0.80.0-1 → 0.81.0-11
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 +3 -0
- package/esm/index.es.js +180 -32
- 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 +6 -0
- package/esm/typings/src/_packages/utils.index.d.ts +10 -2
- package/esm/typings/src/_packages/wizzard.index.d.ts +44 -0
- package/esm/typings/src/config.d.ts +26 -0
- package/esm/typings/src/execution/ExecutionTools.d.ts +7 -0
- package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -2
- 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/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -2
- 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/llm-providers/_common/register/{$provideLlmToolsForCli.d.ts → $provideLlmToolsForWizzardOrCli.d.ts} +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +2 -0
- package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
- package/esm/typings/src/llm-providers/google/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/google/register-constructor.d.ts +1 -0
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +2 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +2 -0
- package/esm/typings/src/other/templates/getBookTemplate.d.ts +21 -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/scrapers/document/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -0
- package/esm/typings/src/types/typeAliases.d.ts +8 -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/esm/typings/src/version.d.ts +7 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +51 -0
- package/package.json +2 -2
- package/umd/index.umd.js +180 -32
- 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/umd/index.umd.js
CHANGED
|
@@ -35,15 +35,17 @@
|
|
|
35
35
|
/**
|
|
36
36
|
* The version of the Book language
|
|
37
37
|
*
|
|
38
|
+
* @generated
|
|
38
39
|
* @see https://github.com/webgptorg/book
|
|
39
40
|
*/
|
|
40
41
|
var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
41
42
|
/**
|
|
42
43
|
* The version of the Promptbook engine
|
|
43
44
|
*
|
|
45
|
+
* @generated
|
|
44
46
|
* @see https://github.com/webgptorg/promptbook
|
|
45
47
|
*/
|
|
46
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
48
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-10';
|
|
47
49
|
/**
|
|
48
50
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
49
51
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -221,6 +223,26 @@
|
|
|
221
223
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
222
224
|
*/
|
|
223
225
|
var LOOP_LIMIT = 1000;
|
|
226
|
+
/**
|
|
227
|
+
* Strings to represent various values in the context of parameter values
|
|
228
|
+
*
|
|
229
|
+
* @public exported from `@promptbook/utils`
|
|
230
|
+
*/
|
|
231
|
+
var VALUE_STRINGS = {
|
|
232
|
+
empty: '(nothing; empty string)',
|
|
233
|
+
null: '(no value; null)',
|
|
234
|
+
undefined: '(unknown value; undefined)',
|
|
235
|
+
nan: '(not a number; NaN)',
|
|
236
|
+
infinity: '(infinity; ∞)',
|
|
237
|
+
negativeInfinity: '(negative infinity; -∞)',
|
|
238
|
+
unserializable: '(unserializable value)',
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Small number limit
|
|
242
|
+
*
|
|
243
|
+
* @public exported from `@promptbook/utils`
|
|
244
|
+
*/
|
|
245
|
+
var SMALL_NUMBER = 0.001;
|
|
224
246
|
/**
|
|
225
247
|
* Short time interval to prevent race conditions in milliseconds
|
|
226
248
|
*
|
|
@@ -576,6 +598,7 @@
|
|
|
576
598
|
* @public exported from `@promptbook/core`
|
|
577
599
|
*/
|
|
578
600
|
var ORDER_OF_PIPELINE_JSON = [
|
|
601
|
+
// Note: [🍙] In this order will be pipeline serialized
|
|
579
602
|
'title',
|
|
580
603
|
'pipelineUrl',
|
|
581
604
|
'bookVersion',
|
|
@@ -587,6 +610,7 @@
|
|
|
587
610
|
'preparations',
|
|
588
611
|
'knowledgeSources',
|
|
589
612
|
'knowledgePieces',
|
|
613
|
+
'sources', // <- TODO: [🧠] Where should the `sources` be
|
|
590
614
|
];
|
|
591
615
|
/**
|
|
592
616
|
* Nonce which is used for replacing things in strings
|
|
@@ -1245,7 +1269,7 @@
|
|
|
1245
1269
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
1246
1270
|
*/
|
|
1247
1271
|
|
|
1248
|
-
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"}];
|
|
1272
|
+
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"}];
|
|
1249
1273
|
|
|
1250
1274
|
/**
|
|
1251
1275
|
* Prettify the html code
|
|
@@ -1670,9 +1694,6 @@
|
|
|
1670
1694
|
if (!url.startsWith('https://')) {
|
|
1671
1695
|
return false;
|
|
1672
1696
|
}
|
|
1673
|
-
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
|
|
1674
|
-
return false;
|
|
1675
|
-
}
|
|
1676
1697
|
if (url.includes('#')) {
|
|
1677
1698
|
// TODO: [🐠]
|
|
1678
1699
|
return false;
|
|
@@ -2434,6 +2455,81 @@
|
|
|
2434
2455
|
* - [♨] Are tasks prepared
|
|
2435
2456
|
*/
|
|
2436
2457
|
|
|
2458
|
+
/**
|
|
2459
|
+
* Format either small or big number
|
|
2460
|
+
*
|
|
2461
|
+
* @public exported from `@promptbook/utils`
|
|
2462
|
+
*/
|
|
2463
|
+
function numberToString(value) {
|
|
2464
|
+
if (value === 0) {
|
|
2465
|
+
return '0';
|
|
2466
|
+
}
|
|
2467
|
+
else if (Number.isNaN(value)) {
|
|
2468
|
+
return VALUE_STRINGS.nan;
|
|
2469
|
+
}
|
|
2470
|
+
else if (value === Infinity) {
|
|
2471
|
+
return VALUE_STRINGS.infinity;
|
|
2472
|
+
}
|
|
2473
|
+
else if (value === -Infinity) {
|
|
2474
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
2475
|
+
}
|
|
2476
|
+
for (var exponent = 0; exponent < 15; exponent++) {
|
|
2477
|
+
var factor = Math.pow(10, exponent);
|
|
2478
|
+
var valueRounded = Math.round(value * factor) / factor;
|
|
2479
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
2480
|
+
return valueRounded.toFixed(exponent);
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2483
|
+
return value.toString();
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
/**
|
|
2487
|
+
* Function `valueToString` will convert the given value to string
|
|
2488
|
+
* This is useful and used in the `templateParameters` function
|
|
2489
|
+
*
|
|
2490
|
+
* Note: This function is not just calling `toString` method
|
|
2491
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
2492
|
+
* See `VALUE_STRINGS`
|
|
2493
|
+
*
|
|
2494
|
+
* Note: There are 2 similar functions
|
|
2495
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
2496
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
2497
|
+
*
|
|
2498
|
+
* @public exported from `@promptbook/utils`
|
|
2499
|
+
*/
|
|
2500
|
+
function valueToString(value) {
|
|
2501
|
+
try {
|
|
2502
|
+
if (value === '') {
|
|
2503
|
+
return VALUE_STRINGS.empty;
|
|
2504
|
+
}
|
|
2505
|
+
else if (value === null) {
|
|
2506
|
+
return VALUE_STRINGS.null;
|
|
2507
|
+
}
|
|
2508
|
+
else if (value === undefined) {
|
|
2509
|
+
return VALUE_STRINGS.undefined;
|
|
2510
|
+
}
|
|
2511
|
+
else if (typeof value === 'string') {
|
|
2512
|
+
return value;
|
|
2513
|
+
}
|
|
2514
|
+
else if (typeof value === 'number') {
|
|
2515
|
+
return numberToString(value);
|
|
2516
|
+
}
|
|
2517
|
+
else if (value instanceof Date) {
|
|
2518
|
+
return value.toISOString();
|
|
2519
|
+
}
|
|
2520
|
+
else {
|
|
2521
|
+
return JSON.stringify(value);
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
catch (error) {
|
|
2525
|
+
if (!(error instanceof Error)) {
|
|
2526
|
+
throw error;
|
|
2527
|
+
}
|
|
2528
|
+
console.error(error);
|
|
2529
|
+
return VALUE_STRINGS.unserializable;
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2437
2533
|
/**
|
|
2438
2534
|
* Serializes an error into a [🚉] JSON-serializable object
|
|
2439
2535
|
*
|
|
@@ -3146,13 +3242,16 @@
|
|
|
3146
3242
|
/**
|
|
3147
3243
|
* Replaces parameters in template with values from parameters object
|
|
3148
3244
|
*
|
|
3245
|
+
* Note: This function is not places strings into string,
|
|
3246
|
+
* It's more complex and can handle this operation specifically for LLM models
|
|
3247
|
+
*
|
|
3149
3248
|
* @param template the template with parameters in {curly} braces
|
|
3150
3249
|
* @param parameters the object with parameters
|
|
3151
3250
|
* @returns the template with replaced parameters
|
|
3152
3251
|
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
3153
3252
|
* @public exported from `@promptbook/utils`
|
|
3154
3253
|
*/
|
|
3155
|
-
function
|
|
3254
|
+
function templateParameters(template, parameters) {
|
|
3156
3255
|
var e_1, _a;
|
|
3157
3256
|
try {
|
|
3158
3257
|
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -3178,7 +3277,7 @@
|
|
|
3178
3277
|
var loopLimit = LOOP_LIMIT;
|
|
3179
3278
|
var _loop_1 = function () {
|
|
3180
3279
|
if (loopLimit-- < 0) {
|
|
3181
|
-
throw new LimitReachedError('Loop limit reached during parameters replacement in `
|
|
3280
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `templateParameters`');
|
|
3182
3281
|
}
|
|
3183
3282
|
var precol = match.groups.precol;
|
|
3184
3283
|
var parameterName = match.groups.parameterName;
|
|
@@ -3195,7 +3294,7 @@
|
|
|
3195
3294
|
if (parameterValue === undefined) {
|
|
3196
3295
|
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
3197
3296
|
}
|
|
3198
|
-
parameterValue = parameterValue
|
|
3297
|
+
parameterValue = valueToString(parameterValue);
|
|
3199
3298
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
3200
3299
|
parameterValue = parameterValue
|
|
3201
3300
|
.split('\n')
|
|
@@ -3691,7 +3790,7 @@
|
|
|
3691
3790
|
}
|
|
3692
3791
|
return [3 /*break*/, 24];
|
|
3693
3792
|
case 2:
|
|
3694
|
-
$ongoingTaskResult.$resultString =
|
|
3793
|
+
$ongoingTaskResult.$resultString = templateParameters(preparedContent, parameters);
|
|
3695
3794
|
return [3 /*break*/, 25];
|
|
3696
3795
|
case 3:
|
|
3697
3796
|
modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
|
|
@@ -3814,8 +3913,8 @@
|
|
|
3814
3913
|
_j = $ongoingTaskResult;
|
|
3815
3914
|
return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
|
|
3816
3915
|
promptTitle: task.title,
|
|
3817
|
-
promptMessage:
|
|
3818
|
-
defaultValue:
|
|
3916
|
+
promptMessage: templateParameters(task.description || '', parameters),
|
|
3917
|
+
defaultValue: templateParameters(preparedContent, parameters),
|
|
3819
3918
|
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
3820
3919
|
placeholder: undefined,
|
|
3821
3920
|
priority: priority,
|
|
@@ -3939,7 +4038,7 @@
|
|
|
3939
4038
|
if (!isJokerAttempt &&
|
|
3940
4039
|
task.taskType === 'PROMPT_TASK' &&
|
|
3941
4040
|
$ongoingTaskResult.$prompt
|
|
3942
|
-
// <- Note: [2] When some expected parameter is not defined, error will occur in
|
|
4041
|
+
// <- Note: [2] When some expected parameter is not defined, error will occur in templateParameters
|
|
3943
4042
|
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
3944
4043
|
) {
|
|
3945
4044
|
// TODO: [🧠] Maybe put other taskTypes into report
|
|
@@ -4516,7 +4615,10 @@
|
|
|
4516
4615
|
finally { if (e_2) throw e_2.error; }
|
|
4517
4616
|
return [7 /*endfinally*/];
|
|
4518
4617
|
case 19:
|
|
4519
|
-
parametersToPass = inputParameters
|
|
4618
|
+
parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
|
|
4619
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
4620
|
+
return [key, valueToString(value)];
|
|
4621
|
+
}));
|
|
4520
4622
|
_g.label = 20;
|
|
4521
4623
|
case 20:
|
|
4522
4624
|
_g.trys.push([20, 25, , 28]);
|
|
@@ -5266,6 +5368,30 @@
|
|
|
5266
5368
|
return false;
|
|
5267
5369
|
}
|
|
5268
5370
|
|
|
5371
|
+
/**
|
|
5372
|
+
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
5373
|
+
*
|
|
5374
|
+
* @private as default `fetch` function used in Promptbook scrapers
|
|
5375
|
+
*/
|
|
5376
|
+
var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
5377
|
+
var error_1;
|
|
5378
|
+
return __generator(this, function (_a) {
|
|
5379
|
+
switch (_a.label) {
|
|
5380
|
+
case 0:
|
|
5381
|
+
_a.trys.push([0, 2, , 3]);
|
|
5382
|
+
return [4 /*yield*/, fetch(url, init)];
|
|
5383
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5384
|
+
case 2:
|
|
5385
|
+
error_1 = _a.sent();
|
|
5386
|
+
if (!(error_1 instanceof Error)) {
|
|
5387
|
+
throw error_1;
|
|
5388
|
+
}
|
|
5389
|
+
throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Can not fetch \"".concat(url, "\"\n\n Fetch error:\n ").concat(block(error_1.message), "\n\n "); }));
|
|
5390
|
+
case 3: return [2 /*return*/];
|
|
5391
|
+
}
|
|
5392
|
+
});
|
|
5393
|
+
}); };
|
|
5394
|
+
|
|
5269
5395
|
/**
|
|
5270
5396
|
* @@@
|
|
5271
5397
|
*
|
|
@@ -5274,13 +5400,14 @@
|
|
|
5274
5400
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
5275
5401
|
var _a;
|
|
5276
5402
|
return __awaiter(this, void 0, void 0, function () {
|
|
5277
|
-
var sourceContent, name,
|
|
5278
|
-
return __generator(this, function (
|
|
5279
|
-
switch (
|
|
5403
|
+
var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
5404
|
+
return __generator(this, function (_f) {
|
|
5405
|
+
switch (_f.label) {
|
|
5280
5406
|
case 0:
|
|
5407
|
+
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
5281
5408
|
sourceContent = knowledgeSource.sourceContent;
|
|
5282
5409
|
name = knowledgeSource.name;
|
|
5283
|
-
|
|
5410
|
+
_c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
|
|
5284
5411
|
if (!name) {
|
|
5285
5412
|
name = sourceContentToName(sourceContent);
|
|
5286
5413
|
}
|
|
@@ -5288,7 +5415,7 @@
|
|
|
5288
5415
|
url = sourceContent;
|
|
5289
5416
|
return [4 /*yield*/, fetch(url)];
|
|
5290
5417
|
case 1:
|
|
5291
|
-
response_1 =
|
|
5418
|
+
response_1 = _f.sent();
|
|
5292
5419
|
mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
|
|
5293
5420
|
return [2 /*return*/, {
|
|
5294
5421
|
source: name,
|
|
@@ -5345,7 +5472,7 @@
|
|
|
5345
5472
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
5346
5473
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
5347
5474
|
case 3:
|
|
5348
|
-
if (!(
|
|
5475
|
+
if (!(_f.sent())) {
|
|
5349
5476
|
throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
|
|
5350
5477
|
}
|
|
5351
5478
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
@@ -8648,6 +8775,14 @@
|
|
|
8648
8775
|
knowledgePieces: [],
|
|
8649
8776
|
personas: [],
|
|
8650
8777
|
preparations: [],
|
|
8778
|
+
sources: [
|
|
8779
|
+
{
|
|
8780
|
+
type: 'BOOK',
|
|
8781
|
+
path: null,
|
|
8782
|
+
// <- TODO: !!!!!! Pass here path of the file
|
|
8783
|
+
content: pipelineString,
|
|
8784
|
+
},
|
|
8785
|
+
],
|
|
8651
8786
|
};
|
|
8652
8787
|
function getPipelineIdentification() {
|
|
8653
8788
|
// Note: This is a 😐 implementation of [🚞]
|
|
@@ -8662,6 +8797,8 @@
|
|
|
8662
8797
|
}
|
|
8663
8798
|
// =============================================================
|
|
8664
8799
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
8800
|
+
// ==============
|
|
8801
|
+
// Note: 1️⃣◽1️⃣ Remove #!shebang and comments
|
|
8665
8802
|
if (pipelineString.startsWith('#!')) {
|
|
8666
8803
|
var _g = __read(pipelineString.split('\n')), shebangLine_1 = _g[0], restLines = _g.slice(1);
|
|
8667
8804
|
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
@@ -8670,10 +8807,21 @@
|
|
|
8670
8807
|
pipelineString = restLines.join('\n');
|
|
8671
8808
|
}
|
|
8672
8809
|
pipelineString = removeContentComments(pipelineString);
|
|
8810
|
+
// ==============
|
|
8811
|
+
// Note: 1️⃣◽2️⃣ Process flat pipeline
|
|
8812
|
+
// TODO: !!!!!!
|
|
8813
|
+
// const isMarkdownBeginningWithHeadline =
|
|
8814
|
+
// const isMarkdown
|
|
8815
|
+
// const isMarkdown
|
|
8816
|
+
// const isMarkdown
|
|
8817
|
+
// ==============
|
|
8818
|
+
// Note: 1️⃣◽3️⃣ Parse the markdown
|
|
8673
8819
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
8674
8820
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
8675
8821
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
8676
8822
|
var _h = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _h[0], pipelineSections = _h.slice(1); /* <- Note: [🥞] */
|
|
8823
|
+
// ==============
|
|
8824
|
+
// Note: 1️⃣◽4️⃣ Check markdown structure
|
|
8677
8825
|
if (pipelineHead === undefined) {
|
|
8678
8826
|
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
8679
8827
|
}
|
|
@@ -9055,7 +9203,6 @@
|
|
|
9055
9203
|
$pipelineJson.formfactorName = 'GENERIC';
|
|
9056
9204
|
}
|
|
9057
9205
|
// =============================================================
|
|
9058
|
-
// TODO: [🍙] Maybe do reorder of `$pipelineJson` here
|
|
9059
9206
|
return exportJson({
|
|
9060
9207
|
name: 'pipelineJson',
|
|
9061
9208
|
message: "Result of `precompilePipeline`",
|
|
@@ -9711,8 +9858,11 @@
|
|
|
9711
9858
|
}
|
|
9712
9859
|
var configuration = $provideLlmToolsConfigurationFromEnv();
|
|
9713
9860
|
if (configuration.length === 0) {
|
|
9861
|
+
if ($llmToolsMetadataRegister.list().length === 0) {
|
|
9862
|
+
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n No LLM tools registered, this is probably a bug in the Promptbook library\n\n ".concat(block($registeredLlmToolsMessage()), "}\n "); }));
|
|
9863
|
+
}
|
|
9714
9864
|
// TODO: [🥃]
|
|
9715
|
-
throw new Error(spaceTrim__default["default"](function (block) { return "\n No LLM tools found in the environment\n\n
|
|
9865
|
+
throw new Error(spaceTrim__default["default"](function (block) { return "\n No LLM tools found in the environment\n\n ".concat(block($registeredLlmToolsMessage()), "}\n "); }));
|
|
9716
9866
|
}
|
|
9717
9867
|
return createLlmToolsFromConfiguration(configuration, options);
|
|
9718
9868
|
}
|
|
@@ -10478,7 +10628,7 @@
|
|
|
10478
10628
|
*/
|
|
10479
10629
|
function createCollectionFromDirectory(path$1, tools, options) {
|
|
10480
10630
|
return __awaiter(this, void 0, void 0, function () {
|
|
10481
|
-
var
|
|
10631
|
+
var madeLibraryFilePath, _a, _b, isRecursive, _c, isVerbose, _d, isLazyLoaded, _e, isCrashedOnError, collection;
|
|
10482
10632
|
var _this = this;
|
|
10483
10633
|
return __generator(this, function (_f) {
|
|
10484
10634
|
switch (_f.label) {
|
|
@@ -10493,16 +10643,14 @@
|
|
|
10493
10643
|
throw new EnvironmentMismatchError('Can not create collection without filesystem tools');
|
|
10494
10644
|
// <- TODO: [🧠] What is the best error type here`
|
|
10495
10645
|
}
|
|
10496
|
-
|
|
10646
|
+
madeLibraryFilePath = path.join(path$1, "".concat(DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME
|
|
10497
10647
|
// <- TODO: [🦒] Allow to override (pass different value into the function)
|
|
10498
10648
|
, ".json"));
|
|
10499
|
-
return [4 /*yield*/, isFileExisting(
|
|
10649
|
+
return [4 /*yield*/, isFileExisting(madeLibraryFilePath, tools.fs)];
|
|
10500
10650
|
case 3:
|
|
10501
|
-
if (!(_f.sent()))
|
|
10502
|
-
console.info(colors__default["default"].yellow("Tip: Prebuild your pipeline collection (file with supposed prebuild ".concat(makedLibraryFilePath, " not found) with CLI util \"ptbk make\" to speed up the collection creation.")));
|
|
10503
|
-
}
|
|
10651
|
+
if (!(_f.sent())) ;
|
|
10504
10652
|
else {
|
|
10505
|
-
colors__default["default"].green("(In future, not implemented yet) Using your
|
|
10653
|
+
colors__default["default"].green("(In future, not implemented yet) Using your compiled pipeline collection ".concat(madeLibraryFilePath));
|
|
10506
10654
|
// TODO: !! Implement;
|
|
10507
10655
|
// TODO: [🌗]
|
|
10508
10656
|
}
|
|
@@ -10522,10 +10670,10 @@
|
|
|
10522
10670
|
// Note: First load all .book.json and then .book.md files
|
|
10523
10671
|
// .book.json can be prepared so it is faster to load
|
|
10524
10672
|
fileNames.sort(function (a, b) {
|
|
10525
|
-
if (a.endsWith('.
|
|
10673
|
+
if (a.endsWith('.json') && b.endsWith('.md')) {
|
|
10526
10674
|
return -1;
|
|
10527
10675
|
}
|
|
10528
|
-
if (a.endsWith('.
|
|
10676
|
+
if (a.endsWith('.md') && b.endsWith('.json')) {
|
|
10529
10677
|
return 1;
|
|
10530
10678
|
}
|
|
10531
10679
|
return 0;
|
|
@@ -10574,7 +10722,7 @@
|
|
|
10574
10722
|
// TODO: [👠] DRY
|
|
10575
10723
|
if (pipeline.pipelineUrl === undefined) {
|
|
10576
10724
|
if (isVerbose) {
|
|
10577
|
-
console.info(colors__default["default"].
|
|
10725
|
+
console.info(colors__default["default"].yellow("Can not load pipeline from ".concat(fileName
|
|
10578
10726
|
.split('\\')
|
|
10579
10727
|
.join('/'), " because of missing URL")));
|
|
10580
10728
|
}
|
|
@@ -10708,7 +10856,7 @@
|
|
|
10708
10856
|
* Note: [0] It can be used for more JSON types like whole collection of pipelines, single knowledge piece, etc.
|
|
10709
10857
|
* Note: In contrast to JSON.stringify, this function ensures that **embedding index** is on single line
|
|
10710
10858
|
*
|
|
10711
|
-
* @public exported from `@promptbook/
|
|
10859
|
+
* @public exported from `@promptbook/editable`
|
|
10712
10860
|
*/
|
|
10713
10861
|
function stringifyPipelineJson(pipeline) {
|
|
10714
10862
|
if (!isSerializableAsJson(pipeline)) {
|