@promptbook/cli 0.72.0 → 0.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -245
- package/esm/index.es.js +29 -29
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/commands/TEMPLATE/TemplateTypes.d.ts +1 -1
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
- package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +1 -1
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -2
- package/esm/typings/src/execution/createPipelineExecutor/{getSamplesForTemplate.d.ts → getExamplesForTemplate.d.ts} +1 -1
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +2 -2
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +1 -1
- package/esm/typings/src/personas/preparePersona.d.ts +1 -1
- package/esm/typings/src/prepare/isPipelinePrepared.d.ts +2 -2
- package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
- package/esm/typings/src/scrapers/document/DocumentScraper.test.d.ts +1 -1
- package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.test.d.ts +1 -1
- package/esm/typings/src/scrapers/markdown/MarkdownScraper.test.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +2 -2
- package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
- package/package.json +3 -2
- package/umd/index.umd.js +29 -29
- package/umd/index.umd.js.map +1 -1
|
@@ -12,4 +12,4 @@ export type TemplateType = TupleToUnion<typeof TemplateTypes>;
|
|
|
12
12
|
* @see https://github.com/webgptorg/promptbook#template-type
|
|
13
13
|
* @public exported from `@promptbook/core`
|
|
14
14
|
*/
|
|
15
|
-
export declare const TemplateTypes: readonly ["PROMPT_TEMPLATE", "SIMPLE_TEMPLATE", "SCRIPT_TEMPLATE", "DIALOG_TEMPLATE", "
|
|
15
|
+
export declare const TemplateTypes: readonly ["PROMPT_TEMPLATE", "SIMPLE_TEMPLATE", "SCRIPT_TEMPLATE", "DIALOG_TEMPLATE", "EXAMPLE", "KNOWLEDGE", "INSTRUMENT", "ACTION"];
|
|
@@ -121,7 +121,7 @@ export declare const REPLACING_NONCE = "u$k42k%!V2zo34w7Fu#@QUHYPW";
|
|
|
121
121
|
*
|
|
122
122
|
* @public exported from `@promptbook/core`
|
|
123
123
|
*/
|
|
124
|
-
export declare const RESERVED_PARAMETER_NAMES: readonly ["content", "context", "knowledge", "
|
|
124
|
+
export declare const RESERVED_PARAMETER_NAMES: readonly ["content", "context", "knowledge", "examples", "modelName", "currentDate"];
|
|
125
125
|
/**
|
|
126
126
|
* @@@
|
|
127
127
|
*
|
|
@@ -22,9 +22,9 @@ export type renderPipelineMermaidOptions = {
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function renderPromptbookMermaid(pipelineJson: PipelineJson, options?: renderPipelineMermaidOptions): string;
|
|
24
24
|
/**
|
|
25
|
-
* TODO:
|
|
26
|
-
* TODO:
|
|
27
|
-
* TODO:
|
|
25
|
+
* TODO: [🧠] !! FOREACH in mermaid graph
|
|
26
|
+
* TODO: [🧠] !! Knowledge in mermaid graph
|
|
27
|
+
* TODO: [🧠] !! Personas in mermaid graph
|
|
28
28
|
* TODO: Maybe use some Mermaid package instead of string templating
|
|
29
29
|
* TODO: [🕌] When more than 2 functionalities, split into separate functions
|
|
30
30
|
*/
|
|
@@ -9,7 +9,7 @@ import type { string_json } from '../../types/typeAliases';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function stringifyPipelineJson<TType>(pipeline: TType): string_json<TType>;
|
|
11
11
|
/**
|
|
12
|
-
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/
|
|
12
|
+
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.ptbk.md
|
|
13
13
|
* TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
|
|
14
14
|
* TODO: [🧠] Maybe more elegant solution than replacing via regex
|
|
15
15
|
* TODO: [🍙] Make some standard order of json properties
|
|
@@ -7,7 +7,7 @@ import type { string_json } from '../../types/typeAliases';
|
|
|
7
7
|
* Note: Using here custom import to work in jest tests
|
|
8
8
|
* Note: Using sync version is 💩 in the production code, but it's ok here in tests
|
|
9
9
|
*
|
|
10
|
-
* @param path - The path to the file relative to
|
|
10
|
+
* @param path - The path to the file relative to examples/pipelines directory
|
|
11
11
|
* @private internal function of tests
|
|
12
12
|
*/
|
|
13
13
|
export declare function importPipelineWithoutPreparation(path: `${string}.ptbk.md`): PipelineString;
|
|
@@ -20,7 +20,7 @@ export declare function validatePipeline(pipeline: PipelineJson): PipelineJson;
|
|
|
20
20
|
*/
|
|
21
21
|
export declare function validatePipelineCore(pipeline: PipelineJson): void;
|
|
22
22
|
/**
|
|
23
|
-
* TODO:
|
|
23
|
+
* TODO: !! [🧞♀️] Do not allow joker + foreach
|
|
24
24
|
* TODO: [🧠] Work with promptbookVersion
|
|
25
25
|
* TODO: Use here some json-schema, Zod or something similar and change it to:
|
|
26
26
|
* > /**
|
|
@@ -32,7 +32,7 @@ export declare function validatePipelineCore(pipeline: PipelineJson): void;
|
|
|
32
32
|
* > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
|
|
33
33
|
*/
|
|
34
34
|
/**
|
|
35
|
-
* TODO: [🧳][main] !!!! Validate that all
|
|
35
|
+
* TODO: [🧳][main] !!!! Validate that all examples match expectations
|
|
36
36
|
* TODO: [🧳][🐝][main] !!!! Validate that knowledge is valid (non-void)
|
|
37
37
|
* TODO: [🧳][main] !!!! Validate that persona can be used only with CHAT variant
|
|
38
38
|
* TODO: [🧳][main] !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
|
|
@@ -7,4 +7,4 @@ import type { string_parameter_value } from '../../types/typeAliases';
|
|
|
7
7
|
*
|
|
8
8
|
* @private internal utility of `createPipelineExecutor`
|
|
9
9
|
*/
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function getExamplesForTemplate(template: ReadonlyDeep<TemplateJson>): Promise<string_parameter_value & string_markdown>;
|
|
@@ -15,7 +15,7 @@ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends
|
|
|
15
15
|
/**
|
|
16
16
|
* The name of the format used in .ptbk.md files
|
|
17
17
|
*
|
|
18
|
-
* @
|
|
18
|
+
* @example "JSON"
|
|
19
19
|
*/
|
|
20
20
|
readonly formatName: string_name & string_SCREAMING_CASE;
|
|
21
21
|
/**
|
|
@@ -25,7 +25,7 @@ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends
|
|
|
25
25
|
/**
|
|
26
26
|
* The mime type of the format (if any)
|
|
27
27
|
*
|
|
28
|
-
* @
|
|
28
|
+
* @example "application/json"
|
|
29
29
|
*/
|
|
30
30
|
readonly mimeType?: string_mime_type;
|
|
31
31
|
/**
|
|
@@ -11,7 +11,7 @@ export type FormatSubvalueDefinition<TValue extends string, TSettings extends em
|
|
|
11
11
|
/**
|
|
12
12
|
* The name of the format used in .ptbk.md files
|
|
13
13
|
*
|
|
14
|
-
* @
|
|
14
|
+
* @example "CELL"
|
|
15
15
|
*/
|
|
16
16
|
readonly subvalueName: string_name & string_SCREAMING_CASE;
|
|
17
17
|
/**
|
|
@@ -10,7 +10,7 @@ import type { string_persona_description } from '../types/typeAliases';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function preparePersona(personaDescription: string_persona_description, tools: Pick<ExecutionTools, 'llm'>, options: PrepareAndScrapeOptions): Promise<PersonaPreparedJson['modelRequirements']>;
|
|
12
12
|
/**
|
|
13
|
-
* TODO: [🔃][main]
|
|
13
|
+
* TODO: [🔃][main] !! If the persona was prepared with different version or different set of models, prepare it once again
|
|
14
14
|
* TODO: [🏢] !! Check validity of `modelName` in pipeline
|
|
15
15
|
* TODO: [🏢] !! Check validity of `systemMessage` in pipeline
|
|
16
16
|
* TODO: [🏢] !! Check validity of `temperature` in pipeline
|
|
@@ -6,11 +6,11 @@ import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function isPipelinePrepared(pipeline: PipelineJson): boolean;
|
|
8
8
|
/**
|
|
9
|
-
* TODO: [🔃][main]
|
|
9
|
+
* TODO: [🔃][main] !! If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
10
10
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
11
11
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
12
12
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
13
13
|
* - [🏍] ? Is context in each template
|
|
14
|
-
* - [♨] Are
|
|
14
|
+
* - [♨] Are examples prepared
|
|
15
15
|
* - [♨] Are templates prepared
|
|
16
16
|
*/
|
|
@@ -24,7 +24,7 @@ export {};
|
|
|
24
24
|
/**
|
|
25
25
|
* TODO: [🧠] Add context to each template (if missing)
|
|
26
26
|
* TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
|
|
27
|
-
* TODO: [♨][main] !!! Prepare index the
|
|
27
|
+
* TODO: [♨][main] !!! Prepare index the examples and maybe templates
|
|
28
28
|
* TODO: Write tests for `preparePipeline`
|
|
29
29
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
30
30
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
@@ -27,10 +27,10 @@ export type ParameterJson = {
|
|
|
27
27
|
*/
|
|
28
28
|
readonly description?: string_markdown_text;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Example values of the parameter
|
|
31
31
|
* Note: This values won't be actually used as some default values, but they are just for better understanding of the parameter
|
|
32
32
|
*/
|
|
33
|
-
readonly
|
|
33
|
+
readonly exampleValues?: Array<string_parameter_value>;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
36
|
* TODO: [🧠] Should be here registered subparameters from foreach or not?
|
|
@@ -18,5 +18,5 @@ export type PreparationJson = {
|
|
|
18
18
|
/**
|
|
19
19
|
* TODO: [🍙] Make some standard order of json properties
|
|
20
20
|
* TODO: Maybe put here used `modelName`
|
|
21
|
-
* TODO: [🍥] When using `date` it changes all
|
|
21
|
+
* TODO: [🍥] When using `date` it changes all examples .ptbk.json files each time so until some more elegant solution omit the time from prepared pipeline
|
|
22
22
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.73.0",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"o1",
|
|
32
32
|
"o1-mini",
|
|
33
33
|
"o1-preview",
|
|
34
|
-
"anthropic"
|
|
34
|
+
"anthropic",
|
|
35
|
+
"LLMOps"
|
|
35
36
|
],
|
|
36
37
|
"license": "CC-BY-4.0",
|
|
37
38
|
"bugs": {
|
package/umd/index.umd.js
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
/**
|
|
40
40
|
* The version of the Promptbook library
|
|
41
41
|
*/
|
|
42
|
-
var PROMPTBOOK_VERSION = '0.72.0
|
|
42
|
+
var PROMPTBOOK_VERSION = '0.72.0';
|
|
43
43
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
44
44
|
|
|
45
45
|
/*! *****************************************************************************
|
|
@@ -508,10 +508,10 @@
|
|
|
508
508
|
'content',
|
|
509
509
|
'context',
|
|
510
510
|
'knowledge',
|
|
511
|
-
'
|
|
511
|
+
'examples',
|
|
512
512
|
'modelName',
|
|
513
513
|
'currentDate',
|
|
514
|
-
// <- TODO:
|
|
514
|
+
// <- TODO: list here all command names
|
|
515
515
|
// <- TODO: Add more like 'date', 'modelName',...
|
|
516
516
|
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
517
517
|
]);
|
|
@@ -1543,7 +1543,7 @@
|
|
|
1543
1543
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
1544
1544
|
*/
|
|
1545
1545
|
|
|
1546
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",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",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",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",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##
|
|
1546
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",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",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",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",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1547
1547
|
|
|
1548
1548
|
/**
|
|
1549
1549
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -1970,7 +1970,7 @@
|
|
|
1970
1970
|
}
|
|
1971
1971
|
}
|
|
1972
1972
|
/**
|
|
1973
|
-
* TODO:
|
|
1973
|
+
* TODO: !! [🧞♀️] Do not allow joker + foreach
|
|
1974
1974
|
* TODO: [🧠] Work with promptbookVersion
|
|
1975
1975
|
* TODO: Use here some json-schema, Zod or something similar and change it to:
|
|
1976
1976
|
* > /**
|
|
@@ -1982,7 +1982,7 @@
|
|
|
1982
1982
|
* > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
|
|
1983
1983
|
*/
|
|
1984
1984
|
/**
|
|
1985
|
-
* TODO: [🧳][main] !!!! Validate that all
|
|
1985
|
+
* TODO: [🧳][main] !!!! Validate that all examples match expectations
|
|
1986
1986
|
* TODO: [🧳][🐝][main] !!!! Validate that knowledge is valid (non-void)
|
|
1987
1987
|
* TODO: [🧳][main] !!!! Validate that persona can be used only with CHAT variant
|
|
1988
1988
|
* TODO: [🧳][main] !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
|
|
@@ -2336,12 +2336,12 @@
|
|
|
2336
2336
|
return true;
|
|
2337
2337
|
}
|
|
2338
2338
|
/**
|
|
2339
|
-
* TODO: [🔃][main]
|
|
2339
|
+
* TODO: [🔃][main] !! If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
2340
2340
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
2341
2341
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2342
2342
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2343
2343
|
* - [🏍] ? Is context in each template
|
|
2344
|
-
* - [♨] Are
|
|
2344
|
+
* - [♨] Are examples prepared
|
|
2345
2345
|
* - [♨] Are templates prepared
|
|
2346
2346
|
*/
|
|
2347
2347
|
|
|
@@ -4085,7 +4085,7 @@
|
|
|
4085
4085
|
var preparedPipeline, template;
|
|
4086
4086
|
return __generator(this, function (_a) {
|
|
4087
4087
|
preparedPipeline = options.preparedPipeline, template = options.template;
|
|
4088
|
-
// TODO: [♨] Implement Better - use real index and keyword search from `template` and {
|
|
4088
|
+
// TODO: [♨] Implement Better - use real index and keyword search from `template` and {examples}
|
|
4089
4089
|
TODO_USE(template);
|
|
4090
4090
|
return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
|
|
4091
4091
|
var content = _a.content;
|
|
@@ -4100,7 +4100,7 @@
|
|
|
4100
4100
|
*
|
|
4101
4101
|
* @private internal utility of `createPipelineExecutor`
|
|
4102
4102
|
*/
|
|
4103
|
-
function
|
|
4103
|
+
function getExamplesForTemplate(template) {
|
|
4104
4104
|
return __awaiter(this, void 0, void 0, function () {
|
|
4105
4105
|
return __generator(this, function (_a) {
|
|
4106
4106
|
// TODO: [♨] Implement Better - use real index and keyword search
|
|
@@ -4117,7 +4117,7 @@
|
|
|
4117
4117
|
*/
|
|
4118
4118
|
function getReservedParametersForTemplate(options) {
|
|
4119
4119
|
return __awaiter(this, void 0, void 0, function () {
|
|
4120
|
-
var preparedPipeline, template, pipelineIdentification, context, knowledge,
|
|
4120
|
+
var preparedPipeline, template, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
|
|
4121
4121
|
var e_1, _a;
|
|
4122
4122
|
return __generator(this, function (_b) {
|
|
4123
4123
|
switch (_b.label) {
|
|
@@ -4129,16 +4129,16 @@
|
|
|
4129
4129
|
return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
|
|
4130
4130
|
case 2:
|
|
4131
4131
|
knowledge = _b.sent();
|
|
4132
|
-
return [4 /*yield*/,
|
|
4132
|
+
return [4 /*yield*/, getExamplesForTemplate(template)];
|
|
4133
4133
|
case 3:
|
|
4134
|
-
|
|
4134
|
+
examples = _b.sent();
|
|
4135
4135
|
currentDate = new Date().toISOString();
|
|
4136
4136
|
modelName = RESERVED_PARAMETER_MISSING_VALUE;
|
|
4137
4137
|
reservedParameters = {
|
|
4138
4138
|
content: RESERVED_PARAMETER_RESTRICTED,
|
|
4139
4139
|
context: context,
|
|
4140
4140
|
knowledge: knowledge,
|
|
4141
|
-
|
|
4141
|
+
examples: examples,
|
|
4142
4142
|
currentDate: currentDate,
|
|
4143
4143
|
modelName: modelName,
|
|
4144
4144
|
};
|
|
@@ -4756,7 +4756,7 @@
|
|
|
4756
4756
|
});
|
|
4757
4757
|
}
|
|
4758
4758
|
/**
|
|
4759
|
-
* TODO: [🔃][main]
|
|
4759
|
+
* TODO: [🔃][main] !! If the persona was prepared with different version or different set of models, prepare it once again
|
|
4760
4760
|
* TODO: [🏢] !! Check validity of `modelName` in pipeline
|
|
4761
4761
|
* TODO: [🏢] !! Check validity of `systemMessage` in pipeline
|
|
4762
4762
|
* TODO: [🏢] !! Check validity of `temperature` in pipeline
|
|
@@ -5507,7 +5507,7 @@
|
|
|
5507
5507
|
case 0:
|
|
5508
5508
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
5509
5509
|
templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
5510
|
-
// TODO: [main]
|
|
5510
|
+
// TODO: [main] !! Apply examples to each template (if missing and is for the template defined)
|
|
5511
5511
|
TODO_USE(parameters);
|
|
5512
5512
|
templatesPrepared = new Array(templates.length);
|
|
5513
5513
|
return [4 /*yield*/, forEachAsync(templates, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -5537,7 +5537,7 @@
|
|
|
5537
5537
|
/**
|
|
5538
5538
|
* TODO: [🧠] Add context to each template (if missing)
|
|
5539
5539
|
* TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
|
|
5540
|
-
* TODO: [♨][main] !!! Prepare index the
|
|
5540
|
+
* TODO: [♨][main] !!! Prepare index the examples and maybe templates
|
|
5541
5541
|
* TODO: Write tests for `preparePipeline`
|
|
5542
5542
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
5543
5543
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
@@ -5746,7 +5746,7 @@
|
|
|
5746
5746
|
'SIMPLE_TEMPLATE',
|
|
5747
5747
|
'SCRIPT_TEMPLATE',
|
|
5748
5748
|
'DIALOG_TEMPLATE',
|
|
5749
|
-
'
|
|
5749
|
+
'EXAMPLE',
|
|
5750
5750
|
'KNOWLEDGE',
|
|
5751
5751
|
'INSTRUMENT',
|
|
5752
5752
|
'ACTION',
|
|
@@ -5805,7 +5805,7 @@
|
|
|
5805
5805
|
'SCRIPT',
|
|
5806
5806
|
'DIALOG',
|
|
5807
5807
|
// <- [🅱]
|
|
5808
|
-
'
|
|
5808
|
+
'EXAMPLE',
|
|
5809
5809
|
'KNOWLEDGE',
|
|
5810
5810
|
'INSTRUMENT',
|
|
5811
5811
|
'ACTION',
|
|
@@ -5838,7 +5838,7 @@
|
|
|
5838
5838
|
*/
|
|
5839
5839
|
parse: function (input) {
|
|
5840
5840
|
var normalized = input.normalized;
|
|
5841
|
-
normalized = normalized.split('
|
|
5841
|
+
normalized = normalized.split('SAMPLE').join('EXAMPLE');
|
|
5842
5842
|
var templateTypes = TemplateTypes.filter(function (templateType) {
|
|
5843
5843
|
return normalized.includes(templateType.split('_TEMPLATE').join(''));
|
|
5844
5844
|
});
|
|
@@ -5871,14 +5871,14 @@
|
|
|
5871
5871
|
if ($templateJson.content === undefined) {
|
|
5872
5872
|
throw new UnexpectedError("Content is missing in the templateJson - probbably commands are applied in wrong order");
|
|
5873
5873
|
}
|
|
5874
|
-
if (command.templateType === '
|
|
5874
|
+
if (command.templateType === 'EXAMPLE') {
|
|
5875
5875
|
expectResultingParameterName();
|
|
5876
5876
|
var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $templateJson.resultingParameterName; });
|
|
5877
5877
|
if (parameter === undefined) {
|
|
5878
|
-
throw new ParseError("Can not find parameter {".concat($templateJson.resultingParameterName, "} to assign
|
|
5878
|
+
throw new ParseError("Can not find parameter {".concat($templateJson.resultingParameterName, "} to assign example value on it"));
|
|
5879
5879
|
}
|
|
5880
|
-
parameter.
|
|
5881
|
-
parameter.
|
|
5880
|
+
parameter.exampleValues = parameter.exampleValues || [];
|
|
5881
|
+
parameter.exampleValues.push($templateJson.content);
|
|
5882
5882
|
$templateJson.isTemplate = false;
|
|
5883
5883
|
return;
|
|
5884
5884
|
}
|
|
@@ -9932,7 +9932,7 @@
|
|
|
9932
9932
|
return pipelineJsonStringified;
|
|
9933
9933
|
}
|
|
9934
9934
|
/**
|
|
9935
|
-
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/
|
|
9935
|
+
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.ptbk.md
|
|
9936
9936
|
* TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
|
|
9937
9937
|
* TODO: [🧠] Maybe more elegant solution than replacing via regex
|
|
9938
9938
|
* TODO: [🍙] Make some standard order of json properties
|
|
@@ -10602,9 +10602,9 @@
|
|
|
10602
10602
|
return promptbookMermaid;
|
|
10603
10603
|
}
|
|
10604
10604
|
/**
|
|
10605
|
-
* TODO:
|
|
10606
|
-
* TODO:
|
|
10607
|
-
* TODO:
|
|
10605
|
+
* TODO: [🧠] !! FOREACH in mermaid graph
|
|
10606
|
+
* TODO: [🧠] !! Knowledge in mermaid graph
|
|
10607
|
+
* TODO: [🧠] !! Personas in mermaid graph
|
|
10608
10608
|
* TODO: Maybe use some Mermaid package instead of string templating
|
|
10609
10609
|
* TODO: [🕌] When more than 2 functionalities, split into separate functions
|
|
10610
10610
|
*/
|
|
@@ -13508,7 +13508,7 @@
|
|
|
13508
13508
|
outputParameters = result.outputParameters;
|
|
13509
13509
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
13510
13510
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
13511
|
-
// <- TODO: [main]
|
|
13511
|
+
// <- TODO: [main] !! Smarter split and filter out empty pieces
|
|
13512
13512
|
if (isVerbose) {
|
|
13513
13513
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
13514
13514
|
}
|