@promptbook/legacy-documents 0.74.0-8 → 0.75.0-1
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 +2 -11
- package/esm/index.es.js +92 -52
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +3 -0
- package/esm/typings/src/_packages/core.index.d.ts +25 -1
- package/esm/typings/src/_packages/types.index.d.ts +10 -0
- package/esm/typings/src/_packages/utils.index.d.ts +4 -0
- package/esm/typings/src/cli/cli-commands/run.d.ts +1 -1
- package/esm/typings/src/cli/main.d.ts +4 -1
- package/esm/typings/src/cli/promptbookCli.d.ts +1 -1
- package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
- package/esm/typings/src/collection/collectionToJson.test.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -1
- package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/FORMFACTOR/FormfactorCommand.d.ts +11 -0
- package/esm/typings/src/commands/FORMFACTOR/formfactorCommand.test.d.ts +1 -0
- package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +11 -0
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +2 -0
- package/esm/typings/src/commands/index.d.ts +1 -1
- package/esm/typings/src/config.d.ts +7 -0
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +3 -3
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +2 -2
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -2
- package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +7 -7
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +1 -1
- package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +34 -0
- package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +5 -0
- package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +5 -0
- package/esm/typings/src/formfactors/chat/ChatFormfactorDefinition.d.ts +15 -0
- package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/formfactors/index.d.ts +39 -0
- package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/pipeline/pipeline-interface/PipelineInterface.d.ts +22 -0
- package/esm/typings/src/pipeline/pipeline-interface/constants.d.ts +9 -0
- package/esm/typings/src/pipeline/pipeline-interface/getPipelineInterface.d.ts +11 -0
- package/esm/typings/src/pipeline/pipeline-interface/isPipelineImplementingInterface.d.ts +25 -0
- package/esm/typings/src/pipeline/pipeline-interface/isPipelineInterfacesEqual.d.ts +11 -0
- package/esm/typings/src/storage/blackhole/BlackholeStorage.d.ts +33 -0
- package/esm/typings/src/storage/memory/MemoryStorage.d.ts +1 -1
- package/esm/typings/src/storage/{memory/utils → utils}/PrefixStorage.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +11 -4
- package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
- package/esm/typings/src/types/Prompt.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +2 -2
- package/esm/typings/src/utils/expectation-counters/constants.d.ts +15 -0
- package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -0
- package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -0
- package/package.json +2 -2
- package/umd/index.umd.js +92 -52
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
package/umd/index.umd.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
26
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.75.0-0';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
*/
|
|
@@ -462,6 +462,7 @@
|
|
|
462
462
|
// Note: In normal situations, we check the pipeline logic:
|
|
463
463
|
true);
|
|
464
464
|
/**
|
|
465
|
+
* TODO: Extract `constants.ts` from `config.ts`
|
|
465
466
|
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
466
467
|
*/
|
|
467
468
|
|
|
@@ -1225,7 +1226,7 @@
|
|
|
1225
1226
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
1226
1227
|
*/
|
|
1227
1228
|
|
|
1228
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.
|
|
1229
|
+
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}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/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}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/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}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/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}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.book.md"}];
|
|
1229
1230
|
|
|
1230
1231
|
/**
|
|
1231
1232
|
* Prettify the html code
|
|
@@ -1273,13 +1274,13 @@
|
|
|
1273
1274
|
/**
|
|
1274
1275
|
* Converts promptbook in JSON format to string format
|
|
1275
1276
|
*
|
|
1276
|
-
* @param pipelineJson Promptbook in JSON format (.
|
|
1277
|
-
* @returns Promptbook in string format (.
|
|
1277
|
+
* @param pipelineJson Promptbook in JSON format (.book.json)
|
|
1278
|
+
* @returns Promptbook in string format (.book.md)
|
|
1278
1279
|
* @public exported from `@promptbook/core`
|
|
1279
1280
|
*/
|
|
1280
1281
|
function pipelineJsonToString(pipelineJson) {
|
|
1281
1282
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
1282
|
-
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl,
|
|
1283
|
+
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
|
|
1283
1284
|
var pipelineString = "# ".concat(title);
|
|
1284
1285
|
if (description) {
|
|
1285
1286
|
pipelineString += '\n\n';
|
|
@@ -1289,8 +1290,10 @@
|
|
|
1289
1290
|
if (pipelineUrl) {
|
|
1290
1291
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
1291
1292
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1293
|
+
if (bookVersion !== "undefined") {
|
|
1294
|
+
commands.push("BOOK VERSION ".concat(bookVersion));
|
|
1295
|
+
}
|
|
1296
|
+
// TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
|
|
1294
1297
|
pipelineString = prettifyMarkdown(pipelineString);
|
|
1295
1298
|
try {
|
|
1296
1299
|
for (var _g = __values(parameters.filter(function (_a) {
|
|
@@ -1470,7 +1473,7 @@
|
|
|
1470
1473
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
1471
1474
|
* TODO: [🏛] Maybe make some markdown builder
|
|
1472
1475
|
* TODO: [🏛] Escape all
|
|
1473
|
-
* TODO: [🧠] Should be in generated .
|
|
1476
|
+
* TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
|
|
1474
1477
|
*/
|
|
1475
1478
|
|
|
1476
1479
|
/**
|
|
@@ -1617,7 +1620,7 @@
|
|
|
1617
1620
|
if (!url.startsWith('https://')) {
|
|
1618
1621
|
return false;
|
|
1619
1622
|
}
|
|
1620
|
-
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.
|
|
1623
|
+
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
|
|
1621
1624
|
return false;
|
|
1622
1625
|
}
|
|
1623
1626
|
if (url.includes('#')) {
|
|
@@ -1686,9 +1689,9 @@
|
|
|
1686
1689
|
// <- Note: [🚲]
|
|
1687
1690
|
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1688
1691
|
}
|
|
1689
|
-
if (pipeline.
|
|
1692
|
+
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
1690
1693
|
// <- Note: [🚲]
|
|
1691
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.
|
|
1694
|
+
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1692
1695
|
}
|
|
1693
1696
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
1694
1697
|
if (!Array.isArray(pipeline.parameters)) {
|
|
@@ -1702,18 +1705,18 @@
|
|
|
1702
1705
|
}
|
|
1703
1706
|
var _loop_1 = function (parameter) {
|
|
1704
1707
|
if (parameter.isInput && parameter.isOutput) {
|
|
1705
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n\n Parameter {".concat(parameter.name, "} can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1708
|
+
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n\n Parameter `{".concat(parameter.name, "}` can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1706
1709
|
}
|
|
1707
1710
|
// Note: Testing that parameter is either intermediate or output BUT not created and unused
|
|
1708
1711
|
if (!parameter.isInput &&
|
|
1709
1712
|
!parameter.isOutput &&
|
|
1710
1713
|
!pipeline.templates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
|
|
1711
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
1714
|
+
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
1712
1715
|
}
|
|
1713
1716
|
// Note: Testing that parameter is either input or result of some template
|
|
1714
1717
|
if (!parameter.isInput &&
|
|
1715
1718
|
!pipeline.templates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
|
|
1716
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of {").concat(parameter.name, "}
|
|
1719
|
+
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of `{").concat(parameter.name, "}`\n 2) Add template that results in `-> {").concat(parameter.name, "}`\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1717
1720
|
}
|
|
1718
1721
|
};
|
|
1719
1722
|
try {
|
|
@@ -1741,7 +1744,7 @@
|
|
|
1741
1744
|
var _loop_2 = function (template) {
|
|
1742
1745
|
var e_4, _h, e_5, _j;
|
|
1743
1746
|
if (definedParameters.has(template.resultingParameterName)) {
|
|
1744
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(template.resultingParameterName, "} is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1747
|
+
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(template.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1745
1748
|
}
|
|
1746
1749
|
if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
|
|
1747
1750
|
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
@@ -1754,7 +1757,7 @@
|
|
|
1754
1757
|
}
|
|
1755
1758
|
var _loop_4 = function (joker) {
|
|
1756
1759
|
if (!template.dependentParameterNames.includes(joker)) {
|
|
1757
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1760
|
+
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(joker, "}` is used for {").concat(template.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1758
1761
|
}
|
|
1759
1762
|
};
|
|
1760
1763
|
try {
|
|
@@ -1849,14 +1852,24 @@
|
|
|
1849
1852
|
if (currentlyResovedTemplates.length === 0) {
|
|
1850
1853
|
throw new PipelineLogicError(
|
|
1851
1854
|
// TODO: [🐎] DRY
|
|
1852
|
-
spaceTrim.spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve
|
|
1855
|
+
spaceTrim.spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates
|
|
1853
1856
|
.map(function (_a) {
|
|
1854
1857
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
1855
|
-
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
1856
|
-
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
1858
|
+
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
1859
|
+
.map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
|
|
1857
1860
|
.join(' and '));
|
|
1858
1861
|
})
|
|
1859
|
-
.join('\n')), "\n\n Resolved
|
|
1862
|
+
.join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameters
|
|
1863
|
+
.filter(function (name) {
|
|
1864
|
+
return !RESERVED_PARAMETER_NAMES.includes(name);
|
|
1865
|
+
})
|
|
1866
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
1867
|
+
.join('\n')), "\n\n\n **Reserved (which are available):**\n ").concat(block(resovedParameters
|
|
1868
|
+
.filter(function (name) {
|
|
1869
|
+
return RESERVED_PARAMETER_NAMES.includes(name);
|
|
1870
|
+
})
|
|
1871
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
1872
|
+
.join('\n')), "\n\n\n "); }));
|
|
1860
1873
|
}
|
|
1861
1874
|
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
|
|
1862
1875
|
var resultingParameterName = _a.resultingParameterName;
|
|
@@ -1867,6 +1880,7 @@
|
|
|
1867
1880
|
while (unresovedTemplates.length > 0) {
|
|
1868
1881
|
_loop_3();
|
|
1869
1882
|
}
|
|
1883
|
+
// TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
|
|
1870
1884
|
}
|
|
1871
1885
|
/**
|
|
1872
1886
|
* TODO: !! [🧞♀️] Do not allow joker + foreach
|
|
@@ -2804,8 +2818,8 @@
|
|
|
2804
2818
|
else if (errors.length > 1) {
|
|
2805
2819
|
throw new PipelineExecutionError(
|
|
2806
2820
|
// TODO: Tell which execution tools failed like
|
|
2807
|
-
// 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
|
|
2808
|
-
// 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
|
|
2821
|
+
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
2822
|
+
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
2809
2823
|
// 3) ...
|
|
2810
2824
|
spaceTrim__default["default"](function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
|
|
2811
2825
|
.map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
|
|
@@ -2919,7 +2933,7 @@
|
|
|
2919
2933
|
collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
|
|
2920
2934
|
_b = createPipelineExecutor;
|
|
2921
2935
|
_c = {};
|
|
2922
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.
|
|
2936
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
|
|
2923
2937
|
case 1:
|
|
2924
2938
|
preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
|
|
2925
2939
|
_c.tools = tools,
|
|
@@ -3529,13 +3543,14 @@
|
|
|
3529
3543
|
*/
|
|
3530
3544
|
function clonePipeline(pipeline) {
|
|
3531
3545
|
// Note: Not using spread operator (...) because @@@
|
|
3532
|
-
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title,
|
|
3546
|
+
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
|
|
3533
3547
|
return {
|
|
3534
3548
|
pipelineUrl: pipelineUrl,
|
|
3535
3549
|
sourceFile: sourceFile,
|
|
3536
3550
|
title: title,
|
|
3537
|
-
|
|
3551
|
+
bookVersion: bookVersion,
|
|
3538
3552
|
description: description,
|
|
3553
|
+
formfactorName: formfactorName,
|
|
3539
3554
|
parameters: parameters,
|
|
3540
3555
|
templates: templates,
|
|
3541
3556
|
knowledgeSources: knowledgeSources,
|
|
@@ -4400,11 +4415,11 @@
|
|
|
4400
4415
|
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
4401
4416
|
var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
|
|
4402
4417
|
if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
|
|
4403
|
-
throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
|
|
4418
|
+
throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
|
|
4404
4419
|
}
|
|
4405
4420
|
else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
|
|
4406
4421
|
// TODO: [🍵]
|
|
4407
|
-
throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
|
|
4422
|
+
throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
|
|
4408
4423
|
}
|
|
4409
4424
|
}
|
|
4410
4425
|
}
|
|
@@ -4431,11 +4446,11 @@
|
|
|
4431
4446
|
throw new PipelineExecutionError('Parameter is already opened or not closed');
|
|
4432
4447
|
}
|
|
4433
4448
|
if (parameters[parameterName] === undefined) {
|
|
4434
|
-
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
4449
|
+
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4435
4450
|
}
|
|
4436
4451
|
var parameterValue = parameters[parameterName];
|
|
4437
4452
|
if (parameterValue === undefined) {
|
|
4438
|
-
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
4453
|
+
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4439
4454
|
}
|
|
4440
4455
|
parameterValue = parameterValue.toString();
|
|
4441
4456
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
@@ -4479,30 +4494,45 @@
|
|
|
4479
4494
|
return text.length;
|
|
4480
4495
|
}
|
|
4481
4496
|
|
|
4497
|
+
/**
|
|
4498
|
+
* Number of characters per standard line with 11pt Arial font size.
|
|
4499
|
+
*
|
|
4500
|
+
* @public exported from `@promptbook/utils`
|
|
4501
|
+
*/
|
|
4502
|
+
var CHARACTERS_PER_STANDARD_LINE = 63;
|
|
4503
|
+
/**
|
|
4504
|
+
* Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
|
|
4505
|
+
*
|
|
4506
|
+
* @public exported from `@promptbook/utils`
|
|
4507
|
+
*/
|
|
4508
|
+
var LINES_PER_STANDARD_PAGE = 44;
|
|
4509
|
+
/**
|
|
4510
|
+
* TODO: [🧠] Should be this `constants.ts` or `config.ts`?
|
|
4511
|
+
*/
|
|
4512
|
+
|
|
4482
4513
|
/**
|
|
4483
4514
|
* Counts number of lines in the text
|
|
4484
4515
|
*
|
|
4516
|
+
* Note: This does not check only for the presence of newlines, but also for the length of the standard line.
|
|
4517
|
+
*
|
|
4485
4518
|
* @public exported from `@promptbook/utils`
|
|
4486
4519
|
*/
|
|
4487
4520
|
function countLines(text) {
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
return
|
|
4521
|
+
text = text.replace('\r\n', '\n');
|
|
4522
|
+
text = text.replace('\r', '\n');
|
|
4523
|
+
var lines = text.split('\n');
|
|
4524
|
+
return lines.reduce(function (count, line) { return count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE); }, 0);
|
|
4492
4525
|
}
|
|
4493
4526
|
|
|
4494
4527
|
/**
|
|
4495
4528
|
* Counts number of pages in the text
|
|
4496
4529
|
*
|
|
4530
|
+
* Note: This does not check only for the count of newlines, but also for the length of the standard line and length of the standard page.
|
|
4531
|
+
*
|
|
4497
4532
|
* @public exported from `@promptbook/utils`
|
|
4498
4533
|
*/
|
|
4499
4534
|
function countPages(text) {
|
|
4500
|
-
|
|
4501
|
-
return 0;
|
|
4502
|
-
}
|
|
4503
|
-
var pagesByLinesCount = Math.ceil(countLines(text) / 44);
|
|
4504
|
-
var pagesByCharactersCount = Math.ceil(countCharacters(text) / 2772);
|
|
4505
|
-
return Math.max(pagesByLinesCount, pagesByCharactersCount);
|
|
4535
|
+
return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
|
|
4506
4536
|
}
|
|
4507
4537
|
|
|
4508
4538
|
/**
|
|
@@ -4782,7 +4812,7 @@
|
|
|
4782
4812
|
promptTitle: template.title,
|
|
4783
4813
|
promptMessage: replaceParameters(template.description || '', parameters),
|
|
4784
4814
|
defaultValue: replaceParameters(preparedContent, parameters),
|
|
4785
|
-
// TODO: [🧠] !! Figure out how to define placeholder in .
|
|
4815
|
+
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
4786
4816
|
placeholder: undefined,
|
|
4787
4817
|
priority: priority,
|
|
4788
4818
|
}))];
|
|
@@ -5210,7 +5240,7 @@
|
|
|
5210
5240
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
5211
5241
|
// Houston, we have a problem
|
|
5212
5242
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
5213
|
-
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is NOT defined\n BUT used in template \"").concat(currentTemplate.title || currentTemplate.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
5243
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameterName, "}` is NOT defined\n BUT used in template \"").concat(currentTemplate.title || currentTemplate.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
5214
5244
|
}
|
|
5215
5245
|
};
|
|
5216
5246
|
try {
|
|
@@ -5289,7 +5319,7 @@
|
|
|
5289
5319
|
var _loop_1 = function (parameter) {
|
|
5290
5320
|
if (parametersToPass[parameter.name] === undefined) {
|
|
5291
5321
|
// [4]
|
|
5292
|
-
$warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} should be an output parameter, but it was not generated during pipeline execution\n\n ").concat(block(pipelineIdentification), "\n "); })));
|
|
5322
|
+
$warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` should be an output parameter, but it was not generated during pipeline execution\n\n ").concat(block(pipelineIdentification), "\n "); })));
|
|
5293
5323
|
return "continue";
|
|
5294
5324
|
}
|
|
5295
5325
|
outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
|
|
@@ -5348,7 +5378,7 @@
|
|
|
5348
5378
|
pipelineUrl: preparedPipeline.pipelineUrl,
|
|
5349
5379
|
title: preparedPipeline.title,
|
|
5350
5380
|
promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
5351
|
-
promptbookRequestedVersion: preparedPipeline.
|
|
5381
|
+
promptbookRequestedVersion: preparedPipeline.bookVersion,
|
|
5352
5382
|
description: preparedPipeline.description,
|
|
5353
5383
|
promptExecutions: [],
|
|
5354
5384
|
};
|
|
@@ -5376,7 +5406,7 @@
|
|
|
5376
5406
|
case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
|
|
5377
5407
|
isSuccessful: false,
|
|
5378
5408
|
errors: __spreadArray([
|
|
5379
|
-
new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
|
|
5409
|
+
new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
|
|
5380
5410
|
], __read(errors), false).map(serializeError),
|
|
5381
5411
|
warnings: [],
|
|
5382
5412
|
executionReport: executionReport,
|
|
@@ -5424,7 +5454,7 @@
|
|
|
5424
5454
|
case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
|
|
5425
5455
|
isSuccessful: false,
|
|
5426
5456
|
errors: __spreadArray([
|
|
5427
|
-
new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
|
|
5457
|
+
new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
|
|
5428
5458
|
], __read(errors), false).map(serializeError),
|
|
5429
5459
|
warnings: warnings.map(serializeError),
|
|
5430
5460
|
executionReport: executionReport,
|
|
@@ -5498,14 +5528,24 @@
|
|
|
5498
5528
|
if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
5499
5529
|
throw new UnexpectedError(
|
|
5500
5530
|
// TODO: [🐎] DRY
|
|
5501
|
-
spaceTrim.spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve
|
|
5531
|
+
spaceTrim.spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates_1
|
|
5502
5532
|
.map(function (_a) {
|
|
5503
5533
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
5504
|
-
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
5505
|
-
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
5534
|
+
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
5535
|
+
.map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
|
|
5506
5536
|
.join(' and '));
|
|
5507
5537
|
})
|
|
5508
|
-
.join('\n')), "\n\n Resolved
|
|
5538
|
+
.join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameterNames_1
|
|
5539
|
+
.filter(function (name) {
|
|
5540
|
+
return !RESERVED_PARAMETER_NAMES.includes(name);
|
|
5541
|
+
})
|
|
5542
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
5543
|
+
.join('\n')), "\n\n **Reserved (which are available):**\n ").concat(block(resovedParameterNames_1
|
|
5544
|
+
.filter(function (name) {
|
|
5545
|
+
return RESERVED_PARAMETER_NAMES.includes(name);
|
|
5546
|
+
})
|
|
5547
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
5548
|
+
.join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
|
|
5509
5549
|
case 1:
|
|
5510
5550
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
5511
5551
|
/* [🤹♂️] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
@@ -5744,7 +5784,7 @@
|
|
|
5744
5784
|
collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
|
|
5745
5785
|
_d = createPipelineExecutor;
|
|
5746
5786
|
_g = {};
|
|
5747
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.
|
|
5787
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md')];
|
|
5748
5788
|
case 1:
|
|
5749
5789
|
prepareKnowledgeFromMarkdownExecutor = _d.apply(void 0, [(_g.pipeline = _k.sent(),
|
|
5750
5790
|
_g.tools = {
|
|
@@ -5753,7 +5793,7 @@
|
|
|
5753
5793
|
_g)]);
|
|
5754
5794
|
_e = createPipelineExecutor;
|
|
5755
5795
|
_h = {};
|
|
5756
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.
|
|
5796
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.book.md')];
|
|
5757
5797
|
case 2:
|
|
5758
5798
|
prepareTitleExecutor = _e.apply(void 0, [(_h.pipeline = _k.sent(),
|
|
5759
5799
|
_h.tools = {
|
|
@@ -5762,7 +5802,7 @@
|
|
|
5762
5802
|
_h)]);
|
|
5763
5803
|
_f = createPipelineExecutor;
|
|
5764
5804
|
_j = {};
|
|
5765
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.
|
|
5805
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md')];
|
|
5766
5806
|
case 3:
|
|
5767
5807
|
prepareKeywordsExecutor = _f.apply(void 0, [(_j.pipeline = _k.sent(),
|
|
5768
5808
|
_j.tools = {
|