@promptbook/core 0.69.0-1 → 0.69.0-2
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 +89 -30
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +2 -6
- package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +26 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -4
- package/esm/typings/src/config.d.ts +7 -1
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -0
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +1 -1
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +4 -0
- package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +1 -0
- package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +5 -0
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +3 -0
- package/package.json +1 -1
- package/umd/index.umd.js +89 -30
- package/umd/index.umd.js.map +1 -1
|
@@ -7,6 +7,7 @@ import type { PipelineTemplateCommandParser } from '../commands/_common/types/Co
|
|
|
7
7
|
import type { CommandParserInput } from '../commands/_common/types/CommandParser';
|
|
8
8
|
import type { CommandUsagePlace } from '../commands/_common/types/CommandUsagePlaces';
|
|
9
9
|
import type { ExpectCommand } from '../commands/EXPECT/ExpectCommand';
|
|
10
|
+
import type { ForeachJson } from '../commands/FOREACH/ForeachJson';
|
|
10
11
|
import type { FormatCommand } from '../commands/FORMAT/FormatCommand';
|
|
11
12
|
import type { TemplateType } from '../commands/TEMPLATE/TemplateTypes';
|
|
12
13
|
import type { PipelineStringToJsonOptions } from '../conversion/pipelineStringToJson';
|
|
@@ -232,6 +233,7 @@ export type { PipelineTemplateCommandParser };
|
|
|
232
233
|
export type { CommandParserInput };
|
|
233
234
|
export type { CommandUsagePlace };
|
|
234
235
|
export type { ExpectCommand };
|
|
236
|
+
export type { ForeachJson };
|
|
235
237
|
export type { FormatCommand };
|
|
236
238
|
export type { TemplateType };
|
|
237
239
|
export type { PipelineStringToJsonOptions };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { TODO_string } from '../../utils/organization/TODO_string';
|
|
1
|
+
import type { ForeachJson } from './ForeachJson';
|
|
3
2
|
/**
|
|
4
3
|
* Parsed FOREACH command <- Write [🍭] !!!!!!
|
|
5
4
|
*
|
|
@@ -8,7 +7,4 @@ import type { TODO_string } from '../../utils/organization/TODO_string';
|
|
|
8
7
|
*/
|
|
9
8
|
export type ForeachCommand = {
|
|
10
9
|
readonly type: 'FOREACH';
|
|
11
|
-
|
|
12
|
-
cellName: TODO_string;
|
|
13
|
-
parameterName: string_parameter_name;
|
|
14
|
-
};
|
|
10
|
+
} & ForeachJson;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { string_parameter_name } from '../../types/typeAliases';
|
|
2
|
+
import type { TODO_string } from '../../utils/organization/TODO_string';
|
|
3
|
+
/**
|
|
4
|
+
* @@@
|
|
5
|
+
*/
|
|
6
|
+
export type ForeachJson = {
|
|
7
|
+
/**
|
|
8
|
+
* @@@
|
|
9
|
+
*/
|
|
10
|
+
readonly formatName: TODO_string;
|
|
11
|
+
/**
|
|
12
|
+
* @@@
|
|
13
|
+
*/
|
|
14
|
+
readonly cellName: TODO_string;
|
|
15
|
+
/**
|
|
16
|
+
* @@@
|
|
17
|
+
*/
|
|
18
|
+
readonly parameterName: string_parameter_name;
|
|
19
|
+
/**
|
|
20
|
+
* @@@
|
|
21
|
+
*/
|
|
22
|
+
readonly subparameterName: string_parameter_name;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* TODO: [🧠] Betetr name for `parameterName` and `subparameterName`
|
|
26
|
+
*/
|
|
@@ -156,28 +156,28 @@ export type CommandParserInput = {
|
|
|
156
156
|
* @@@
|
|
157
157
|
*
|
|
158
158
|
* @example 'promptbook version 0.62.0'
|
|
159
|
-
* @example 'FOREACH List Line -> `{customer}`'
|
|
159
|
+
* @example 'FOREACH List Line `{customers}` -> `{customer}`'
|
|
160
160
|
*/
|
|
161
161
|
readonly raw: string_markdown_text;
|
|
162
162
|
/**
|
|
163
163
|
* @@@
|
|
164
164
|
*
|
|
165
165
|
* @example '0.62.0'
|
|
166
|
-
* @example 'List Line -> `{customer}`'
|
|
166
|
+
* @example 'List Line `{customers}` -> `{customer}`'
|
|
167
167
|
*/
|
|
168
168
|
readonly rawArgs: string_markdown_text;
|
|
169
169
|
/**
|
|
170
170
|
* @@@
|
|
171
171
|
*
|
|
172
172
|
* @example 'PROMPTBOOK_VERSION_0_62_0'
|
|
173
|
-
* @example '
|
|
173
|
+
* @example 'FOREACH_LIST_LINE_CUSTOMERS_CUSTOMER'
|
|
174
174
|
*/
|
|
175
175
|
readonly normalized: string_name & string_SCREAMING_CASE;
|
|
176
176
|
/**
|
|
177
177
|
* @@@
|
|
178
178
|
*
|
|
179
179
|
* @example [ '0.62.0' ]
|
|
180
|
-
* @example [ 'List', 'Line', '', '{customer}' ]
|
|
180
|
+
* @example [ 'List', 'Line', '{customers}', '', '{customer}' ]
|
|
181
181
|
*/
|
|
182
182
|
readonly args: Array<string_name>;
|
|
183
183
|
};
|
|
@@ -148,7 +148,13 @@ export declare const IS_VERBOSE = false;
|
|
|
148
148
|
*
|
|
149
149
|
* @private within the repository
|
|
150
150
|
*/
|
|
151
|
-
export declare const
|
|
151
|
+
export declare const IS_COST_PREVENTED: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* @@@
|
|
154
|
+
*
|
|
155
|
+
* @private within the repository
|
|
156
|
+
*/
|
|
157
|
+
export declare const IS_PIPELINE_LOGIC_VALIDATED: boolean;
|
|
152
158
|
/**
|
|
153
159
|
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
154
160
|
*/
|
|
@@ -22,6 +22,9 @@ export type renderPipelineMermaidOptions = {
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function renderPromptbookMermaid(pipelineJson: PipelineJson, options?: renderPipelineMermaidOptions): string;
|
|
24
24
|
/**
|
|
25
|
+
* TODO: !!!!!! FOREACH in mermaid graph
|
|
26
|
+
* TODO: !!!!!! Knowledge in mermaid graph
|
|
27
|
+
* TODO: !!!!!! Personas in mermaid graph
|
|
25
28
|
* TODO: Maybe use some Mermaid package instead of string templating
|
|
26
29
|
* TODO: [🕌] When more than 2 functionalities, split into separate functions
|
|
27
30
|
*/
|
|
@@ -8,7 +8,7 @@ import type { string_parameter_name } from '../../types/typeAliases';
|
|
|
8
8
|
* @throws {ParseError} if the script is invalid
|
|
9
9
|
* @public exported from `@promptbook/utils`
|
|
10
10
|
*/
|
|
11
|
-
export declare function extractParameterNamesFromTemplate(template: Pick<TemplateJson, 'title' | 'description' | 'templateType' | 'content' | 'preparedContent' | 'jokerParameterNames'>): Set<string_parameter_name>;
|
|
11
|
+
export declare function extractParameterNamesFromTemplate(template: Pick<TemplateJson, 'title' | 'description' | 'templateType' | 'content' | 'preparedContent' | 'jokerParameterNames' | 'foreach'>): Set<string_parameter_name>;
|
|
12
12
|
/**
|
|
13
13
|
* TODO: [🔣] If script require contentLanguage
|
|
14
14
|
*/
|
|
@@ -15,6 +15,10 @@ import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
|
|
|
15
15
|
* @public exported from `@promptbook/core`
|
|
16
16
|
*/
|
|
17
17
|
export declare function validatePipeline(pipeline: PipelineJson): PipelineJson;
|
|
18
|
+
/**
|
|
19
|
+
* @private internal function for `validatePipeline`
|
|
20
|
+
*/
|
|
21
|
+
export declare function validatePipelineCore(pipeline: PipelineJson): void;
|
|
18
22
|
/**
|
|
19
23
|
* TODO: [🧠] Work with promptbookVersion
|
|
20
24
|
* TODO: Use here some json-schema, Zod or something similar and change it to:
|
|
@@ -33,6 +33,7 @@ export type ParameterJson = {
|
|
|
33
33
|
readonly sampleValues?: Array<string_parameter_value>;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
|
+
* TODO: [🧠] !!!!!! Should be here registered subparameter from foreach or not?
|
|
36
37
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
37
38
|
* TODO: [🍙] Make some standard order of json properties
|
|
38
39
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ForeachJson } from '../../commands/FOREACH/ForeachJson';
|
|
1
2
|
import type { FormatCommand } from '../../commands/FORMAT/FormatCommand';
|
|
2
3
|
import type { TemplateType } from '../../commands/TEMPLATE/TemplateTypes';
|
|
3
4
|
import type { string_javascript } from '../typeAliases';
|
|
@@ -42,6 +43,10 @@ export interface TemplateJsonCommon {
|
|
|
42
43
|
* @see https://github.com/webgptorg/promptbook/discussions/66
|
|
43
44
|
*/
|
|
44
45
|
readonly jokerParameterNames?: Array<string_parameter_name>;
|
|
46
|
+
/**
|
|
47
|
+
* @@@
|
|
48
|
+
*/
|
|
49
|
+
readonly foreach?: ForeachJson;
|
|
45
50
|
/**
|
|
46
51
|
* Type of the execution
|
|
47
52
|
* This determines if the template is send to LLM, user or some scripting evaluation
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
/**
|
|
17
17
|
* The version of the Promptbook library
|
|
18
18
|
*/
|
|
19
|
-
var PROMPTBOOK_VERSION = '0.69.0-
|
|
19
|
+
var PROMPTBOOK_VERSION = '0.69.0-1';
|
|
20
20
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
21
21
|
|
|
22
22
|
/*! *****************************************************************************
|
|
@@ -758,6 +758,15 @@
|
|
|
758
758
|
* @public exported from `@promptbook/core`
|
|
759
759
|
*/
|
|
760
760
|
var IS_VERBOSE = false;
|
|
761
|
+
/**
|
|
762
|
+
* @@@
|
|
763
|
+
*
|
|
764
|
+
* @private within the repository
|
|
765
|
+
*/
|
|
766
|
+
var IS_PIPELINE_LOGIC_VALIDATED = just(
|
|
767
|
+
/**/
|
|
768
|
+
// Note: In normal situations, we check the pipeline logic:
|
|
769
|
+
true);
|
|
761
770
|
/**
|
|
762
771
|
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
763
772
|
*/
|
|
@@ -967,6 +976,26 @@
|
|
|
967
976
|
* @public exported from `@promptbook/core`
|
|
968
977
|
*/
|
|
969
978
|
function validatePipeline(pipeline) {
|
|
979
|
+
if (IS_PIPELINE_LOGIC_VALIDATED) {
|
|
980
|
+
validatePipelineCore(pipeline);
|
|
981
|
+
}
|
|
982
|
+
else {
|
|
983
|
+
try {
|
|
984
|
+
validatePipelineCore(pipeline);
|
|
985
|
+
}
|
|
986
|
+
catch (error) {
|
|
987
|
+
if (!(error instanceof PipelineLogicError)) {
|
|
988
|
+
throw error;
|
|
989
|
+
}
|
|
990
|
+
console.error(spaceTrim.spaceTrim(function (block) { return "\n Pipeline is not valid but logic errors are temporarily disabled via `IS_PIPELINE_LOGIC_VALIDATED`\n\n ".concat(block(error.message), "\n "); }));
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
return pipeline;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* @private internal function for `validatePipeline`
|
|
997
|
+
*/
|
|
998
|
+
function validatePipelineCore(pipeline) {
|
|
970
999
|
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
971
1000
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
972
1001
|
var pipelineIdentification = (function () {
|
|
@@ -1165,7 +1194,6 @@
|
|
|
1165
1194
|
while (unresovedTemplates.length > 0) {
|
|
1166
1195
|
_loop_3();
|
|
1167
1196
|
}
|
|
1168
|
-
return pipeline;
|
|
1169
1197
|
}
|
|
1170
1198
|
/**
|
|
1171
1199
|
* TODO: [🧠] Work with promptbookVersion
|
|
@@ -1794,7 +1822,7 @@
|
|
|
1794
1822
|
});
|
|
1795
1823
|
}
|
|
1796
1824
|
|
|
1797
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.69.0-
|
|
1825
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.69.0-1",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.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.69.0-1",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.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.69.0-1",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.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.69.0-1",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## 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- 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.ptbk.md"}];
|
|
1798
1826
|
|
|
1799
1827
|
var defaultDiacriticsRemovalMap = [
|
|
1800
1828
|
{
|
|
@@ -2381,7 +2409,7 @@
|
|
|
2381
2409
|
*/
|
|
2382
2410
|
function extractParameterNamesFromTemplate(template) {
|
|
2383
2411
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
2384
|
-
var title = template.title, description = template.description, templateType = template.templateType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames;
|
|
2412
|
+
var title = template.title, description = template.description, templateType = template.templateType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames, foreach = template.foreach;
|
|
2385
2413
|
var parameterNames = new Set();
|
|
2386
2414
|
try {
|
|
2387
2415
|
for (var _d = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameterNames(title)), false), __read(extractParameterNames(description || '')), false), __read(extractParameterNames(content)), false), __read(extractParameterNames(preparedContent || '')), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
@@ -2426,6 +2454,14 @@
|
|
|
2426
2454
|
}
|
|
2427
2455
|
parameterNames.delete('content');
|
|
2428
2456
|
// <- Note {websiteContent} is used in `preparedContent`
|
|
2457
|
+
// Note: [🍭] Fixing dependent subparameterName from FOREACH command
|
|
2458
|
+
if (foreach !== undefined) {
|
|
2459
|
+
if (parameterNames.has(foreach.subparameterName)) {
|
|
2460
|
+
parameterNames.delete(foreach.subparameterName);
|
|
2461
|
+
parameterNames.add(foreach.parameterName);
|
|
2462
|
+
// <- TODO: [🚎] Warn/logic error when `subparameterName` not used
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2429
2465
|
return parameterNames;
|
|
2430
2466
|
}
|
|
2431
2467
|
/**
|
|
@@ -3476,6 +3512,7 @@
|
|
|
3476
3512
|
case 0:
|
|
3477
3513
|
isJokerAttempt = attempt < 0;
|
|
3478
3514
|
jokerParameterName = jokerParameterNames[jokerParameterNames.length + attempt];
|
|
3515
|
+
// TODO: [🧠] !!!!!! JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
3479
3516
|
if (isJokerAttempt && !jokerParameterName) {
|
|
3480
3517
|
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3481
3518
|
}
|
|
@@ -3794,6 +3831,19 @@
|
|
|
3794
3831
|
attempt++;
|
|
3795
3832
|
return [3 /*break*/, 4];
|
|
3796
3833
|
case 7:
|
|
3834
|
+
//------------------------------------
|
|
3835
|
+
/*
|
|
3836
|
+
|
|
3837
|
+
|
|
3838
|
+
|
|
3839
|
+
|
|
3840
|
+
|
|
3841
|
+
|
|
3842
|
+
|
|
3843
|
+
|
|
3844
|
+
|
|
3845
|
+
*/
|
|
3846
|
+
//------------------------------------
|
|
3797
3847
|
if (resultString === null) {
|
|
3798
3848
|
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3799
3849
|
}
|
|
@@ -5303,20 +5353,21 @@
|
|
|
5303
5353
|
* Example usages of the FOREACH command
|
|
5304
5354
|
*/
|
|
5305
5355
|
examples: [
|
|
5306
|
-
'FOREACH List Line -> `{customer}`',
|
|
5307
|
-
'FOR List Line -> `{customer}`',
|
|
5308
|
-
'EACH List Line -> `{customer}`',
|
|
5356
|
+
'FOREACH List Line `{customers}` -> `{customer}`',
|
|
5357
|
+
'FOR List Line `{customers}` -> `{customer}`',
|
|
5358
|
+
'EACH List Line `{customers}` -> `{customer}`',
|
|
5309
5359
|
// <- TODO: [🍭] !!!!!! More
|
|
5310
5360
|
],
|
|
5311
5361
|
/**
|
|
5312
5362
|
* Parses the FOREACH command
|
|
5313
5363
|
*/
|
|
5314
5364
|
parse: function (input) {
|
|
5315
|
-
var args = input.args
|
|
5365
|
+
var args = input.args;
|
|
5316
5366
|
var formatName = normalizeTo_SCREAMING_CASE(args[0] || '');
|
|
5317
5367
|
var cellName = normalizeTo_SCREAMING_CASE(args[1] || '');
|
|
5318
|
-
var
|
|
5319
|
-
var
|
|
5368
|
+
var parameterNameWrapped = args[2];
|
|
5369
|
+
var assignSign = args[3];
|
|
5370
|
+
var subparameterNameWrapped = args[4];
|
|
5320
5371
|
if (![
|
|
5321
5372
|
'LIST',
|
|
5322
5373
|
'CSV',
|
|
@@ -5331,7 +5382,7 @@
|
|
|
5331
5382
|
'ROW',
|
|
5332
5383
|
'COLUMN',
|
|
5333
5384
|
'CELL',
|
|
5334
|
-
// <- TODO: [🏢] Unhardcode format
|
|
5385
|
+
// <- TODO: [🏢] Unhardcode format cells
|
|
5335
5386
|
].includes(cellName)) {
|
|
5336
5387
|
console.info({ args: args, cellName: cellName });
|
|
5337
5388
|
throw new Error("Format ".concat(formatName, " does not support cell \"").concat(cellName, "\""));
|
|
@@ -5341,24 +5392,27 @@
|
|
|
5341
5392
|
console.info({ args: args, assignSign: assignSign });
|
|
5342
5393
|
throw new Error("FOREACH command must have '->' to assign the value to the parameter");
|
|
5343
5394
|
}
|
|
5344
|
-
|
|
5345
|
-
if (
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
//
|
|
5352
|
-
) {
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5395
|
+
// TODO: !!!!!! Replace with propper parameter name validation
|
|
5396
|
+
if ((parameterNameWrapped === null || parameterNameWrapped === void 0 ? void 0 : parameterNameWrapped.substring(0, 1)) !== '{' ||
|
|
5397
|
+
(parameterNameWrapped === null || parameterNameWrapped === void 0 ? void 0 : parameterNameWrapped.substring(parameterNameWrapped.length - 1, parameterNameWrapped.length)) !== '}') {
|
|
5398
|
+
console.info({ args: args, parameterNameWrapped: parameterNameWrapped }, parameterNameWrapped === null || parameterNameWrapped === void 0 ? void 0 : parameterNameWrapped.substring(0, 1), parameterNameWrapped === null || parameterNameWrapped === void 0 ? void 0 : parameterNameWrapped.substring(parameterNameWrapped.length - 1, parameterNameWrapped.length));
|
|
5399
|
+
throw new Error("!!!!!! 1 Here will be error (with rules and precise error) from validateParameterName");
|
|
5400
|
+
}
|
|
5401
|
+
var parameterName = parameterNameWrapped.substring(1, parameterNameWrapped.length - 1);
|
|
5402
|
+
// TODO: !!!!!! Replace with propper parameter name validation
|
|
5403
|
+
if ((subparameterNameWrapped === null || subparameterNameWrapped === void 0 ? void 0 : subparameterNameWrapped.substring(0, 1)) !== '{' ||
|
|
5404
|
+
(subparameterNameWrapped === null || subparameterNameWrapped === void 0 ? void 0 : subparameterNameWrapped.substring(subparameterNameWrapped.length - 1, subparameterNameWrapped.length)) !==
|
|
5405
|
+
'}') {
|
|
5406
|
+
console.info({ args: args, subparameterNameWrapped: subparameterNameWrapped });
|
|
5407
|
+
throw new Error("!!!!!! 2 Here will be error (with rules and precise error) from validateParameterName");
|
|
5408
|
+
}
|
|
5409
|
+
var subparameterName = subparameterNameWrapped.substring(1, subparameterNameWrapped.length - 1);
|
|
5357
5410
|
return {
|
|
5358
5411
|
type: 'FOREACH',
|
|
5359
5412
|
formatName: formatName,
|
|
5360
5413
|
cellName: cellName,
|
|
5361
5414
|
parameterName: parameterName,
|
|
5415
|
+
subparameterName: subparameterName,
|
|
5362
5416
|
};
|
|
5363
5417
|
},
|
|
5364
5418
|
/**
|
|
@@ -5367,8 +5421,10 @@
|
|
|
5367
5421
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
5368
5422
|
*/
|
|
5369
5423
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
5370
|
-
|
|
5371
|
-
|
|
5424
|
+
var formatName = command.formatName, cellName = command.cellName, parameterName = command.parameterName, subparameterName = command.subparameterName;
|
|
5425
|
+
$templateJson.foreach = { formatName: formatName, cellName: cellName, parameterName: parameterName, subparameterName: subparameterName };
|
|
5426
|
+
keepUnused($pipelineJson); // <- TODO: !!!!!! BUT Maybe register subparameter from foreach into parameters of the pipeline
|
|
5427
|
+
// Note: [🍭] FOREACH apply has some sideeffects on different places in codebase
|
|
5372
5428
|
},
|
|
5373
5429
|
/**
|
|
5374
5430
|
* Converts the FOREACH command back to string
|
|
@@ -5377,8 +5433,7 @@
|
|
|
5377
5433
|
*/
|
|
5378
5434
|
stringify: function (command) {
|
|
5379
5435
|
keepUnused(command);
|
|
5380
|
-
return "";
|
|
5381
|
-
// <- TODO: [🍭] !!!!!! Implement
|
|
5436
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5382
5437
|
},
|
|
5383
5438
|
/**
|
|
5384
5439
|
* Reads the FOREACH command from the `TemplateJson`
|
|
@@ -5387,8 +5442,7 @@
|
|
|
5387
5442
|
*/
|
|
5388
5443
|
takeFromTemplateJson: function ($templateJson) {
|
|
5389
5444
|
keepUnused($templateJson);
|
|
5390
|
-
|
|
5391
|
-
// <- TODO: [🍭] !!!!!! Implement
|
|
5445
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5392
5446
|
},
|
|
5393
5447
|
};
|
|
5394
5448
|
/**
|
|
@@ -5503,6 +5557,7 @@
|
|
|
5503
5557
|
*/
|
|
5504
5558
|
parse: function (input) {
|
|
5505
5559
|
var args = input.args;
|
|
5560
|
+
// TODO: !!!!!! Replace with propper parameter name validation
|
|
5506
5561
|
var parametersMatch = (args.pop() || '').match(/^\{(?<parameterName>[a-z0-9_]+)\}$/im);
|
|
5507
5562
|
if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
|
|
5508
5563
|
throw new ParseError("Invalid joker");
|
|
@@ -5632,6 +5687,7 @@
|
|
|
5632
5687
|
if ($pipelineJson.defaultModelRequirements[command.key] !== undefined) {
|
|
5633
5688
|
if ($pipelineJson.defaultModelRequirements[command.key] === command.value) {
|
|
5634
5689
|
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the pipeline head"));
|
|
5690
|
+
// <- TODO: [🚎] Some better way how to get warnings from pipeline parsing / logic
|
|
5635
5691
|
}
|
|
5636
5692
|
else {
|
|
5637
5693
|
throw new ParseError(spaceTrim__default["default"]("\n Redefinition of MODEL `".concat(command.key, "` in the pipeline head\n\n You have used:\n - MODEL ").concat(command.key, " ").concat($pipelineJson.defaultModelRequirements[command.key], "\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
|
|
@@ -7387,6 +7443,9 @@
|
|
|
7387
7443
|
return promptbookMermaid;
|
|
7388
7444
|
}
|
|
7389
7445
|
/**
|
|
7446
|
+
* TODO: !!!!!! FOREACH in mermaid graph
|
|
7447
|
+
* TODO: !!!!!! Knowledge in mermaid graph
|
|
7448
|
+
* TODO: !!!!!! Personas in mermaid graph
|
|
7390
7449
|
* TODO: Maybe use some Mermaid package instead of string templating
|
|
7391
7450
|
* TODO: [🕌] When more than 2 functionalities, split into separate functions
|
|
7392
7451
|
*/
|