@promptbook/core 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/core",
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,
package/umd/index.umd.js CHANGED
@@ -473,19 +473,26 @@
473
473
  * The maximum number of attempts to execute LLM task before giving up
474
474
  */
475
475
  var MAX_EXECUTION_ATTEMPTS = 3;
476
+ /**
477
+ * Nonce which is used for replacing things in strings
478
+ */
479
+ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
476
480
  /**
477
481
  * The names of the parameters that are reserved for special purposes
478
482
  */
479
483
  var RESERVED_PARAMETER_NAMES = deepFreeze([
480
484
  'context',
485
+ 'knowledge',
486
+ 'samples',
487
+ 'modelName',
481
488
  'currentDate',
482
489
  // <- TODO: Add more like 'date', 'modelName',...
483
490
  // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
484
491
  ]);
485
492
  /**
486
- * Nonce which is used for replacing things in strings
493
+ * @@@
487
494
  */
488
- var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
495
+ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
489
496
  /*
490
497
  TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
491
498
  */
@@ -760,7 +767,7 @@
760
767
  throw new PipelineLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
761
768
  }
762
769
  if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
763
- throw new PipelineLogicError("Parameter name {".concat(template.resultingParameterName, "} is reserved, please use fifferent name"));
770
+ throw new PipelineLogicError("Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name"));
764
771
  }
765
772
  definedParameters.add(template.resultingParameterName);
766
773
  if (template.blockType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
@@ -937,6 +944,7 @@
937
944
  }
938
945
  /**
939
946
  * TODO: [🔼] !!! Export via `@promptbook/core`
947
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
940
948
  * TODO: Write tests for `preparePipeline`
941
949
  */
942
950
 
@@ -1454,7 +1462,7 @@
1454
1462
  });
1455
1463
  }
1456
1464
 
1457
- 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"}];
1465
+ 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"}];
1458
1466
 
1459
1467
  var defaultDiacriticsRemovalMap = [
1460
1468
  {
@@ -2250,22 +2258,21 @@
2250
2258
  // Note: Ignoring `pipeline.preparations` @@@
2251
2259
  // Note: Ignoring `pipeline.knowledgePieces` @@@
2252
2260
  if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
2253
- console.log('!!!!', 'Not all personas have modelRequirements');
2254
2261
  return false;
2255
2262
  }
2256
2263
  if (!pipeline.knowledgeSources.every(function (knowledgeSource) { return knowledgeSource.preparationIds !== undefined; })) {
2257
- console.log('!!!!', 'Not all knowledgeSources have preparationIds');
2258
2264
  return false;
2259
2265
  }
2260
- // TODO: !!!!! Is context in each template
2261
- // TODO: !!!!! Are samples prepared
2262
- // TODO: !!!!! Are templates prepared
2263
2266
  return true;
2264
2267
  }
2265
2268
  /**
2266
2269
  * TODO: [🐠] Maybe base this on `makeValidator`
2267
2270
  * TODO: [🔼] Export via core or utils
2268
2271
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2272
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
2273
+ * - Is context in each template
2274
+ * - Are samples prepared
2275
+ * - Are templates prepared
2269
2276
  */
2270
2277
 
2271
2278
  /**
@@ -2327,6 +2334,22 @@
2327
2334
  * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
2328
2335
  */
2329
2336
  function replaceParameters(template, parameters) {
2337
+ var e_1, _a;
2338
+ try {
2339
+ for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
2340
+ var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
2341
+ if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
2342
+ throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
2343
+ }
2344
+ }
2345
+ }
2346
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2347
+ finally {
2348
+ try {
2349
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2350
+ }
2351
+ finally { if (e_1) throw e_1.error; }
2352
+ }
2330
2353
  var replacedTemplate = template;
2331
2354
  var match;
2332
2355
  var loopLimit = LOOP_LIMIT;
@@ -2452,7 +2475,7 @@
2452
2475
  /**
2453
2476
  * The version of the Promptbook library
2454
2477
  */
2455
- var PROMPTBOOK_VERSION = '0.61.0-21';
2478
+ var PROMPTBOOK_VERSION = '0.61.0-22';
2456
2479
  // TODO: !!!! List here all the versions and annotate + put into script
2457
2480
 
2458
2481
  /**
@@ -2606,11 +2629,21 @@
2606
2629
  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 ")));
2607
2630
  }
2608
2631
  var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
2632
+ // TODO: !!!!! Extract to separate functions and files - ALL FUNCTIONS BELOW
2609
2633
  function getContextForTemplate(// <- TODO: [🧠][🥜]
2610
2634
  template) {
2611
2635
  return __awaiter(this, void 0, void 0, function () {
2612
2636
  return __generator(this, function (_a) {
2613
- // TODO: !!!!!! Implement Better - use real index and keyword search
2637
+ TODO_USE(template);
2638
+ return [2 /*return*/, ''];
2639
+ });
2640
+ });
2641
+ }
2642
+ function getKnowledgeForTemplate(// <- TODO: [🧠][🥜]
2643
+ template) {
2644
+ return __awaiter(this, void 0, void 0, function () {
2645
+ return __generator(this, function (_a) {
2646
+ // TODO: !!!! Implement Better - use real index and keyword search
2614
2647
  TODO_USE(template);
2615
2648
  return [2 /*return*/, pipeline.knowledgePieces.map(function (_a) {
2616
2649
  var content = _a.content;
@@ -2619,19 +2652,39 @@
2619
2652
  });
2620
2653
  });
2621
2654
  }
2655
+ function getSamplesForTemplate(// <- TODO: [🧠][🥜]
2656
+ template) {
2657
+ return __awaiter(this, void 0, void 0, function () {
2658
+ return __generator(this, function (_a) {
2659
+ // TODO: !!!! Implement Better - use real index and keyword search
2660
+ TODO_USE(template);
2661
+ return [2 /*return*/, ''];
2662
+ });
2663
+ });
2664
+ }
2622
2665
  function getReservedParametersForTemplate(template) {
2623
2666
  return __awaiter(this, void 0, void 0, function () {
2624
- var context, currentDate, reservedParameters, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
2667
+ var context, knowledge, samples, currentDate, modelName, reservedParameters, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
2625
2668
  var e_3, _a;
2626
2669
  return __generator(this, function (_b) {
2627
2670
  switch (_b.label) {
2628
2671
  case 0: return [4 /*yield*/, getContextForTemplate(template)];
2629
2672
  case 1:
2630
2673
  context = _b.sent();
2674
+ return [4 /*yield*/, getKnowledgeForTemplate(template)];
2675
+ case 2:
2676
+ knowledge = _b.sent();
2677
+ return [4 /*yield*/, getSamplesForTemplate(template)];
2678
+ case 3:
2679
+ samples = _b.sent();
2631
2680
  currentDate = new Date().toISOString();
2681
+ modelName = RESERVED_PARAMETER_MISSING_VALUE;
2632
2682
  reservedParameters = {
2633
2683
  context: context,
2684
+ knowledge: knowledge,
2685
+ samples: samples,
2634
2686
  currentDate: currentDate,
2687
+ modelName: modelName,
2635
2688
  };
2636
2689
  try {
2637
2690
  // Note: Doublecheck that ALL reserved parameters are defined:
@@ -3118,7 +3171,7 @@
3118
3171
  var parameter = _c.value;
3119
3172
  if (parametersToPass[parameter.name] === undefined) {
3120
3173
  // [4]
3121
- errors.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} should be an output parameter, but it was not be resolved")));
3174
+ warnings.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} should be an output parameter, but it was not be resolved")));
3122
3175
  continue;
3123
3176
  }
3124
3177
  outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
@@ -3133,7 +3186,7 @@
3133
3186
  }
3134
3187
  return outputParameters;
3135
3188
  }
3136
- 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;
3189
+ 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;
3137
3190
  var e_1, _e, e_2, _f;
3138
3191
  return __generator(this, function (_g) {
3139
3192
  switch (_g.label) {
@@ -3168,8 +3221,8 @@
3168
3221
  isSuccessful: false,
3169
3222
  errors: [
3170
3223
  new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter")),
3171
- // <- TODO: !!!!! Test this error
3172
3224
  ],
3225
+ warnings: [],
3173
3226
  executionReport: executionReport,
3174
3227
  outputParameters: {},
3175
3228
  usage: ZERO_USAGE,
@@ -3185,21 +3238,22 @@
3185
3238
  finally { if (e_1) throw e_1.error; }
3186
3239
  }
3187
3240
  errors = [];
3241
+ warnings = [];
3188
3242
  _loop_1 = function (parameterName) {
3189
3243
  var parameter = pipeline.parameters.find(function (_a) {
3190
3244
  var name = _a.name;
3191
3245
  return name === parameterName;
3192
3246
  });
3193
3247
  if (parameter === undefined) {
3194
- errors.push(new PipelineExecutionError("Extra parameter {".concat(parameterName, "} is passed as input parameter")));
3248
+ warnings.push(new PipelineExecutionError("Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.")));
3195
3249
  }
3196
3250
  else if (parameter.isInput === false) {
3197
3251
  return { value: deepFreezeWithSameType({
3198
3252
  isSuccessful: false,
3199
3253
  errors: [
3200
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is passed as input parameter but is not input")),
3201
- // <- TODO: !!!!! Test this error
3254
+ new PipelineExecutionError("Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input")),
3202
3255
  ],
3256
+ warnings: warnings,
3203
3257
  executionReport: executionReport,
3204
3258
  outputParameters: {},
3205
3259
  usage: ZERO_USAGE,
@@ -3308,6 +3362,7 @@
3308
3362
  return [2 /*return*/, deepFreezeWithSameType({
3309
3363
  isSuccessful: false,
3310
3364
  errors: __spreadArray([error_1], __read(errors), false),
3365
+ warnings: warnings,
3311
3366
  usage: usage_1,
3312
3367
  executionReport: executionReport,
3313
3368
  outputParameters: outputParameters_1,
@@ -3321,6 +3376,7 @@
3321
3376
  return [2 /*return*/, deepFreezeWithSameType({
3322
3377
  isSuccessful: true,
3323
3378
  errors: errors,
3379
+ warnings: warnings,
3324
3380
  usage: usage,
3325
3381
  executionReport: executionReport,
3326
3382
  outputParameters: outputParameters,
@@ -3347,7 +3403,7 @@
3347
3403
  */
3348
3404
  function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
3349
3405
  return __awaiter(this, void 0, void 0, function () {
3350
- var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
3406
+ var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
3351
3407
  var _f, _g, _h;
3352
3408
  var _this = this;
3353
3409
  return __generator(this, function (_j) {
@@ -3388,8 +3444,8 @@
3388
3444
  result = _j.sent();
3389
3445
  assertsExecutionSuccessful(result);
3390
3446
  outputParameters = result.outputParameters;
3391
- knowledgeRaw = outputParameters.knowledge;
3392
- knowledgeTextPieces = (knowledgeRaw || '').split('\n---\n');
3447
+ knowledgePiecesRaw = outputParameters.knowledgePieces;
3448
+ knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
3393
3449
  if (isVerbose) {
3394
3450
  console.info('knowledgeTextPieces:', knowledgeTextPieces);
3395
3451
  }
@@ -3657,7 +3713,8 @@
3657
3713
  knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
3658
3714
  // ----- /Knowledge preparation -----
3659
3715
  // TODO: !!!!! Add context to each template (if missing)
3660
- // TODO: !!!!! Apply samples to each template (if missing)
3716
+ // TODO: !!!!! Add knowledge to each template (if missing and is in pipeline defined)
3717
+ // TODO: !!!!! Apply samples to each template (if missing and is for the template defined)
3661
3718
  return [2 /*return*/, __assign(__assign({}, pipeline), { knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: preparations })];
3662
3719
  }
3663
3720
  });