@promptbook/core 0.61.0-10 → 0.61.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/esm/index.es.js +363 -237
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +83 -2
- package/esm/typings/src/_packages/core.index.d.ts +2 -2
- package/esm/typings/src/_packages/types.index.d.ts +2 -2
- package/esm/typings/src/_packages/utils.index.d.ts +3 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +3 -0
- package/esm/typings/src/config.d.ts +4 -0
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +1 -0
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -0
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +4 -0
- package/esm/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
- package/{umd/typings/src/errors/VersionMismatch.d.ts → esm/typings/src/errors/VersionMismatchError.d.ts} +1 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +3 -1
- package/esm/typings/src/execution/PipelineExecutor.d.ts +4 -3
- package/esm/typings/src/execution/PromptResult.d.ts +12 -0
- package/esm/typings/src/execution/ScriptExecutionTools.d.ts +4 -2
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +2 -0
- package/esm/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +10 -0
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
- package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
- package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/utils/cache/CacheItem.d.ts +29 -0
- package/esm/typings/src/llm-providers/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
- package/esm/typings/src/llm-providers/utils/cache/cacheLlmTools.d.ts +17 -0
- package/esm/typings/src/llm-providers/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
- package/esm/typings/src/llm-providers/utils/count-total-cost/countTotalCost.d.ts +14 -0
- package/esm/typings/src/llm-providers/utils/createLlmToolsFromEnv.d.ts +21 -0
- package/esm/typings/src/personas/preparePersona.d.ts +0 -3
- package/esm/typings/src/prepare/preparePipeline.d.ts +2 -1
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +24 -0
- package/esm/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
- package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +28 -0
- package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +10 -0
- package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
- package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
- package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +8 -0
- package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +8 -0
- package/esm/typings/src/storage/memory/MemoryStorage.d.ts +31 -0
- package/esm/typings/src/storage/utils/PrefixStorage.d.ts +23 -0
- package/esm/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +12 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +21 -1
- package/esm/typings/src/types/Parameters.d.ts +0 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +0 -1
- package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -5
- package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +1 -0
- package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +11 -2
- package/esm/typings/src/types/Prompt.d.ts +5 -2
- package/esm/typings/src/types/typeAliases.d.ts +35 -1
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +7 -0
- package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
- package/esm/typings/src/utils/organization/notUsing.d.ts +11 -0
- package/esm/typings/src/utils/random/randomSeed.d.ts +7 -0
- package/package.json +1 -1
- package/umd/index.umd.js +363 -237
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/promptbook-collection/index.d.ts +83 -2
- package/umd/typings/src/_packages/core.index.d.ts +2 -2
- package/umd/typings/src/_packages/types.index.d.ts +2 -2
- package/umd/typings/src/_packages/utils.index.d.ts +3 -1
- package/umd/typings/src/commands/_common/types/CommandParser.d.ts +3 -0
- package/umd/typings/src/config.d.ts +4 -0
- package/umd/typings/src/conversion/pipelineStringToJson.d.ts +1 -0
- package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -0
- package/umd/typings/src/conversion/validation/validatePipeline.d.ts +4 -0
- package/umd/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
- package/{esm/typings/src/errors/VersionMismatch.d.ts → umd/typings/src/errors/VersionMismatchError.d.ts} +1 -1
- package/umd/typings/src/execution/LlmExecutionTools.d.ts +3 -1
- package/umd/typings/src/execution/PipelineExecutor.d.ts +4 -3
- package/umd/typings/src/execution/PromptResult.d.ts +12 -0
- package/umd/typings/src/execution/ScriptExecutionTools.d.ts +4 -2
- package/umd/typings/src/execution/createPipelineExecutor.d.ts +2 -0
- package/umd/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +10 -0
- package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
- package/umd/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
- package/umd/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
- package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
- package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
- package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -1
- package/umd/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
- package/umd/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
- package/umd/typings/src/llm-providers/utils/cache/CacheItem.d.ts +29 -0
- package/umd/typings/src/llm-providers/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
- package/umd/typings/src/llm-providers/utils/cache/cacheLlmTools.d.ts +17 -0
- package/umd/typings/src/llm-providers/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
- package/umd/typings/src/llm-providers/utils/count-total-cost/countTotalCost.d.ts +14 -0
- package/umd/typings/src/llm-providers/utils/createLlmToolsFromEnv.d.ts +21 -0
- package/umd/typings/src/personas/preparePersona.d.ts +0 -3
- package/umd/typings/src/prepare/preparePipeline.d.ts +2 -1
- package/umd/typings/src/storage/_common/PromptbookStorage.d.ts +24 -0
- package/umd/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
- package/umd/typings/src/storage/files-storage/FilesStorage.d.ts +28 -0
- package/umd/typings/src/storage/files-storage/FilesStorageOptions.d.ts +10 -0
- package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
- package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
- package/umd/typings/src/storage/local-storage/getLocalStorage.d.ts +8 -0
- package/umd/typings/src/storage/local-storage/getSessionStorage.d.ts +8 -0
- package/umd/typings/src/storage/memory/MemoryStorage.d.ts +31 -0
- package/umd/typings/src/storage/utils/PrefixStorage.d.ts +23 -0
- package/umd/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +12 -0
- package/umd/typings/src/types/ModelRequirements.d.ts +21 -1
- package/umd/typings/src/types/Parameters.d.ts +0 -1
- package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +0 -1
- package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -5
- package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +1 -0
- package/umd/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +11 -2
- package/umd/typings/src/types/Prompt.d.ts +5 -2
- package/umd/typings/src/types/typeAliases.d.ts +35 -1
- package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
- package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +7 -0
- package/umd/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
- package/umd/typings/src/utils/organization/notUsing.d.ts +11 -0
- package/umd/typings/src/utils/random/randomSeed.d.ts +7 -0
- package/esm/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
- package/esm/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTests.d.ts +0 -7
- package/umd/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
- package/umd/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTests.d.ts +0 -7
package/esm/index.es.js
CHANGED
|
@@ -779,6 +779,10 @@ function validatePipeline(pipeline) {
|
|
|
779
779
|
* > * - ...
|
|
780
780
|
* > ex port function validatePipeline(promptbook: unknown): asserts promptbook is PipelineJson {
|
|
781
781
|
*/
|
|
782
|
+
/**
|
|
783
|
+
* TODO: [🧠] !!!!! Validate new things
|
|
784
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
785
|
+
*/
|
|
782
786
|
|
|
783
787
|
/**
|
|
784
788
|
* This error indicates that promptbook not found in the collection
|
|
@@ -1288,7 +1292,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1288
1292
|
});
|
|
1289
1293
|
}
|
|
1290
1294
|
|
|
1291
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
1295
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-10",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],blockType:"PROMPT_TEMPLATE",personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",resultingParameterName:"knowledge"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-10",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.61.0-10",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],blockType:"PROMPT_TEMPLATE",personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-10",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.61.0-10",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],blockType:"PROMPT_TEMPLATE",expectations:{words:{min:1,max:8}},personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-10",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.61.0-10",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}],promptTemplates:[{name:"make-model-requirements",title:"Make modelRequirements",dependentParameterNames:["availableModelNames","personaDescription"],blockType:"PROMPT_TEMPLATE",expectFormat:"JSON",personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\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### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `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### Option `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"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-10",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1292
1296
|
|
|
1293
1297
|
var defaultDiacriticsRemovalMap = [
|
|
1294
1298
|
{
|
|
@@ -1844,7 +1848,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
1844
1848
|
};
|
|
1845
1849
|
/**
|
|
1846
1850
|
* List all available models that can be used
|
|
1847
|
-
* This
|
|
1851
|
+
* This lists is a combination of all available models from all execution tools
|
|
1848
1852
|
*/
|
|
1849
1853
|
MultipleLlmExecutionTools.prototype.listModels = function () {
|
|
1850
1854
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1890,6 +1894,8 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
1890
1894
|
}());
|
|
1891
1895
|
/**
|
|
1892
1896
|
* TODO: [🧠][🎛] Aggregating multiple models - have result not only from one first aviable model BUT all of them
|
|
1897
|
+
* TODO: [🏖] If no llmTools have for example not defined `callCompletionModel` this will still return object with defined `callCompletionModel` which just throws `PipelineExecutionError`, make it undefined instead
|
|
1898
|
+
* Look how `countTotalUsage` (and `cacheLlmTools`) implements it
|
|
1893
1899
|
*/
|
|
1894
1900
|
|
|
1895
1901
|
/**
|
|
@@ -1960,7 +1966,7 @@ function arrayableToArray(input) {
|
|
|
1960
1966
|
/**
|
|
1961
1967
|
* The version of the Promptbook library
|
|
1962
1968
|
*/
|
|
1963
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
1969
|
+
var PROMPTBOOK_VERSION = '0.61.0-10';
|
|
1964
1970
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
1965
1971
|
|
|
1966
1972
|
/**
|
|
@@ -2164,7 +2170,6 @@ function createPipelineExecutor(options) {
|
|
|
2164
2170
|
var _this = this;
|
|
2165
2171
|
var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
|
|
2166
2172
|
var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? 3 : _b;
|
|
2167
|
-
// TODO: !!!!! Implement new commands
|
|
2168
2173
|
validatePipeline(pipeline);
|
|
2169
2174
|
var llmTools = joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(arrayableToArray(tools.llm)), false));
|
|
2170
2175
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -2240,7 +2245,10 @@ function createPipelineExecutor(options) {
|
|
|
2240
2245
|
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
|
|
2241
2246
|
parameters: parametersToPass,
|
|
2242
2247
|
content: replaceParameters(currentTemplate.content, parametersToPass) /* <- [2] */,
|
|
2248
|
+
// <- TODO: !!!!! Apply {context} and knowledges
|
|
2249
|
+
// <- TODO: !!!!! Apply samples
|
|
2243
2250
|
modelRequirements: currentTemplate.modelRequirements,
|
|
2251
|
+
// <- TODO: !!!!! Apply persona
|
|
2244
2252
|
expectations: currentTemplate.expectations,
|
|
2245
2253
|
expectFormat: currentTemplate.expectFormat,
|
|
2246
2254
|
postprocessing: (currentTemplate.postprocessing || []).map(function (functionName) { return function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -2687,10 +2695,12 @@ function createPipelineExecutor(options) {
|
|
|
2687
2695
|
}
|
|
2688
2696
|
/**
|
|
2689
2697
|
* TODO: [🪂] Pass maxParallelCount here
|
|
2698
|
+
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
2690
2699
|
* TODO: [🧠] When not meet expectations in PROMPT_DIALOG, make some way to tell the user
|
|
2691
2700
|
* TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
|
|
2692
2701
|
* Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
|
|
2693
2702
|
* TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
|
|
2703
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
2694
2704
|
*/
|
|
2695
2705
|
|
|
2696
2706
|
/**
|
|
@@ -2708,7 +2718,6 @@ function TODO_USE() {
|
|
|
2708
2718
|
value[_i] = arguments[_i];
|
|
2709
2719
|
}
|
|
2710
2720
|
}
|
|
2711
|
-
// TODO: !!!! Find ACRY all just(...) and replace with TODO_USE
|
|
2712
2721
|
|
|
2713
2722
|
/**
|
|
2714
2723
|
* @@@
|
|
@@ -2914,32 +2923,59 @@ TODO: [🧊] This is how it can look in future
|
|
|
2914
2923
|
*/
|
|
2915
2924
|
function preparePersona(personaDescription, options) {
|
|
2916
2925
|
return __awaiter(this, void 0, void 0, function () {
|
|
2917
|
-
var llmTools, _a,
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2926
|
+
var llmTools, _a, isVerbose, collection, preparePersonaExecutor, _b, availableModels, availableModelNames, result, outputParameters, modelRequirementsRaw, modelRequirements, modelName, systemMessage, temperature;
|
|
2927
|
+
var _c;
|
|
2928
|
+
return __generator(this, function (_d) {
|
|
2929
|
+
switch (_d.label) {
|
|
2930
|
+
case 0:
|
|
2931
|
+
llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
2932
|
+
collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
|
|
2933
|
+
_b = createPipelineExecutor;
|
|
2934
|
+
_c = {};
|
|
2935
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.ptbk.md')];
|
|
2936
|
+
case 1:
|
|
2937
|
+
preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
|
|
2938
|
+
_c.tools = {
|
|
2939
|
+
llm: llmTools,
|
|
2940
|
+
},
|
|
2941
|
+
_c)]);
|
|
2942
|
+
return [4 /*yield*/, llmTools.listModels()];
|
|
2943
|
+
case 2:
|
|
2944
|
+
availableModels = _d.sent();
|
|
2945
|
+
availableModelNames = availableModels
|
|
2946
|
+
.filter(function (_a) {
|
|
2947
|
+
var modelVariant = _a.modelVariant;
|
|
2948
|
+
return modelVariant === 'CHAT';
|
|
2949
|
+
})
|
|
2950
|
+
.map(function (_a) {
|
|
2951
|
+
var modelName = _a.modelName;
|
|
2952
|
+
return modelName;
|
|
2953
|
+
})
|
|
2954
|
+
.join(',');
|
|
2955
|
+
return [4 /*yield*/, preparePersonaExecutor({ availableModelNames: availableModelNames, personaDescription: personaDescription })];
|
|
2956
|
+
case 3:
|
|
2957
|
+
result = _d.sent();
|
|
2958
|
+
assertsExecutionSuccessful(result);
|
|
2959
|
+
outputParameters = result.outputParameters;
|
|
2960
|
+
modelRequirementsRaw = outputParameters.modelRequirements;
|
|
2961
|
+
modelRequirements = JSON.parse(modelRequirementsRaw);
|
|
2962
|
+
if (isVerbose) {
|
|
2963
|
+
console.info("PERSONA ".concat(personaDescription), modelRequirements);
|
|
2964
|
+
}
|
|
2965
|
+
modelName = modelRequirements.modelName, systemMessage = modelRequirements.systemMessage, temperature = modelRequirements.temperature;
|
|
2966
|
+
// TODO: !!! Check validity of `modelName`
|
|
2967
|
+
// TODO: !!! Check validity of `systemMessage`
|
|
2968
|
+
// TODO: !!! Check validity of `temperature`
|
|
2969
|
+
return [2 /*return*/, {
|
|
2970
|
+
modelVariant: 'CHAT',
|
|
2971
|
+
modelName: modelName,
|
|
2972
|
+
systemMessage: systemMessage,
|
|
2973
|
+
temperature: temperature,
|
|
2974
|
+
}];
|
|
2975
|
+
}
|
|
2928
2976
|
});
|
|
2929
2977
|
});
|
|
2930
2978
|
}
|
|
2931
|
-
/**
|
|
2932
|
-
* TODO: [🪂] Do it in parallel
|
|
2933
|
-
*/
|
|
2934
|
-
|
|
2935
|
-
/**
|
|
2936
|
-
* Simple wrapper `new Date().toISOString()`
|
|
2937
|
-
*
|
|
2938
|
-
* @returns string_date branded type
|
|
2939
|
-
*/
|
|
2940
|
-
function $currentDate() {
|
|
2941
|
-
return new Date().toISOString();
|
|
2942
|
-
}
|
|
2943
2979
|
|
|
2944
2980
|
/**
|
|
2945
2981
|
* Prepare pipeline from string (markdown) format to JSON format
|
|
@@ -2963,7 +2999,7 @@ function preparePipeline(pipeline, options) {
|
|
|
2963
2999
|
knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
|
|
2964
3000
|
currentPreparation = {
|
|
2965
3001
|
id: 1,
|
|
2966
|
-
date: $currentDate(),
|
|
3002
|
+
// TODO: [🍥]> date: $currentDate(),
|
|
2967
3003
|
promptbookVersion: PROMPTBOOK_VERSION,
|
|
2968
3004
|
modelUsage: addUsage(),
|
|
2969
3005
|
};
|
|
@@ -2972,8 +3008,8 @@ function preparePipeline(pipeline, options) {
|
|
|
2972
3008
|
// <- TODO: [🧊]
|
|
2973
3009
|
currentPreparation,
|
|
2974
3010
|
];
|
|
2975
|
-
preparedPersonas =
|
|
2976
|
-
return [4 /*yield*/, forEachAsync(personas, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (persona) { return __awaiter(_this, void 0, void 0, function () {
|
|
3011
|
+
preparedPersonas = new Array(personas.length);
|
|
3012
|
+
return [4 /*yield*/, forEachAsync(personas, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (persona, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
2977
3013
|
var modelRequirements, preparedPersona;
|
|
2978
3014
|
return __generator(this, function (_a) {
|
|
2979
3015
|
switch (_a.label) {
|
|
@@ -2981,7 +3017,7 @@ function preparePipeline(pipeline, options) {
|
|
|
2981
3017
|
case 1:
|
|
2982
3018
|
modelRequirements = _a.sent();
|
|
2983
3019
|
preparedPersona = __assign(__assign({}, persona), { modelRequirements: modelRequirements, preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] });
|
|
2984
|
-
preparedPersonas
|
|
3020
|
+
preparedPersonas[index] = preparedPersona;
|
|
2985
3021
|
return [2 /*return*/];
|
|
2986
3022
|
}
|
|
2987
3023
|
});
|
|
@@ -3003,9 +3039,183 @@ function preparePipeline(pipeline, options) {
|
|
|
3003
3039
|
* TODO: Write tests for `preparePipeline`
|
|
3004
3040
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
3005
3041
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
3006
|
-
* TODO:
|
|
3042
|
+
* TODO: !!!!! Use here countTotalUsage
|
|
3043
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
3007
3044
|
*/
|
|
3008
3045
|
|
|
3046
|
+
/**
|
|
3047
|
+
* Tests if given string is valid URL.
|
|
3048
|
+
*
|
|
3049
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
3050
|
+
*/
|
|
3051
|
+
function isValidFilePath(filePath) {
|
|
3052
|
+
if (typeof filePath !== 'string') {
|
|
3053
|
+
return false;
|
|
3054
|
+
}
|
|
3055
|
+
var filePathSlashes = filePath.split('\\').join('/');
|
|
3056
|
+
// Absolute Unix path: /hello.txt
|
|
3057
|
+
if (/^(\/)/i.test(filePathSlashes)) {
|
|
3058
|
+
return true;
|
|
3059
|
+
}
|
|
3060
|
+
// Absolute Windows path: /hello.txt
|
|
3061
|
+
if (/^([A-Z]{1,2}:\/?)\//i.test(filePathSlashes)) {
|
|
3062
|
+
return true;
|
|
3063
|
+
}
|
|
3064
|
+
// Relative path: ./hello.txt
|
|
3065
|
+
if (/^(\.\.?\/)+/i.test(filePathSlashes)) {
|
|
3066
|
+
return true;
|
|
3067
|
+
}
|
|
3068
|
+
return false;
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
/**
|
|
3072
|
+
* Parses the knowledge command
|
|
3073
|
+
*
|
|
3074
|
+
* @see ./KNOWLEDGE-README.md for more details
|
|
3075
|
+
* @private within the commands folder
|
|
3076
|
+
*/
|
|
3077
|
+
var knowledgeCommandParser = {
|
|
3078
|
+
/**
|
|
3079
|
+
* Name of the command
|
|
3080
|
+
*/
|
|
3081
|
+
name: 'KNOWLEDGE',
|
|
3082
|
+
/**
|
|
3083
|
+
* BOILERPLATE command can be used in:
|
|
3084
|
+
*/
|
|
3085
|
+
usagePlaces: ['PIPELINE_HEAD'],
|
|
3086
|
+
/**
|
|
3087
|
+
* Description of the KNOWLEDGE command
|
|
3088
|
+
*/
|
|
3089
|
+
description: "Tells promptbook which external knowledge to use",
|
|
3090
|
+
/**
|
|
3091
|
+
* Link to discussion
|
|
3092
|
+
*/
|
|
3093
|
+
discussionUrl: 'https://github.com/webgptorg/promptbook/discussions/41',
|
|
3094
|
+
/**
|
|
3095
|
+
* Example usages of the KNOWLEDGE command
|
|
3096
|
+
*/
|
|
3097
|
+
examples: [
|
|
3098
|
+
'KNOWLEDGE https://www.pavolhejny.com/',
|
|
3099
|
+
'KNOWLEDGE ./hejny-cv.txt',
|
|
3100
|
+
'KNOWLEDGE ./hejny-cv.md',
|
|
3101
|
+
'KNOWLEDGE ./hejny-cv.pdf',
|
|
3102
|
+
'KNOWLEDGE ./hejny-cv.docx',
|
|
3103
|
+
],
|
|
3104
|
+
/**
|
|
3105
|
+
* Parses the KNOWLEDGE command
|
|
3106
|
+
*/
|
|
3107
|
+
parse: function (input) {
|
|
3108
|
+
var args = input.args;
|
|
3109
|
+
var source = args[0];
|
|
3110
|
+
if (source === undefined) {
|
|
3111
|
+
throw new ParsingError("Source is not defined");
|
|
3112
|
+
}
|
|
3113
|
+
if (source.startsWith('http://')) {
|
|
3114
|
+
throw new ParsingError("Source is not secure");
|
|
3115
|
+
}
|
|
3116
|
+
if (!(isValidFilePath(source) || isValidUrl(source))) {
|
|
3117
|
+
throw new ParsingError("Source not valid");
|
|
3118
|
+
}
|
|
3119
|
+
if (source.startsWith('../') || source.startsWith('/') || /^[A-Z]:[\\/]+/i.test(source)) {
|
|
3120
|
+
throw new ParsingError("Source cannot be outside of the .ptbk.md folder");
|
|
3121
|
+
}
|
|
3122
|
+
return {
|
|
3123
|
+
type: 'KNOWLEDGE',
|
|
3124
|
+
source: source,
|
|
3125
|
+
};
|
|
3126
|
+
},
|
|
3127
|
+
/**
|
|
3128
|
+
* Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
3129
|
+
*/
|
|
3130
|
+
applyToPipelineJson: function (pipelineJson, personaCommand) {
|
|
3131
|
+
var source = personaCommand.source;
|
|
3132
|
+
var name = titleToName(source);
|
|
3133
|
+
pipelineJson.knowledgeSources.push({
|
|
3134
|
+
name: name,
|
|
3135
|
+
source: source,
|
|
3136
|
+
});
|
|
3137
|
+
},
|
|
3138
|
+
};
|
|
3139
|
+
|
|
3140
|
+
/**
|
|
3141
|
+
* Parses the persona command
|
|
3142
|
+
*
|
|
3143
|
+
* @see ./PERSONA-README.md for more details
|
|
3144
|
+
* @private within the commands folder
|
|
3145
|
+
*/
|
|
3146
|
+
var personaCommandParser = {
|
|
3147
|
+
/**
|
|
3148
|
+
* Name of the command
|
|
3149
|
+
*/
|
|
3150
|
+
name: 'PERSONA',
|
|
3151
|
+
/**
|
|
3152
|
+
* Aliases for the PERSONA command
|
|
3153
|
+
*/
|
|
3154
|
+
aliasNames: ['PERSON'],
|
|
3155
|
+
/**
|
|
3156
|
+
* PERSONA command can be used in:
|
|
3157
|
+
*/
|
|
3158
|
+
usagePlaces: ['PIPELINE_HEAD', 'PIPELINE_TEMPLATE'],
|
|
3159
|
+
/**
|
|
3160
|
+
* Description of the PERSONA command
|
|
3161
|
+
*/
|
|
3162
|
+
description: "Persona command is used to specify who the system is, it will be transformed into system message, top_t,...",
|
|
3163
|
+
/**
|
|
3164
|
+
* Link to discussion
|
|
3165
|
+
*/
|
|
3166
|
+
discussionUrl: 'https://github.com/webgptorg/promptbook/discussions/22',
|
|
3167
|
+
/**
|
|
3168
|
+
* Example usages of the PERSONA command
|
|
3169
|
+
*/
|
|
3170
|
+
examples: ['PERSONA Jane, skilled copywriter', 'PERSONA Joe, male 28 years old, programmer'],
|
|
3171
|
+
/**
|
|
3172
|
+
* Parses the PERSONA command
|
|
3173
|
+
*/
|
|
3174
|
+
parse: function (input) {
|
|
3175
|
+
var rawArgs = input.rawArgs;
|
|
3176
|
+
var _a = __read(rawArgs.split(/[,;:]/, 2), 2), personaNameRaw = _a[0], personaDescriptionRaw = _a[1];
|
|
3177
|
+
var personaName = (personaNameRaw || '').trim();
|
|
3178
|
+
if (personaName === '') {
|
|
3179
|
+
throw new ParsingError("You must set name for the persona");
|
|
3180
|
+
}
|
|
3181
|
+
var personaDescription = (personaDescriptionRaw || '').trim();
|
|
3182
|
+
if (personaDescription === '') {
|
|
3183
|
+
personaDescription = null;
|
|
3184
|
+
}
|
|
3185
|
+
return {
|
|
3186
|
+
type: 'PERSONA',
|
|
3187
|
+
personaName: personaName,
|
|
3188
|
+
personaDescription: personaDescription,
|
|
3189
|
+
};
|
|
3190
|
+
},
|
|
3191
|
+
/**
|
|
3192
|
+
* Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
3193
|
+
*/
|
|
3194
|
+
applyToPipelineJson: function (pipelineJson, personaCommand) {
|
|
3195
|
+
var personaName = personaCommand.personaName, personaDescription = personaCommand.personaDescription;
|
|
3196
|
+
var persona = pipelineJson.personas.find(function (persona) { return persona.name === personaName; });
|
|
3197
|
+
if (persona === undefined) {
|
|
3198
|
+
pipelineJson.personas.push({
|
|
3199
|
+
name: personaName,
|
|
3200
|
+
description: personaDescription || '',
|
|
3201
|
+
});
|
|
3202
|
+
return;
|
|
3203
|
+
}
|
|
3204
|
+
if (persona.description === personaDescription) {
|
|
3205
|
+
return;
|
|
3206
|
+
}
|
|
3207
|
+
if (personaDescription === null) {
|
|
3208
|
+
return;
|
|
3209
|
+
}
|
|
3210
|
+
if (persona.description === '') {
|
|
3211
|
+
persona.description = personaDescription;
|
|
3212
|
+
return;
|
|
3213
|
+
}
|
|
3214
|
+
console.warn(spaceTrim("\n\n Persona \"".concat(personaName, "\" is defined multiple times with different description:\n\n First definition:\n ").concat(persona.description, "\n\n Second definition:\n ").concat(personaDescription, "\n\n ")));
|
|
3215
|
+
persona.description += spaceTrim('\n\n' + personaDescription);
|
|
3216
|
+
},
|
|
3217
|
+
};
|
|
3218
|
+
|
|
3009
3219
|
/**
|
|
3010
3220
|
* Removes Markdown formatting tags from a string.
|
|
3011
3221
|
*
|
|
@@ -3160,7 +3370,6 @@ var blockCommandParser = {
|
|
|
3160
3370
|
normalized = normalized.split('EXAMPLE').join('SAMPLE');
|
|
3161
3371
|
var blockTypes = BlockTypes.filter(function (blockType) { return normalized.includes(blockType); });
|
|
3162
3372
|
if (blockTypes.length !== 1) {
|
|
3163
|
-
// console.log('!!!', { blockType });
|
|
3164
3373
|
throw new ParsingError(spaceTrim(function (block) { return "\n Unknown block type in BLOCK command\n\n Supported block types are:\n ".concat(block(BlockTypes.join(', ')), "\n "); }));
|
|
3165
3374
|
}
|
|
3166
3375
|
// TODO: !!!! Not supported yet
|
|
@@ -3409,92 +3618,12 @@ var jokerCommandParser = {
|
|
|
3409
3618
|
},
|
|
3410
3619
|
};
|
|
3411
3620
|
|
|
3412
|
-
/**
|
|
3413
|
-
* Tests if given string is valid URL.
|
|
3414
|
-
*
|
|
3415
|
-
* Note: This does not check if the file exists only if the path is valid
|
|
3416
|
-
*/
|
|
3417
|
-
function isValidFilePath(filePath) {
|
|
3418
|
-
if (typeof filePath !== 'string') {
|
|
3419
|
-
return false;
|
|
3420
|
-
}
|
|
3421
|
-
var filePathSlashes = filePath.split('\\').join('/');
|
|
3422
|
-
// Absolute Unix path: /hello.txt
|
|
3423
|
-
if (/^(\/)/i.test(filePathSlashes)) {
|
|
3424
|
-
return true;
|
|
3425
|
-
}
|
|
3426
|
-
// Absolute Windows path: /hello.txt
|
|
3427
|
-
if (/^([A-Z]{1,2}:\/?)\//i.test(filePathSlashes)) {
|
|
3428
|
-
return true;
|
|
3429
|
-
}
|
|
3430
|
-
// Relative path: ./hello.txt
|
|
3431
|
-
if (/^(\.\.?\/)+/i.test(filePathSlashes)) {
|
|
3432
|
-
return true;
|
|
3433
|
-
}
|
|
3434
|
-
return false;
|
|
3435
|
-
}
|
|
3436
|
-
|
|
3437
|
-
/**
|
|
3438
|
-
* Parses the knowledge command
|
|
3439
|
-
*
|
|
3440
|
-
* @see ./KNOWLEDGE-README.md for more details
|
|
3441
|
-
* @private within the commands folder
|
|
3442
|
-
*/
|
|
3443
|
-
var knowledgeCommandParser = {
|
|
3444
|
-
/**
|
|
3445
|
-
* Name of the command
|
|
3446
|
-
*/
|
|
3447
|
-
name: 'KNOWLEDGE',
|
|
3448
|
-
/**
|
|
3449
|
-
* BOILERPLATE command can be used in:
|
|
3450
|
-
*/
|
|
3451
|
-
usagePlaces: ['PIPELINE_HEAD'],
|
|
3452
|
-
/**
|
|
3453
|
-
* Description of the KNOWLEDGE command
|
|
3454
|
-
*/
|
|
3455
|
-
description: "Tells promptbook which external knowledge to use",
|
|
3456
|
-
/**
|
|
3457
|
-
* Link to discussion
|
|
3458
|
-
*/
|
|
3459
|
-
discussionUrl: 'https://github.com/webgptorg/promptbook/discussions/41',
|
|
3460
|
-
/**
|
|
3461
|
-
* Example usages of the KNOWLEDGE command
|
|
3462
|
-
*/
|
|
3463
|
-
examples: [
|
|
3464
|
-
'KNOWLEDGE https://www.pavolhejny.com/',
|
|
3465
|
-
'KNOWLEDGE ./hejny-cv.txt',
|
|
3466
|
-
'KNOWLEDGE ./hejny-cv.md',
|
|
3467
|
-
'KNOWLEDGE ./hejny-cv.pdf',
|
|
3468
|
-
'KNOWLEDGE ./hejny-cv.docx',
|
|
3469
|
-
],
|
|
3470
|
-
/**
|
|
3471
|
-
* Parses the KNOWLEDGE command
|
|
3472
|
-
*/
|
|
3473
|
-
parse: function (input) {
|
|
3474
|
-
var args = input.args;
|
|
3475
|
-
var source = args[0];
|
|
3476
|
-
if (source === undefined) {
|
|
3477
|
-
throw new ParsingError("Source is not defined");
|
|
3478
|
-
}
|
|
3479
|
-
if (source.startsWith('http://')) {
|
|
3480
|
-
throw new ParsingError("Source is not secure");
|
|
3481
|
-
}
|
|
3482
|
-
if (!(isValidFilePath(source) || isValidUrl(source))) {
|
|
3483
|
-
throw new ParsingError("Source not valid");
|
|
3484
|
-
}
|
|
3485
|
-
if (source.startsWith('../') || source.startsWith('/') || /^[A-Z]:[\\/]+/i.test(source)) {
|
|
3486
|
-
throw new ParsingError("Source cannot be outside of the .ptbk.md folder");
|
|
3487
|
-
}
|
|
3488
|
-
return {
|
|
3489
|
-
type: 'KNOWLEDGE',
|
|
3490
|
-
source: source,
|
|
3491
|
-
};
|
|
3492
|
-
},
|
|
3493
|
-
};
|
|
3494
|
-
|
|
3495
3621
|
var MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
|
|
3496
3622
|
/**
|
|
3497
|
-
* TODO:
|
|
3623
|
+
* TODO: [🈁] `seed` should maybe be somewhere else (not in `ModelRequirements`) (simmilar that `user` identification is not here)
|
|
3624
|
+
* TODO: [🧠][💱] Add more model options: `stop_token`, `logit_bias`, `logprobs` (`top_logprobs`), `top_k`, `top_p`, `presence_penalty`, `frequency_penalty`, `bestOf`, `logitBias`, `logitBiasType`,...
|
|
3625
|
+
* [💱] Probbably keep using just `temperature` in Promptbook (not `top_k` and `top_p`)
|
|
3626
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
3498
3627
|
* TODO: Maybe figure out better word than "variant"
|
|
3499
3628
|
* TODO: Add here more requirement options like max context size, max tokens, etc.
|
|
3500
3629
|
* TODO: [💕][🧠] Just selecting gpt3 or gpt4 level of model
|
|
@@ -3636,59 +3765,6 @@ var parameterCommandParser = {
|
|
|
3636
3765
|
},
|
|
3637
3766
|
};
|
|
3638
3767
|
|
|
3639
|
-
/**
|
|
3640
|
-
* Parses the persona command
|
|
3641
|
-
*
|
|
3642
|
-
* @see ./PERSONA-README.md for more details
|
|
3643
|
-
* @private within the commands folder
|
|
3644
|
-
*/
|
|
3645
|
-
var personaCommandParser = {
|
|
3646
|
-
/**
|
|
3647
|
-
* Name of the command
|
|
3648
|
-
*/
|
|
3649
|
-
name: 'PERSONA',
|
|
3650
|
-
/**
|
|
3651
|
-
* Aliases for the PERSONA command
|
|
3652
|
-
*/
|
|
3653
|
-
aliasNames: ['PERSON'],
|
|
3654
|
-
/**
|
|
3655
|
-
* PERSONA command can be used in:
|
|
3656
|
-
*/
|
|
3657
|
-
usagePlaces: ['PIPELINE_HEAD', 'PIPELINE_TEMPLATE'],
|
|
3658
|
-
/**
|
|
3659
|
-
* Description of the PERSONA command
|
|
3660
|
-
*/
|
|
3661
|
-
description: "Persona command is used to specify who the system is, it will be transformed into system message, top_t,...",
|
|
3662
|
-
/**
|
|
3663
|
-
* Link to discussion
|
|
3664
|
-
*/
|
|
3665
|
-
discussionUrl: 'https://github.com/webgptorg/promptbook/discussions/22',
|
|
3666
|
-
/**
|
|
3667
|
-
* Example usages of the PERSONA command
|
|
3668
|
-
*/
|
|
3669
|
-
examples: ['PERSONA Jane, skilled copywriter', 'PERSONA Joe, male 28 years old, programmer'],
|
|
3670
|
-
/**
|
|
3671
|
-
* Parses the PERSONA command
|
|
3672
|
-
*/
|
|
3673
|
-
parse: function (input) {
|
|
3674
|
-
var rawArgs = input.rawArgs;
|
|
3675
|
-
var _a = __read(rawArgs.split(/[,;:]/, 2), 2), personaNameRaw = _a[0], personaDescriptionRaw = _a[1];
|
|
3676
|
-
var personaName = (personaNameRaw || '').trim();
|
|
3677
|
-
if (personaName === '') {
|
|
3678
|
-
throw new ParsingError("You must set name for the persona");
|
|
3679
|
-
}
|
|
3680
|
-
var personaDescription = (personaDescriptionRaw || '').trim();
|
|
3681
|
-
if (personaDescription === '') {
|
|
3682
|
-
personaDescription = null;
|
|
3683
|
-
}
|
|
3684
|
-
return {
|
|
3685
|
-
type: 'PERSONA',
|
|
3686
|
-
personaName: personaName,
|
|
3687
|
-
personaDescription: personaDescription,
|
|
3688
|
-
};
|
|
3689
|
-
},
|
|
3690
|
-
};
|
|
3691
|
-
|
|
3692
3768
|
function isValidJavascriptName(javascriptName) {
|
|
3693
3769
|
if (typeof javascriptName !== 'string') {
|
|
3694
3770
|
return false;
|
|
@@ -3875,22 +3951,6 @@ var urlCommandParser = {
|
|
|
3875
3951
|
},
|
|
3876
3952
|
};
|
|
3877
3953
|
|
|
3878
|
-
/**
|
|
3879
|
-
* Returns the same value that is passed as argument.
|
|
3880
|
-
* No side effects.
|
|
3881
|
-
*
|
|
3882
|
-
* Note: It can be usefull for leveling indentation
|
|
3883
|
-
*
|
|
3884
|
-
* @param value any values
|
|
3885
|
-
* @returns the same values
|
|
3886
|
-
*/
|
|
3887
|
-
function just(value) {
|
|
3888
|
-
if (value === undefined) {
|
|
3889
|
-
return undefined;
|
|
3890
|
-
}
|
|
3891
|
-
return value;
|
|
3892
|
-
}
|
|
3893
|
-
|
|
3894
3954
|
/**
|
|
3895
3955
|
* Parses the action command
|
|
3896
3956
|
*
|
|
@@ -3922,7 +3982,8 @@ var actionCommandParser = {
|
|
|
3922
3982
|
* Parses the ACTION command
|
|
3923
3983
|
*/
|
|
3924
3984
|
parse: function (input) {
|
|
3925
|
-
input.args;
|
|
3985
|
+
var args = input.args;
|
|
3986
|
+
TODO_USE(args);
|
|
3926
3987
|
return {
|
|
3927
3988
|
type: 'ACTION',
|
|
3928
3989
|
};
|
|
@@ -3960,7 +4021,8 @@ var instrumentCommandParser = {
|
|
|
3960
4021
|
* Parses the INSTRUMENT command
|
|
3961
4022
|
*/
|
|
3962
4023
|
parse: function (input) {
|
|
3963
|
-
input.args;
|
|
4024
|
+
var args = input.args;
|
|
4025
|
+
TODO_USE(args);
|
|
3964
4026
|
return {
|
|
3965
4027
|
type: 'INSTRUMENT',
|
|
3966
4028
|
};
|
|
@@ -4142,7 +4204,6 @@ function parseCommandVariant(input) {
|
|
|
4142
4204
|
var _loop_1 = function (commandParser) {
|
|
4143
4205
|
var name_1 = commandParser.name, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
|
|
4144
4206
|
var names = __spreadArray(__spreadArray([name_1], __read((aliasNames || [])), false), __read((deprecatedNames || [])), false);
|
|
4145
|
-
// console.log('!!!', { commandName, names });
|
|
4146
4207
|
if (names.includes(commandName)) {
|
|
4147
4208
|
try {
|
|
4148
4209
|
return { value: parse({ usagePlace: usagePlace, raw: raw, rawArgs: rawArgs, normalized: normalized, args: args }) };
|
|
@@ -4252,25 +4313,42 @@ function extractAllBlocksFromMarkdown(markdown) {
|
|
|
4252
4313
|
var e_1, _a;
|
|
4253
4314
|
var codeBlocks = [];
|
|
4254
4315
|
var lines = markdown.split('\n');
|
|
4316
|
+
// Note: [0] Ensure that the last block notated by gt > will be closed
|
|
4317
|
+
lines.push('');
|
|
4255
4318
|
var currentCodeBlock = null;
|
|
4256
4319
|
try {
|
|
4257
4320
|
for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
|
|
4258
4321
|
var line = lines_1_1.value;
|
|
4322
|
+
if (line.startsWith('> ') || line === '>') {
|
|
4323
|
+
if (currentCodeBlock === null) {
|
|
4324
|
+
currentCodeBlock = { blockNotation: '>', language: null, content: '' };
|
|
4325
|
+
} /* not else */
|
|
4326
|
+
if (currentCodeBlock.blockNotation === '>') {
|
|
4327
|
+
if (currentCodeBlock.content !== '') {
|
|
4328
|
+
currentCodeBlock.content += '\n';
|
|
4329
|
+
}
|
|
4330
|
+
currentCodeBlock.content += line.slice(2);
|
|
4331
|
+
}
|
|
4332
|
+
}
|
|
4333
|
+
else if (currentCodeBlock !== null && currentCodeBlock.blockNotation === '>' /* <- Note: [0] */) {
|
|
4334
|
+
codeBlocks.push(currentCodeBlock);
|
|
4335
|
+
currentCodeBlock = null;
|
|
4336
|
+
}
|
|
4337
|
+
/* not else */
|
|
4259
4338
|
if (line.startsWith('```')) {
|
|
4260
4339
|
var language = line.slice(3).trim() || null;
|
|
4261
4340
|
if (currentCodeBlock === null) {
|
|
4262
|
-
currentCodeBlock = { language: language, content: '' };
|
|
4341
|
+
currentCodeBlock = { blockNotation: '```', language: language, content: '' };
|
|
4263
4342
|
}
|
|
4264
4343
|
else {
|
|
4265
4344
|
if (language !== null) {
|
|
4266
|
-
|
|
4267
|
-
throw new Error("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed and already opening new ").concat(language, " code block"));
|
|
4345
|
+
throw new ParsingError("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed and already opening new ").concat(language, " code block"));
|
|
4268
4346
|
}
|
|
4269
4347
|
codeBlocks.push(currentCodeBlock);
|
|
4270
4348
|
currentCodeBlock = null;
|
|
4271
4349
|
}
|
|
4272
4350
|
}
|
|
4273
|
-
else if (currentCodeBlock !== null) {
|
|
4351
|
+
else if (currentCodeBlock !== null && currentCodeBlock.blockNotation === '```') {
|
|
4274
4352
|
if (currentCodeBlock.content !== '') {
|
|
4275
4353
|
currentCodeBlock.content += '\n';
|
|
4276
4354
|
}
|
|
@@ -4286,11 +4364,13 @@ function extractAllBlocksFromMarkdown(markdown) {
|
|
|
4286
4364
|
finally { if (e_1) throw e_1.error; }
|
|
4287
4365
|
}
|
|
4288
4366
|
if (currentCodeBlock !== null) {
|
|
4289
|
-
|
|
4290
|
-
throw new Error("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed at the end of the markdown"));
|
|
4367
|
+
throw new ParsingError("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed at the end of the markdown"));
|
|
4291
4368
|
}
|
|
4292
4369
|
return codeBlocks;
|
|
4293
4370
|
}
|
|
4371
|
+
/**
|
|
4372
|
+
* TODO: Maybe name for `blockNotation` instead of '```' and '>'
|
|
4373
|
+
*/
|
|
4294
4374
|
|
|
4295
4375
|
/**
|
|
4296
4376
|
* Extracts exactly ONE code block from markdown.
|
|
@@ -4308,13 +4388,12 @@ function extractAllBlocksFromMarkdown(markdown) {
|
|
|
4308
4388
|
function extractOneBlockFromMarkdown(markdown) {
|
|
4309
4389
|
var codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
4310
4390
|
if (codeBlocks.length !== 1) {
|
|
4311
|
-
|
|
4312
|
-
throw new Error(/* <- [🌻] */ 'There should be exactly one code block in the markdown');
|
|
4391
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n There should be exactly 1 code block, found ".concat(codeBlocks.length, " code blocks\n\n ").concat(block(codeBlocks.map(function (block, i) { return "Block ".concat(i + 1, ":\n").concat(block.content); }).join('\n\n\n')), "\n "); }));
|
|
4313
4392
|
}
|
|
4314
4393
|
return codeBlocks[0];
|
|
4315
4394
|
}
|
|
4316
4395
|
/***
|
|
4317
|
-
* TODO: [🍓][🌻]
|
|
4396
|
+
* TODO: [🍓][🌻] Decide of this is internal util, external util OR validator/postprocessor
|
|
4318
4397
|
*/
|
|
4319
4398
|
|
|
4320
4399
|
/**
|
|
@@ -4324,13 +4403,13 @@ function parseMarkdownSection(value) {
|
|
|
4324
4403
|
var _a, _b;
|
|
4325
4404
|
var lines = value.split('\n');
|
|
4326
4405
|
if (!lines[0].startsWith('#')) {
|
|
4327
|
-
throw new
|
|
4406
|
+
throw new ParsingError('Markdown section must start with heading');
|
|
4328
4407
|
}
|
|
4329
4408
|
var title = lines[0].replace(/^#+\s*/, '');
|
|
4330
4409
|
var level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
|
|
4331
4410
|
var content = spaceTrim(lines.slice(1).join('\n'));
|
|
4332
4411
|
if (level < 1 || level > 6) {
|
|
4333
|
-
throw new
|
|
4412
|
+
throw new ParsingError('Markdown section must have heading level between 1 and 6');
|
|
4334
4413
|
}
|
|
4335
4414
|
return { title: title, level: level, content: content };
|
|
4336
4415
|
}
|
|
@@ -4712,7 +4791,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
4712
4791
|
existingParameter.description &&
|
|
4713
4792
|
existingParameter.description !== parameterDescription &&
|
|
4714
4793
|
parameterDescription) {
|
|
4715
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description
|
|
4794
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
|
|
4716
4795
|
}
|
|
4717
4796
|
if (existingParameter) {
|
|
4718
4797
|
if (parameterDescription) {
|
|
@@ -4731,11 +4810,12 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
4731
4810
|
// =============================================================
|
|
4732
4811
|
// Note: 3️⃣ Process pipeline head
|
|
4733
4812
|
pipelineJson.title = pipelineHead.title;
|
|
4734
|
-
// TODO: [1] DRY description
|
|
4813
|
+
// TODO: [🎾][1] DRY description
|
|
4735
4814
|
var description = pipelineHead.content;
|
|
4736
|
-
// Note: Remove codeblocks - TODO:
|
|
4815
|
+
// Note: Remove codeblocks - TODO: [🎾] Make util removeAllBlocksFromMarkdown (exported from `@promptbool/utils`)
|
|
4737
4816
|
description = description.split(/^```.*^```/gms).join('');
|
|
4738
|
-
|
|
4817
|
+
description = description.split(/^>.*$/gm).join('');
|
|
4818
|
+
//Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
|
|
4739
4819
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
4740
4820
|
description = spaceTrim$1(description);
|
|
4741
4821
|
if (description === '') {
|
|
@@ -4763,7 +4843,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
4763
4843
|
pipelineJson.pipelineUrl = command.pipelineUrl.href;
|
|
4764
4844
|
break;
|
|
4765
4845
|
case 'KNOWLEDGE':
|
|
4766
|
-
|
|
4846
|
+
knowledgeCommandParser.applyToPipelineJson(pipelineJson, command);
|
|
4767
4847
|
break;
|
|
4768
4848
|
case 'ACTION':
|
|
4769
4849
|
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
@@ -4772,7 +4852,8 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
4772
4852
|
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
4773
4853
|
break;
|
|
4774
4854
|
case 'PERSONA':
|
|
4775
|
-
|
|
4855
|
+
personaCommandParser.applyToPipelineJson(pipelineJson, command);
|
|
4856
|
+
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
4776
4857
|
break;
|
|
4777
4858
|
case 'BOILERPLATE':
|
|
4778
4859
|
throw new ParsingError('BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file'); // <- TODO: [🚞]
|
|
@@ -4801,7 +4882,27 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
4801
4882
|
var postprocessing = [];
|
|
4802
4883
|
var expectAmount = {};
|
|
4803
4884
|
var expectFormat = undefined;
|
|
4804
|
-
var
|
|
4885
|
+
var isBlockTypeSet = false;
|
|
4886
|
+
var lastLine = section.content.split('\n').pop();
|
|
4887
|
+
var resultingParameterNameMatch = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
|
|
4888
|
+
var resultingParameterName = null;
|
|
4889
|
+
if (resultingParameterNameMatch &&
|
|
4890
|
+
resultingParameterNameMatch.groups !== undefined &&
|
|
4891
|
+
resultingParameterNameMatch.groups.resultingParamName !== undefined) {
|
|
4892
|
+
resultingParameterName = resultingParameterNameMatch.groups.resultingParamName;
|
|
4893
|
+
}
|
|
4894
|
+
var expectResultingParameterName = function () {
|
|
4895
|
+
if (resultingParameterName !== null) {
|
|
4896
|
+
return resultingParameterName;
|
|
4897
|
+
}
|
|
4898
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Template section must end with -> {parameterName}\n\n Invalid section:\n ".concat(block(
|
|
4899
|
+
// TODO: Show code of invalid sections each time + DRY
|
|
4900
|
+
section.content
|
|
4901
|
+
.split('\n')
|
|
4902
|
+
.map(function (line) { return " | ".concat(line); } /* <- TODO: [🚞] */)
|
|
4903
|
+
.join('\n')), "\n "); }));
|
|
4904
|
+
};
|
|
4905
|
+
var _e = extractOneBlockFromMarkdown(section.content), language = _e.language, content = _e.content;
|
|
4805
4906
|
try {
|
|
4806
4907
|
for (var listItems_2 = (e_3 = void 0, __values(listItems_3)), listItems_2_1 = listItems_2.next(); !listItems_2_1.done; listItems_2_1 = listItems_2.next()) {
|
|
4807
4908
|
var listItem = listItems_2_1.value;
|
|
@@ -4809,15 +4910,24 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
4809
4910
|
switch (command.type) {
|
|
4810
4911
|
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
4811
4912
|
case 'BLOCK':
|
|
4812
|
-
if (
|
|
4913
|
+
if (isBlockTypeSet) {
|
|
4813
4914
|
throw new ParsingError('Block type is already defined in the prompt template. It can be defined only once.');
|
|
4814
4915
|
}
|
|
4815
4916
|
if (command.blockType === 'SAMPLE') {
|
|
4816
|
-
|
|
4917
|
+
expectResultingParameterName();
|
|
4918
|
+
var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
|
|
4919
|
+
if (parameter === undefined) {
|
|
4920
|
+
throw new UnexpectedError("Can not find parameter {".concat(resultingParameterName, "} to assign sample value"));
|
|
4921
|
+
}
|
|
4922
|
+
parameter.sampleValues = parameter.sampleValues || [];
|
|
4923
|
+
parameter.sampleValues.push(content);
|
|
4817
4924
|
return "continue-templates";
|
|
4818
4925
|
}
|
|
4819
4926
|
if (command.blockType === 'KNOWLEDGE') {
|
|
4820
|
-
|
|
4927
|
+
knowledgeCommandParser.applyToPipelineJson(pipelineJson, {
|
|
4928
|
+
type: 'KNOWLEDGE',
|
|
4929
|
+
source: content, // <- TODO: !!!! Working KNOWLEDGE which not referring to the source file/wweb, but its content itseld
|
|
4930
|
+
});
|
|
4821
4931
|
return "continue-templates";
|
|
4822
4932
|
}
|
|
4823
4933
|
if (command.blockType === 'ACTION') {
|
|
@@ -4828,8 +4938,9 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
4828
4938
|
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
4829
4939
|
return "continue-templates";
|
|
4830
4940
|
}
|
|
4941
|
+
expectResultingParameterName();
|
|
4831
4942
|
blockType = command.blockType;
|
|
4832
|
-
|
|
4943
|
+
isBlockTypeSet = true;
|
|
4833
4944
|
break;
|
|
4834
4945
|
case 'EXPECT_AMOUNT':
|
|
4835
4946
|
// eslint-disable-next-line no-case-declarations
|
|
@@ -4869,16 +4980,20 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
4869
4980
|
postprocessing.push(command.functionName);
|
|
4870
4981
|
break;
|
|
4871
4982
|
case 'KNOWLEDGE':
|
|
4872
|
-
|
|
4983
|
+
// TODO: [👙] The knowledge is maybe relevant for just this template
|
|
4984
|
+
knowledgeCommandParser.applyToPipelineJson(pipelineJson, command);
|
|
4873
4985
|
break;
|
|
4874
4986
|
case 'ACTION':
|
|
4987
|
+
// TODO: [👙] The action is maybe relevant for just this template
|
|
4875
4988
|
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
4876
4989
|
break;
|
|
4877
4990
|
case 'INSTRUMENT':
|
|
4991
|
+
// TODO: [👙] The instrument is maybe relevant for just this template
|
|
4878
4992
|
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
4879
4993
|
break;
|
|
4880
4994
|
case 'PERSONA':
|
|
4881
|
-
|
|
4995
|
+
personaCommandParser.applyToPipelineJson(pipelineJson, command);
|
|
4996
|
+
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
4882
4997
|
break;
|
|
4883
4998
|
case 'BOILERPLATE':
|
|
4884
4999
|
console.error(new ParsingError('BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file'));
|
|
@@ -4896,7 +5011,6 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
4896
5011
|
}
|
|
4897
5012
|
finally { if (e_3) throw e_3.error; }
|
|
4898
5013
|
}
|
|
4899
|
-
var _e = extractOneBlockFromMarkdown(section.content), language = _e.language, content = _e.content;
|
|
4900
5014
|
if (blockType === 'SCRIPT') {
|
|
4901
5015
|
if (!language) {
|
|
4902
5016
|
throw new ParsingError('You must specify the language of the script in the prompt template');
|
|
@@ -4905,22 +5019,12 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
4905
5019
|
throw new ParsingError(spaceTrim$1(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
|
|
4906
5020
|
}
|
|
4907
5021
|
}
|
|
4908
|
-
|
|
4909
|
-
var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
|
|
4910
|
-
if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
|
|
4911
|
-
throw new ParsingError(spaceTrim$1(function (block) { return "\n Each section must end with -> {parameterName}\n\n Invalid section:\n ".concat(block(
|
|
4912
|
-
// TODO: Show code of invalid sections each time + DRY
|
|
4913
|
-
section.content
|
|
4914
|
-
.split('\n')
|
|
4915
|
-
.map(function (line) { return " | ".concat(line); } /* <- TODO: [🚞] */)
|
|
4916
|
-
.join('\n')), "\n "); }));
|
|
4917
|
-
}
|
|
4918
|
-
var resultingParameterName = match.groups.resultingParamName;
|
|
4919
|
-
// TODO: [1] DRY description
|
|
5022
|
+
// TODO: [🎾][1] DRY description
|
|
4920
5023
|
var description_1 = section.content;
|
|
4921
|
-
// Note: Remove codeblocks
|
|
5024
|
+
// Note: Remove codeblocks - TODO: [🎾]
|
|
4922
5025
|
description_1 = description_1.split(/^```.*^```/gms).join('');
|
|
4923
|
-
|
|
5026
|
+
description_1 = description_1.split(/^>.*$/gm).join('');
|
|
5027
|
+
//Note: Remove lists and return statement - TODO: [🎾]
|
|
4924
5028
|
description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
4925
5029
|
description_1 = spaceTrim$1(description_1);
|
|
4926
5030
|
if (description_1 === '') {
|
|
@@ -4954,7 +5058,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
4954
5058
|
modelRequirements: templateModelRequirements,
|
|
4955
5059
|
contentLanguage: blockType === 'SCRIPT' ? language : undefined,
|
|
4956
5060
|
content: content,
|
|
4957
|
-
resultingParameterName:
|
|
5061
|
+
resultingParameterName: expectResultingParameterName( /* <- Note: This is once more redundant */),
|
|
4958
5062
|
};
|
|
4959
5063
|
if (blockType !== 'PROMPT_TEMPLATE') {
|
|
4960
5064
|
delete template.modelRequirements;
|
|
@@ -5027,6 +5131,8 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5027
5131
|
* TODO: Use spaceTrim more effectively
|
|
5028
5132
|
* TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
|
|
5029
5133
|
* TODO: [🥞] Not optimal parsing because `splitMarkdownIntoSections` is executed twice with same string, once through `flattenMarkdown` and second directly here
|
|
5134
|
+
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
5135
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
5030
5136
|
*/
|
|
5031
5137
|
|
|
5032
5138
|
/**
|
|
@@ -5066,6 +5172,7 @@ function pipelineStringToJson(pipelineString, options) {
|
|
|
5066
5172
|
}
|
|
5067
5173
|
/**
|
|
5068
5174
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
5175
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
5069
5176
|
*/
|
|
5070
5177
|
|
|
5071
5178
|
/**
|
|
@@ -5083,7 +5190,10 @@ function addAutoGeneratedSection(content, options) {
|
|
|
5083
5190
|
}
|
|
5084
5191
|
var placeForSection = removeContentComments(content).match(/^##.*$/im);
|
|
5085
5192
|
if (!placeForSection) {
|
|
5086
|
-
throw new
|
|
5193
|
+
throw new ParsingError(
|
|
5194
|
+
// <- [🧠] Maybe something better than `ParsingError`
|
|
5195
|
+
"No place where to put the section <!--".concat(sectionName, "-->"));
|
|
5196
|
+
// <- [🚞]
|
|
5087
5197
|
}
|
|
5088
5198
|
var _a = __read(placeForSection, 1), heading = _a[0];
|
|
5089
5199
|
return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
|
|
@@ -5257,15 +5367,15 @@ var CollectionError = /** @class */ (function (_super) {
|
|
|
5257
5367
|
/**
|
|
5258
5368
|
* This error type indicates that the version of the pipeline is not matching the expected version
|
|
5259
5369
|
*/
|
|
5260
|
-
var
|
|
5261
|
-
__extends(
|
|
5262
|
-
function
|
|
5370
|
+
var VersionMismatchError = /** @class */ (function (_super) {
|
|
5371
|
+
__extends(VersionMismatchError, _super);
|
|
5372
|
+
function VersionMismatchError(message, expectedVersion) {
|
|
5263
5373
|
var _this = _super.call(this, spaceTrim$1(function (block) { return "\n ".concat(block(message), "\n\n This error indicates that there is error with compatibility\n\n Expected version:\n ").concat(expectedVersion, "\n\n Current version:\n ").concat(PROMPTBOOK_VERSION, "\n\n "); })) || this;
|
|
5264
5374
|
_this.name = 'UnexpectedError';
|
|
5265
|
-
Object.setPrototypeOf(_this,
|
|
5375
|
+
Object.setPrototypeOf(_this, VersionMismatchError.prototype);
|
|
5266
5376
|
return _this;
|
|
5267
5377
|
}
|
|
5268
|
-
return
|
|
5378
|
+
return VersionMismatchError;
|
|
5269
5379
|
}(Error));
|
|
5270
5380
|
|
|
5271
5381
|
/**
|
|
@@ -5469,6 +5579,22 @@ function escapeMarkdownBlock(value) {
|
|
|
5469
5579
|
return value.replace(/```/g, '\\`\\`\\`');
|
|
5470
5580
|
}
|
|
5471
5581
|
|
|
5582
|
+
/**
|
|
5583
|
+
* Returns the same value that is passed as argument.
|
|
5584
|
+
* No side effects.
|
|
5585
|
+
*
|
|
5586
|
+
* Note: It can be usefull for leveling indentation
|
|
5587
|
+
*
|
|
5588
|
+
* @param value any values
|
|
5589
|
+
* @returns the same values
|
|
5590
|
+
*/
|
|
5591
|
+
function just(value) {
|
|
5592
|
+
if (value === undefined) {
|
|
5593
|
+
return undefined;
|
|
5594
|
+
}
|
|
5595
|
+
return value;
|
|
5596
|
+
}
|
|
5597
|
+
|
|
5472
5598
|
/**
|
|
5473
5599
|
* The thresholds for the relative time in the `moment` NPM package.
|
|
5474
5600
|
*
|
|
@@ -5679,5 +5805,5 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
5679
5805
|
* TODO: [🧠] Allow to filter out some parts of the report by options
|
|
5680
5806
|
*/
|
|
5681
5807
|
|
|
5682
|
-
export { BlockTypes, CallbackInterfaceTools, CollectionError, ExecutionReportStringOptionsDefaults, ExpectError, NotFoundError, PROMPTBOOK_VERSION, ParsingError, PipelineExecutionError, PipelineLogicError, RESERVED_PARAMETER_NAMES, ReferenceError$1 as ReferenceError, SimplePromptInterfaceTools, UnexpectedError,
|
|
5808
|
+
export { BlockTypes, CallbackInterfaceTools, CollectionError, ExecutionReportStringOptionsDefaults, ExpectError, NotFoundError, PROMPTBOOK_VERSION, ParsingError, PipelineExecutionError, PipelineLogicError, RESERVED_PARAMETER_NAMES, ReferenceError$1 as ReferenceError, SimplePromptInterfaceTools, UnexpectedError, VersionMismatchError, addUsage, assertsExecutionSuccessful, checkExpectations, collectionToJson, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, joinLlmExecutionTools, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgeFromMarkdown, preparePipeline, prettifyPipelineString, unpreparePipeline, usageToWorktime, validatePipeline };
|
|
5683
5809
|
//# sourceMappingURL=index.es.js.map
|