@promptbook/node 0.61.0-22 → 0.61.0-23

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.
@@ -4,7 +4,7 @@ import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionTo
4
4
  import { EmbeddingVector } from '../execution/EmbeddingVector';
5
5
  import type { ExecutionTools } from '../execution/ExecutionTools';
6
6
  import type { AvailableModel, LlmExecutionTools } from '../execution/LlmExecutionTools';
7
- import type { PipelineExecutor } from '../execution/PipelineExecutor';
7
+ import type { PipelineExecutor, PipelineExecutorResult } from '../execution/PipelineExecutor';
8
8
  import type { ChatPromptResult, CommonPromptResult, CompletionPromptResult, EmbeddingPromptResult, PromptResult } from '../execution/PromptResult';
9
9
  import type { PromptResultUsage, PromptResultUsageCounts } from '../execution/PromptResultUsage';
10
10
  import type { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools';
@@ -36,7 +36,7 @@ import type { FromtoItems } from '../utils/FromtoItems';
36
36
  import { PROMPTBOOK_VERSION, string_promptbook_version } from '../version';
37
37
  export { PROMPTBOOK_VERSION };
38
38
  export { EXPECTATION_UNITS };
39
- export type { AvailableModel, BlockType, CommonExecutionToolsOptions, EmbeddingVector, ExecutionReportJson, ExecutionTools, ExpectationAmount, ExpectationUnit, Expectations, FromtoItems, KnowledgePiecePreparedJson, KnowledgeSourceJson, KnowledgeSourcePreparedJson, LlmExecutionTools, LlmTemplateJson, ModelRequirements, ModelVariant, Parameters, PersonaJson, PersonaPreparedJson, PipelineCollection, PipelineExecutor, PipelineJson, PipelineString, PreparationJson, Prompt, ChatPromptResult as PromptChatResult, CommonPromptResult as PromptCommonResult, CompletionPromptResult as PromptCompletionResult, PromptDialogJson, EmbeddingPromptResult as PromptEmbeddingResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ReservedParameters, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, number_model_temperature, number_seed, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_emails, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_parameter_name, string_parameter_value, string_person_fullname, string_pipeline_url, string_pipeline_url_with_hashtemplate, string_prompt, string_promptbook_documentation_url, string_promptbook_version, string_reserved_parameter_name, string_script, string_semantic_version, string_sha256, string_system_message, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_uuid, };
39
+ export type { AvailableModel, BlockType, CommonExecutionToolsOptions, EmbeddingVector, ExecutionReportJson, ExecutionTools, ExpectationAmount, ExpectationUnit, Expectations, FromtoItems, KnowledgePiecePreparedJson, KnowledgeSourceJson, KnowledgeSourcePreparedJson, LlmExecutionTools, LlmTemplateJson, ModelRequirements, ModelVariant, Parameters, PersonaJson, PersonaPreparedJson, PipelineCollection, PipelineExecutor, PipelineExecutorResult, PipelineJson, PipelineString, PreparationJson, Prompt, ChatPromptResult as PromptChatResult, CommonPromptResult as PromptCommonResult, CompletionPromptResult as PromptCompletionResult, PromptDialogJson, EmbeddingPromptResult as PromptEmbeddingResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ReservedParameters, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, number_model_temperature, number_seed, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_emails, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_parameter_name, string_parameter_value, string_person_fullname, string_pipeline_url, string_pipeline_url_with_hashtemplate, string_prompt, string_promptbook_documentation_url, string_promptbook_version, string_reserved_parameter_name, string_script, string_semantic_version, string_sha256, string_system_message, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_uuid, };
40
40
  /**
41
41
  * TODO: Delete type aliases (from ../types/typeAliases) that are not exported here
42
42
  */
@@ -36,18 +36,22 @@ export declare const EXECUTIONS_CACHE_DIRNAME = "/.promptbook/executions-cache";
36
36
  * The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
37
37
  */
38
38
  export declare const PIPELINE_COLLECTION_BASE_FILENAME = "index";
39
+ /**
40
+ * Nonce which is used for replacing things in strings
41
+ */
42
+ export declare const REPLACING_NONCE = "u$k42k%!V2zo34w7Fu#@QUHYPW";
39
43
  /**
40
44
  * The names of the parameters that are reserved for special purposes
41
45
  */
42
- export declare const RESERVED_PARAMETER_NAMES: readonly ["context", "currentDate"];
46
+ export declare const RESERVED_PARAMETER_NAMES: readonly ["context", "knowledge", "samples", "modelName", "currentDate"];
43
47
  /**
44
48
  * @@@
45
49
  */
46
- export declare const DEBUG_ALLOW_PAYED_TESTING: boolean;
50
+ export declare const RESERVED_PARAMETER_MISSING_VALUE: string;
47
51
  /**
48
- * Nonce which is used for replacing things in strings
52
+ * @@@
49
53
  */
50
- export declare const REPLACING_NONCE = "u$k42k%!V2zo34w7Fu#@QUHYPW";
54
+ export declare const DEBUG_ALLOW_PAYED_TESTING: boolean;
51
55
  /**
52
56
  * TODO: [🔼] Export all to core
53
57
  */
@@ -13,30 +13,38 @@ import type { PromptResultUsage } from './PromptResultUsage';
13
13
  * @see https://github.com/webgptorg/promptbook#executor
14
14
  */
15
15
  export type PipelineExecutor = {
16
- (inputParameters: Parameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
17
- /**
18
- * Whether the execution was successful, details are aviable in `executionReport`
19
- */
20
- readonly isSuccessful: boolean;
21
- /**
22
- * Added usage of whole execution, detailed usage is aviable in `executionReport`
23
- */
24
- readonly usage: PromptResultUsage;
25
- /**
26
- * Errors that occured during the execution, details are aviable in `executionReport`
27
- */
28
- readonly errors: Array<PipelineExecutionError | Error>;
29
- /**
30
- * The report of the execution with all details
31
- */
32
- readonly executionReport: ExecutionReportJson;
33
- /**
34
- * Result parameters of the execution
35
- *
36
- * Note: If the execution was not successful, there are only some of the result parameters
37
- */
38
- readonly outputParameters: Parameters;
39
- }>;
16
+ (inputParameters: Parameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<PipelineExecutorResult>;
17
+ };
18
+ /**
19
+ * @@@
20
+ */
21
+ export type PipelineExecutorResult = {
22
+ /**
23
+ * Whether the execution was successful, details are aviable in `executionReport`
24
+ */
25
+ readonly isSuccessful: boolean;
26
+ /**
27
+ * Added usage of whole execution, detailed usage is aviable in `executionReport`
28
+ */
29
+ readonly usage: PromptResultUsage;
30
+ /**
31
+ * Errors that occured during the execution, details are aviable in `executionReport`
32
+ */
33
+ readonly errors: Array<PipelineExecutionError | Error>;
34
+ /**
35
+ * Warnings that occured during the execution, details are aviable in `executionReport`
36
+ */
37
+ readonly warnings: Array<PipelineExecutionError | Error>;
38
+ /**
39
+ * The report of the execution with all details
40
+ */
41
+ readonly executionReport: ExecutionReportJson;
42
+ /**
43
+ * Result parameters of the execution
44
+ *
45
+ * Note: If the execution was not successful, there are only some of the result parameters
46
+ */
47
+ readonly outputParameters: Parameters;
40
48
  };
41
49
  /**
42
50
  * TODO: [🧠] Should this file be in /execution or /types folder?
@@ -7,4 +7,8 @@ export declare function isPipelinePrepared(pipeline: PipelineJson): boolean;
7
7
  * TODO: [🐠] Maybe base this on `makeValidator`
8
8
  * TODO: [🔼] Export via core or utils
9
9
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
10
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
11
+ * - Is context in each template
12
+ * - Are samples prepared
13
+ * - Are templates prepared
10
14
  */
@@ -5,5 +5,6 @@ import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
5
5
  export declare function unpreparePipeline(pipeline: PipelineJson): PipelineJson;
6
6
  /**
7
7
  * TODO: [🔼] !!! Export via `@promptbook/core`
8
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
8
9
  * TODO: Write tests for `preparePipeline`
9
10
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.61.0-22",
3
+ "version": "0.61.0-23",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -51,7 +51,7 @@
51
51
  }
52
52
  ],
53
53
  "peerDependencies": {
54
- "@promptbook/core": "0.61.0-22"
54
+ "@promptbook/core": "0.61.0-23"
55
55
  },
56
56
  "main": "./umd/index.umd.js",
57
57
  "module": "./esm/index.es.js",
package/umd/index.umd.js CHANGED
@@ -191,15 +191,26 @@
191
191
  * The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
192
192
  */
193
193
  var PIPELINE_COLLECTION_BASE_FILENAME = "index";
194
+ /**
195
+ * Nonce which is used for replacing things in strings
196
+ */
197
+ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
194
198
  /**
195
199
  * The names of the parameters that are reserved for special purposes
196
200
  */
197
201
  var RESERVED_PARAMETER_NAMES = deepFreeze([
198
202
  'context',
203
+ 'knowledge',
204
+ 'samples',
205
+ 'modelName',
199
206
  'currentDate',
200
207
  // <- TODO: Add more like 'date', 'modelName',...
201
208
  // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
202
209
  ]);
210
+ /**
211
+ * @@@
212
+ */
213
+ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
203
214
  /*
204
215
  TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
205
216
  */
@@ -643,7 +654,7 @@
643
654
  });
644
655
  }
645
656
 
646
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-21",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",dependentParameterNames:["content"],resultingParameterName:"knowledge"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-21",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-21",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",dependentParameterNames:["content"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-21",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-21",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",expectations:{words:{min:1,max:8}},dependentParameterNames:["content"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-21",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-21",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:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",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}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-21",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"}];
657
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-22",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",dependentParameterNames:["content"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-22",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-22",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",dependentParameterNames:["content"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-22",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-22",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",expectations:{words:{min:1,max:8}},dependentParameterNames:["content"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-22",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-22",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:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",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}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-22",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"}];
647
658
 
648
659
  /**
649
660
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -911,7 +922,7 @@
911
922
  throw new PipelineLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
912
923
  }
913
924
  if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
914
- throw new PipelineLogicError("Parameter name {".concat(template.resultingParameterName, "} is reserved, please use fifferent name"));
925
+ throw new PipelineLogicError("Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name"));
915
926
  }
916
927
  definedParameters.add(template.resultingParameterName);
917
928
  if (template.blockType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
@@ -1088,6 +1099,7 @@
1088
1099
  }
1089
1100
  /**
1090
1101
  * TODO: [🔼] !!! Export via `@promptbook/core`
1102
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
1091
1103
  * TODO: Write tests for `preparePipeline`
1092
1104
  */
1093
1105
 
@@ -1990,22 +2002,21 @@
1990
2002
  // Note: Ignoring `pipeline.preparations` @@@
1991
2003
  // Note: Ignoring `pipeline.knowledgePieces` @@@
1992
2004
  if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
1993
- console.log('!!!!', 'Not all personas have modelRequirements');
1994
2005
  return false;
1995
2006
  }
1996
2007
  if (!pipeline.knowledgeSources.every(function (knowledgeSource) { return knowledgeSource.preparationIds !== undefined; })) {
1997
- console.log('!!!!', 'Not all knowledgeSources have preparationIds');
1998
2008
  return false;
1999
2009
  }
2000
- // TODO: !!!!! Is context in each template
2001
- // TODO: !!!!! Are samples prepared
2002
- // TODO: !!!!! Are templates prepared
2003
2010
  return true;
2004
2011
  }
2005
2012
  /**
2006
2013
  * TODO: [🐠] Maybe base this on `makeValidator`
2007
2014
  * TODO: [🔼] Export via core or utils
2008
2015
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2016
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
2017
+ * - Is context in each template
2018
+ * - Are samples prepared
2019
+ * - Are templates prepared
2009
2020
  */
2010
2021
 
2011
2022
  /**
@@ -2067,6 +2078,22 @@
2067
2078
  * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
2068
2079
  */
2069
2080
  function replaceParameters(template, parameters) {
2081
+ var e_1, _a;
2082
+ try {
2083
+ for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
2084
+ var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
2085
+ if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
2086
+ throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
2087
+ }
2088
+ }
2089
+ }
2090
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2091
+ finally {
2092
+ try {
2093
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2094
+ }
2095
+ finally { if (e_1) throw e_1.error; }
2096
+ }
2070
2097
  var replacedTemplate = template;
2071
2098
  var match;
2072
2099
  var loopLimit = LOOP_LIMIT;
@@ -2192,7 +2219,7 @@
2192
2219
  /**
2193
2220
  * The version of the Promptbook library
2194
2221
  */
2195
- var PROMPTBOOK_VERSION = '0.61.0-21';
2222
+ var PROMPTBOOK_VERSION = '0.61.0-22';
2196
2223
  // TODO: !!!! List here all the versions and annotate + put into script
2197
2224
 
2198
2225
  /**
@@ -2325,11 +2352,21 @@
2325
2352
  console.warn(spaceTrim.spaceTrim("\n Pipeline ".concat(rawPipeline.pipelineUrl || rawPipeline.sourceFile || rawPipeline.title, " is not prepared\n\n It will be prepared ad-hoc before the first execution\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n ")));
2326
2353
  }
2327
2354
  var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
2355
+ // TODO: !!!!! Extract to separate functions and files - ALL FUNCTIONS BELOW
2328
2356
  function getContextForTemplate(// <- TODO: [🧠][🥜]
2329
2357
  template) {
2330
2358
  return __awaiter(this, void 0, void 0, function () {
2331
2359
  return __generator(this, function (_a) {
2332
- // TODO: !!!!!! Implement Better - use real index and keyword search
2360
+ TODO_USE(template);
2361
+ return [2 /*return*/, ''];
2362
+ });
2363
+ });
2364
+ }
2365
+ function getKnowledgeForTemplate(// <- TODO: [🧠][🥜]
2366
+ template) {
2367
+ return __awaiter(this, void 0, void 0, function () {
2368
+ return __generator(this, function (_a) {
2369
+ // TODO: !!!! Implement Better - use real index and keyword search
2333
2370
  TODO_USE(template);
2334
2371
  return [2 /*return*/, pipeline.knowledgePieces.map(function (_a) {
2335
2372
  var content = _a.content;
@@ -2338,19 +2375,39 @@
2338
2375
  });
2339
2376
  });
2340
2377
  }
2378
+ function getSamplesForTemplate(// <- TODO: [🧠][🥜]
2379
+ template) {
2380
+ return __awaiter(this, void 0, void 0, function () {
2381
+ return __generator(this, function (_a) {
2382
+ // TODO: !!!! Implement Better - use real index and keyword search
2383
+ TODO_USE(template);
2384
+ return [2 /*return*/, ''];
2385
+ });
2386
+ });
2387
+ }
2341
2388
  function getReservedParametersForTemplate(template) {
2342
2389
  return __awaiter(this, void 0, void 0, function () {
2343
- var context, currentDate, reservedParameters, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
2390
+ var context, knowledge, samples, currentDate, modelName, reservedParameters, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
2344
2391
  var e_3, _a;
2345
2392
  return __generator(this, function (_b) {
2346
2393
  switch (_b.label) {
2347
2394
  case 0: return [4 /*yield*/, getContextForTemplate(template)];
2348
2395
  case 1:
2349
2396
  context = _b.sent();
2397
+ return [4 /*yield*/, getKnowledgeForTemplate(template)];
2398
+ case 2:
2399
+ knowledge = _b.sent();
2400
+ return [4 /*yield*/, getSamplesForTemplate(template)];
2401
+ case 3:
2402
+ samples = _b.sent();
2350
2403
  currentDate = new Date().toISOString();
2404
+ modelName = RESERVED_PARAMETER_MISSING_VALUE;
2351
2405
  reservedParameters = {
2352
2406
  context: context,
2407
+ knowledge: knowledge,
2408
+ samples: samples,
2353
2409
  currentDate: currentDate,
2410
+ modelName: modelName,
2354
2411
  };
2355
2412
  try {
2356
2413
  // Note: Doublecheck that ALL reserved parameters are defined:
@@ -2837,7 +2894,7 @@
2837
2894
  var parameter = _c.value;
2838
2895
  if (parametersToPass[parameter.name] === undefined) {
2839
2896
  // [4]
2840
- errors.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} should be an output parameter, but it was not be resolved")));
2897
+ warnings.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} should be an output parameter, but it was not be resolved")));
2841
2898
  continue;
2842
2899
  }
2843
2900
  outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
@@ -2852,7 +2909,7 @@
2852
2909
  }
2853
2910
  return outputParameters;
2854
2911
  }
2855
- var executionReport, _a, _b, parameter, errors, _loop_1, _c, _d, parameterName, state_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
2912
+ var executionReport, _a, _b, parameter, errors, warnings, _loop_1, _c, _d, parameterName, state_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
2856
2913
  var e_1, _e, e_2, _f;
2857
2914
  return __generator(this, function (_g) {
2858
2915
  switch (_g.label) {
@@ -2887,8 +2944,8 @@
2887
2944
  isSuccessful: false,
2888
2945
  errors: [
2889
2946
  new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter")),
2890
- // <- TODO: !!!!! Test this error
2891
2947
  ],
2948
+ warnings: [],
2892
2949
  executionReport: executionReport,
2893
2950
  outputParameters: {},
2894
2951
  usage: ZERO_USAGE,
@@ -2904,21 +2961,22 @@
2904
2961
  finally { if (e_1) throw e_1.error; }
2905
2962
  }
2906
2963
  errors = [];
2964
+ warnings = [];
2907
2965
  _loop_1 = function (parameterName) {
2908
2966
  var parameter = pipeline.parameters.find(function (_a) {
2909
2967
  var name = _a.name;
2910
2968
  return name === parameterName;
2911
2969
  });
2912
2970
  if (parameter === undefined) {
2913
- errors.push(new PipelineExecutionError("Extra parameter {".concat(parameterName, "} is passed as input parameter")));
2971
+ warnings.push(new PipelineExecutionError("Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.")));
2914
2972
  }
2915
2973
  else if (parameter.isInput === false) {
2916
2974
  return { value: deepFreezeWithSameType({
2917
2975
  isSuccessful: false,
2918
2976
  errors: [
2919
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is passed as input parameter but is not input")),
2920
- // <- TODO: !!!!! Test this error
2977
+ new PipelineExecutionError("Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input")),
2921
2978
  ],
2979
+ warnings: warnings,
2922
2980
  executionReport: executionReport,
2923
2981
  outputParameters: {},
2924
2982
  usage: ZERO_USAGE,
@@ -3027,6 +3085,7 @@
3027
3085
  return [2 /*return*/, deepFreezeWithSameType({
3028
3086
  isSuccessful: false,
3029
3087
  errors: __spreadArray([error_1], __read(errors), false),
3088
+ warnings: warnings,
3030
3089
  usage: usage_1,
3031
3090
  executionReport: executionReport,
3032
3091
  outputParameters: outputParameters_1,
@@ -3040,6 +3099,7 @@
3040
3099
  return [2 /*return*/, deepFreezeWithSameType({
3041
3100
  isSuccessful: true,
3042
3101
  errors: errors,
3102
+ warnings: warnings,
3043
3103
  usage: usage,
3044
3104
  executionReport: executionReport,
3045
3105
  outputParameters: outputParameters,
@@ -3066,7 +3126,7 @@
3066
3126
  */
3067
3127
  function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
3068
3128
  return __awaiter(this, void 0, void 0, function () {
3069
- var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
3129
+ var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
3070
3130
  var _f, _g, _h;
3071
3131
  var _this = this;
3072
3132
  return __generator(this, function (_j) {
@@ -3107,8 +3167,8 @@
3107
3167
  result = _j.sent();
3108
3168
  assertsExecutionSuccessful(result);
3109
3169
  outputParameters = result.outputParameters;
3110
- knowledgeRaw = outputParameters.knowledge;
3111
- knowledgeTextPieces = (knowledgeRaw || '').split('\n---\n');
3170
+ knowledgePiecesRaw = outputParameters.knowledgePieces;
3171
+ knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
3112
3172
  if (isVerbose) {
3113
3173
  console.info('knowledgeTextPieces:', knowledgeTextPieces);
3114
3174
  }
@@ -3376,7 +3436,8 @@
3376
3436
  knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
3377
3437
  // ----- /Knowledge preparation -----
3378
3438
  // TODO: !!!!! Add context to each template (if missing)
3379
- // TODO: !!!!! Apply samples to each template (if missing)
3439
+ // TODO: !!!!! Add knowledge to each template (if missing and is in pipeline defined)
3440
+ // TODO: !!!!! Apply samples to each template (if missing and is for the template defined)
3380
3441
  return [2 /*return*/, __assign(__assign({}, pipeline), { knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: preparations })];
3381
3442
  }
3382
3443
  });