@promptbook/node 0.69.0-10 → 0.69.0-12

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.
@@ -17,6 +17,7 @@ import { PIPELINE_COLLECTION_BASE_FILENAME } from '../config';
17
17
  import { RESERVED_PARAMETER_NAMES } from '../config';
18
18
  import { DEFAULT_REMOTE_URL } from '../config';
19
19
  import { DEFAULT_REMOTE_URL_PATH } from '../config';
20
+ import { DEFAULT_CSV_SETTINGS } from '../config';
20
21
  import { IS_VERBOSE } from '../config';
21
22
  import { pipelineJsonToString } from '../conversion/pipelineJsonToString';
22
23
  import type { PipelineStringToJsonOptions } from '../conversion/pipelineStringToJson';
@@ -92,6 +93,7 @@ export { PIPELINE_COLLECTION_BASE_FILENAME };
92
93
  export { RESERVED_PARAMETER_NAMES };
93
94
  export { DEFAULT_REMOTE_URL };
94
95
  export { DEFAULT_REMOTE_URL_PATH };
96
+ export { DEFAULT_CSV_SETTINGS };
95
97
  export { IS_VERBOSE };
96
98
  export { pipelineJsonToString };
97
99
  export type { PipelineStringToJsonOptions };
@@ -36,6 +36,7 @@ import type { UncertainNumber } from '../execution/UncertainNumber';
36
36
  import type { UserInterfaceTools } from '../execution/UserInterfaceTools';
37
37
  import type { UserInterfaceToolsPromptDialogOptions } from '../execution/UserInterfaceTools';
38
38
  import type { FormatSubvalueDefinition } from '../formats/_common/FormatSubvalueDefinition';
39
+ import type { CsvSettings } from '../formats/csv/CsvSettings';
39
40
  import type { CallbackInterfaceToolsOptions } from '../knowledge/dialogs/callback/CallbackInterfaceToolsOptions';
40
41
  import type { LlmToolsConfiguration } from '../llm-providers/_common/LlmToolsConfiguration';
41
42
  import type { LlmToolsMetadata } from '../llm-providers/_common/LlmToolsMetadata';
@@ -224,6 +225,7 @@ import type { string_camelCase } from '../utils/normalization/normalizeTo_camelC
224
225
  import type { string_PascalCase } from '../utils/normalization/normalizeTo_PascalCase';
225
226
  import type { string_SCREAMING_CASE } from '../utils/normalization/normalizeTo_SCREAMING_CASE';
226
227
  import type { string_snake_case } from '../utils/normalization/normalizeTo_snake_case';
228
+ import type { empty_object } from '../utils/organization/empty_object';
227
229
  import type { really_any } from '../utils/organization/really_any';
228
230
  import type { TODO_any } from '../utils/organization/TODO_any';
229
231
  import type { string_promptbook_version } from '../version';
@@ -265,6 +267,7 @@ export type { UncertainNumber };
265
267
  export type { UserInterfaceTools };
266
268
  export type { UserInterfaceToolsPromptDialogOptions };
267
269
  export type { FormatSubvalueDefinition };
270
+ export type { CsvSettings };
268
271
  export type { CallbackInterfaceToolsOptions };
269
272
  export type { LlmToolsConfiguration };
270
273
  export type { LlmToolsMetadata };
@@ -453,6 +456,7 @@ export type { string_camelCase };
453
456
  export type { string_PascalCase };
454
457
  export type { string_SCREAMING_CASE };
455
458
  export type { string_snake_case };
459
+ export type { empty_object };
456
460
  export type { really_any };
457
461
  export type { TODO_any };
458
462
  export type { string_promptbook_version };
@@ -1,3 +1,4 @@
1
+ import type { CsvSettings } from './formats/csv/CsvSettings';
1
2
  /**
2
3
  * Warning message for the generated sections and files files
3
4
  *
@@ -137,6 +138,12 @@ export declare const DEFAULT_REMOTE_URL = "https://api.pavolhejny.com/";
137
138
  * @public exported from `@promptbook/core`
138
139
  */
139
140
  export declare const DEFAULT_REMOTE_URL_PATH = "/promptbook/socket.io";
141
+ /**
142
+ * @@@
143
+ *
144
+ * @public exported from `@promptbook/core`
145
+ */
146
+ export declare const DEFAULT_CSV_SETTINGS: CsvSettings;
140
147
  /**
141
148
  * @@@
142
149
  *
@@ -148,13 +155,13 @@ export declare const IS_VERBOSE = false;
148
155
  *
149
156
  * @private within the repository
150
157
  */
151
- export declare const IS_COST_PREVENTED: boolean;
158
+ export declare const IS_PIPELINE_LOGIC_VALIDATED: boolean;
152
159
  /**
153
160
  * @@@
154
161
  *
155
162
  * @private within the repository
156
163
  */
157
- export declare const IS_PIPELINE_LOGIC_VALIDATED: boolean;
164
+ export declare const IS_COST_PREVENTED: boolean;
158
165
  /**
159
166
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
160
167
  */
@@ -1,3 +1,4 @@
1
+ import type { CsvSettings } from '../../formats/csv/CsvSettings';
1
2
  export type CreatePipelineExecutorSettings = {
2
3
  /**
3
4
  * When executor does not satisfy expectations it will be retried this amount of times
@@ -17,6 +18,12 @@ export type CreatePipelineExecutorSettings = {
17
18
  * @default false
18
19
  */
19
20
  readonly isVerbose: boolean;
21
+ /**
22
+ * Settings for CSV format
23
+ *
24
+ * @default DEFAULT_CSV_SETTINGS
25
+ */
26
+ readonly csvSettings: CsvSettings;
20
27
  /**
21
28
  * If you pass fully prepared pipeline, this does not matter
22
29
  *
@@ -1,14 +1,17 @@
1
- import type { string_SCREAMING_CASE } from '../../utils/normalization/normalizeTo_SCREAMING_CASE';
2
1
  import type { string_mime_type } from '../../types/typeAliases';
3
2
  import type { string_name } from '../../types/typeAliases';
3
+ import type { string_SCREAMING_CASE } from '../../utils/normalization/normalizeTo_SCREAMING_CASE';
4
+ import type { empty_object } from '../../utils/organization/empty_object';
4
5
  import type { FormatSubvalueDefinition } from './FormatSubvalueDefinition';
5
6
  /**
6
7
  * A format definition is a set of functions that define how to validate, heal and convert response from LLM
7
8
  *
9
+ * @@@ Describe setting vs schema
10
+ *
8
11
  * @see https://github.com/webgptorg/promptbook/discussions/36
9
12
  * @private still in development [🏢]
10
13
  */
11
- export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends string, TSchema> = {
14
+ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends string, TSettings extends empty_object, TSchema extends empty_object> = {
12
15
  /**
13
16
  * The name of the format used in .ptbk.md files
14
17
  *
@@ -31,7 +34,7 @@ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends
31
34
  * @param value The value to check, for example "{\"foo\": true}"
32
35
  * @param schema Optional schema to do extra validation
33
36
  */
34
- isValid(value: string, schema?: TSchema): value is TValue;
37
+ isValid(value: string, settings?: TSettings, schema?: TSchema): value is TValue;
35
38
  /**
36
39
  * Check if a first part of a value is valid
37
40
  *
@@ -40,7 +43,7 @@ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends
40
43
  * @param partialValue Partial value to check, for example "{\"foo\": t"
41
44
  * @param schema Optional schema to do extra validation
42
45
  */
43
- canBeValid(partialValue: string, schema?: TSchema): partialValue is TPartialValue;
46
+ canBeValid(partialValue: string, settings?: TSettings, schema?: TSchema): partialValue is TPartialValue;
44
47
  /**
45
48
  * Heal a value to make it valid if possible
46
49
  *
@@ -51,11 +54,11 @@ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends
51
54
  * @param scheme
52
55
  * @throws {Error} If the value cannot be healed
53
56
  */
54
- heal(value: string, scheme?: TSchema): TValue;
57
+ heal(value: string, settings?: TSettings, scheme?: TSchema): TValue;
55
58
  /**
56
59
  * @@@
57
60
  */
58
- readonly subvalueDefinitions: Array<FormatSubvalueDefinition<TValue>>;
61
+ readonly subvalueDefinitions: Array<FormatSubvalueDefinition<TValue, TSettings>>;
59
62
  };
60
63
  /**
61
64
  * TODO: [🧠][🦥] Better (less confusing) name for "cell" / "subvalue" / "subparameter"
@@ -1,11 +1,12 @@
1
1
  import type { Promisable } from 'type-fest';
2
- import type { string_SCREAMING_CASE } from '../../utils/normalization/normalizeTo_SCREAMING_CASE';
3
2
  import type { Parameters } from '../../types/typeAliases';
4
3
  import type { string_name } from '../../types/typeAliases';
4
+ import type { string_SCREAMING_CASE } from '../../utils/normalization/normalizeTo_SCREAMING_CASE';
5
+ import type { empty_object } from '../../utils/organization/empty_object';
5
6
  /**
6
7
  * @@@
7
8
  */
8
- export type FormatSubvalueDefinition<TValue extends string> = {
9
+ export type FormatSubvalueDefinition<TValue extends string, TSettings extends empty_object> = {
9
10
  /**
10
11
  * The name of the format used in .ptbk.md files
11
12
  *
@@ -22,7 +23,7 @@ export type FormatSubvalueDefinition<TValue extends string> = {
22
23
  * For example, if you have a JSON object and you want to map all values to uppercase
23
24
  * Or iterate over all CSV cells @@@
24
25
  */
25
- mapValues(value: TValue, mapCallback: (subvalues: Parameters, index: number) => Promisable<string>): Promise<string>;
26
+ mapValues(value: TValue, settings: TSettings, mapCallback: (subvalues: Parameters, index: number) => Promisable<string>): Promise<string>;
26
27
  };
27
28
  /**
28
29
  * TODO: [🧠][🦥] Better (less confusing) name for "cell" / "subvalue" / "subparameter"
@@ -1,11 +1,13 @@
1
+ import type { TODO_any } from '../../utils/organization/TODO_any';
1
2
  import type { FormatDefinition } from '../_common/FormatDefinition';
3
+ import type { CsvSettings } from './CsvSettings';
2
4
  /**
3
5
  * Definition for CSV spreadsheet
4
6
  *
5
7
  * @public exported from `@promptbook/core`
6
8
  * <- TODO: [🏢] Export from package `@promptbook/csv`
7
9
  */
8
- export declare const CsvFormatDefinition: FormatDefinition<string, string, object>;
10
+ export declare const CsvFormatDefinition: FormatDefinition<string, string, CsvSettings, TODO_any>;
9
11
  /**
10
12
  * TODO: [🍓] In `CsvFormatDefinition` implement simple `isValid`
11
13
  * TODO: [🍓] In `CsvFormatDefinition` implement partial `canBeValid`
@@ -0,0 +1,5 @@
1
+ import type { ParseConfig, UnparseConfig } from "papaparse";
2
+ /**
3
+ * @@@
4
+ */
5
+ export type CsvSettings = ParseConfig & UnparseConfig;
@@ -3,4 +3,4 @@
3
3
  *
4
4
  * @private internal index of `...` <- TODO [🏢]
5
5
  */
6
- export declare const FORMAT_DEFINITIONS: readonly [import("./_common/FormatDefinition").FormatDefinition<string, string, object>, import("./_common/FormatDefinition").FormatDefinition<string, string, object>, import("./_common/FormatDefinition").FormatDefinition<string, string, never>, import("./_common/FormatDefinition").FormatDefinition<string, string, object>];
6
+ export declare const FORMAT_DEFINITIONS: readonly [import("./_common/FormatDefinition").FormatDefinition<string, string, any, any>, import("./_common/FormatDefinition").FormatDefinition<string, string, any, any>, import("./_common/FormatDefinition").FormatDefinition<string, string, any, any>, import("./_common/FormatDefinition").FormatDefinition<string, string, import("./csv/CsvSettings").CsvSettings, any>];
@@ -1,14 +1,15 @@
1
+ import type { TODO_any } from '../../utils/organization/TODO_any';
1
2
  import type { FormatDefinition } from '../_common/FormatDefinition';
2
3
  /**
3
4
  * Definition for JSON format
4
5
  *
5
6
  * @private still in development [🏢]
6
7
  */
7
- export declare const JsonFormatDefinition: FormatDefinition<string, string, object>;
8
+ export declare const JsonFormatDefinition: FormatDefinition<string, string, TODO_any, TODO_any>;
8
9
  /**
9
10
  * TODO: [🧠] Maybe propper instance of object
10
11
  * TODO: [0] Make string_serialized_json
11
- * TODO: [1] Make type for JSON Schema
12
+ * TODO: [1] Make type for JSON Settings and Schema
12
13
  * TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
13
14
  * TODO: [🍓] In `JsonFormatDefinition` implement simple `isValid`
14
15
  * TODO: [🍓] In `JsonFormatDefinition` implement partial `canBeValid`
@@ -1,3 +1,4 @@
1
+ import type { TODO_any } from '../../utils/organization/TODO_any';
1
2
  import type { FormatDefinition } from '../_common/FormatDefinition';
2
3
  /**
3
4
  * Definition for any text - this will be always valid
@@ -6,8 +7,9 @@ import type { FormatDefinition } from '../_common/FormatDefinition';
6
7
  *
7
8
  * @public exported from `@promptbook/core`
8
9
  */
9
- export declare const TextFormatDefinition: FormatDefinition<string, string, never>;
10
+ export declare const TextFormatDefinition: FormatDefinition<string, string, TODO_any, TODO_any>;
10
11
  /**
12
+ * TODO: [1] Make type for XML Text and Schema
11
13
  * TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages aviable as subvalues
12
14
  * TODO: [🍓] In `TextFormatDefinition` implement simple `isValid`
13
15
  * TODO: [🍓] In `TextFormatDefinition` implement partial `canBeValid`
@@ -1,14 +1,15 @@
1
+ import type { TODO_any } from '../../utils/organization/TODO_any';
1
2
  import type { FormatDefinition } from '../_common/FormatDefinition';
2
3
  /**
3
4
  * Definition for XML format
4
5
  *
5
6
  * @private still in development [🏢]
6
7
  */
7
- export declare const XmlFormatDefinition: FormatDefinition<string, string, object>;
8
+ export declare const XmlFormatDefinition: FormatDefinition<string, string, TODO_any, TODO_any>;
8
9
  /**
9
10
  * TODO: [🧠] Maybe propper instance of object
10
11
  * TODO: [0] Make string_serialized_xml
11
- * TODO: [1] Make type for XML Schema
12
+ * TODO: [1] Make type for XML Settings and Schema
12
13
  * TODO: [🧠] What to use for validating XMLs - XSD,...
13
14
  * TODO: [🍓] In `XmlFormatDefinition` implement simple `isValid`
14
15
  * TODO: [🍓] In `XmlFormatDefinition` implement partial `canBeValid`
@@ -1,6 +1,10 @@
1
1
  /**
2
2
  * Organizational helper to better mark the place where to really use empty object `{}`
3
3
  *
4
+ * Note: There are 2 similar types>
5
+ * - `empty_object` @@@
6
+ * - `just_empty_object` @@@
7
+ *
4
8
  * @private within the repository
5
9
  */
6
- export type really_empty_object = Record<string, never>;
10
+ export type empty_object = {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Organizational helper to better @@@@
3
+ *
4
+ * Note: There are 2 similar types>
5
+ * - `empty_object` @@@
6
+ * - `just_empty_object` @@@
7
+ *
8
+ * Note: In most cases, you should use `empty_object`
9
+ *
10
+ * @private within the repository
11
+ */
12
+ export type just_empty_object = Record<string, never>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.69.0-10",
3
+ "version": "0.69.0-12",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -47,7 +47,7 @@
47
47
  "module": "./esm/index.es.js",
48
48
  "typings": "./esm/typings/src/_packages/node.index.d.ts",
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.69.0-10"
50
+ "@promptbook/core": "0.69.0-12"
51
51
  },
52
52
  "dependencies": {
53
53
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -35,7 +35,7 @@
35
35
  /**
36
36
  * The version of the Promptbook library
37
37
  */
38
- var PROMPTBOOK_VERSION = '0.69.0-9';
38
+ var PROMPTBOOK_VERSION = '0.69.0-11';
39
39
  // TODO: !!!! List here all the versions and annotate + put into script
40
40
 
41
41
  /*! *****************************************************************************
@@ -442,6 +442,19 @@
442
442
  */
443
443
  var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
444
444
  // <- TODO: [🧜‍♂️]
445
+ /**
446
+ * @@@
447
+ *
448
+ * @public exported from `@promptbook/core`
449
+ */
450
+ var DEFAULT_CSV_SETTINGS = {
451
+ header: true,
452
+ delimiter: ',',
453
+ quoteChar: '"',
454
+ newline: '\n',
455
+ skipEmptyLines: true,
456
+ // encoding: 'utf8'
457
+ };
445
458
  /**
446
459
  * @@@
447
460
  *
@@ -905,7 +918,7 @@
905
918
  });
906
919
  }
907
920
 
908
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.69.0-9",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.69.0-9",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.69.0-9",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.69.0-9",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
921
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.69.0-11",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.69.0-11",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.69.0-11",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.69.0-11",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
909
922
 
910
923
  /**
911
924
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -2661,57 +2674,61 @@
2661
2674
  var CsvFormatDefinition = {
2662
2675
  formatName: 'CSV',
2663
2676
  aliases: ['SPREADSHEET', 'TABLE'],
2664
- isValid: function (value, schema) {
2677
+ isValid: function (value, settings, schema) {
2678
+ // TODO: !!!!!! Implement CSV validation
2665
2679
  TODO_USE(value /* <- TODO: Use value here */);
2680
+ TODO_USE(settings /* <- TODO: Use settings here */);
2666
2681
  TODO_USE(schema /* <- TODO: Use schema here */);
2667
2682
  return true;
2668
2683
  },
2669
- canBeValid: function (partialValue, schema) {
2684
+ canBeValid: function (partialValue, settings, schema) {
2670
2685
  TODO_USE(partialValue /* <- TODO: Use partialValue here */);
2686
+ TODO_USE(settings /* <- TODO: Use settings here */);
2671
2687
  TODO_USE(schema /* <- TODO: Use schema here */);
2672
2688
  return true;
2673
2689
  },
2674
- heal: function (value, schema) {
2690
+ heal: function (value, settings, schema) {
2675
2691
  TODO_USE(value /* <- TODO: Use partialValue here */);
2692
+ TODO_USE(settings /* <- TODO: Use settings here */);
2676
2693
  TODO_USE(schema /* <- TODO: Use schema here */);
2677
2694
  throw new Error('Not implemented');
2678
2695
  },
2679
2696
  subvalueDefinitions: [
2680
2697
  {
2681
2698
  subvalueName: 'ROW',
2682
- mapValues: function (value, mapCallback) {
2699
+ mapValues: function (value, settings, mapCallback) {
2683
2700
  return __awaiter(this, void 0, void 0, function () {
2684
2701
  var csv, mappedData;
2702
+ var _this = this;
2685
2703
  return __generator(this, function (_a) {
2686
2704
  switch (_a.label) {
2687
2705
  case 0:
2688
- csv = papaparse.parse(value, {
2689
- header: true,
2690
- delimiter: ',',
2691
- quoteChar: '"',
2692
- newline: '\r\n',
2693
- skipEmptyLines: true,
2694
- // encoding: 'utf8',
2695
- // <- TODO: !!!!!! DEFAULT_CSV_OPTIONS
2696
- // <- TODO: [🧠] How to define parsing options for formats, its different concept than schema
2697
- });
2706
+ csv = papaparse.parse(value, settings);
2698
2707
  if (csv.errors.length !== 0) {
2699
2708
  throw new ParseError(// <- TODO: !!!!!! Split PipelineParseError and FormatParseError -> CsvParseError
2700
2709
  spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
2701
2710
  }
2702
- return [4 /*yield*/, Promise.all(csv.data.map(function (row, index) { /*not await */ return mapCallback(row, index); }))];
2711
+ return [4 /*yield*/, Promise.all(csv.data.map(function (row, index) { return __awaiter(_this, void 0, void 0, function () {
2712
+ var _a;
2713
+ var _b;
2714
+ return __generator(this, function (_c) {
2715
+ switch (_c.label) {
2716
+ case 0:
2717
+ _a = [__assign({}, row)];
2718
+ _b = {};
2719
+ // <- TODO: !!!!!! Dynamic new column name and position
2720
+ // <- TODO: !!!!!! Check name collisions
2721
+ return [4 /*yield*/, mapCallback(row, index)];
2722
+ case 1: return [2 /*return*/, (__assign.apply(void 0, _a.concat([(_b.newColumn =
2723
+ // <- TODO: !!!!!! Dynamic new column name and position
2724
+ // <- TODO: !!!!!! Check name collisions
2725
+ _c.sent(), _b)])))];
2726
+ }
2727
+ });
2728
+ }); }))];
2703
2729
  case 1:
2704
2730
  mappedData = _a.sent();
2705
- return [2 /*return*/, papaparse.unparse(mappedData, {
2706
- header: true,
2707
- delimiter: ',',
2708
- quoteChar: '"',
2709
- newline: '\r\n',
2710
- skipEmptyLines: true,
2711
- // encoding: 'utf8',
2712
- // <- TODO: !!!!!! DEFAULT_CSV_OPTIONS
2713
- // <- TODO: [🧠] How to define parsing options for formats, its different concept than schema
2714
- })];
2731
+ return [2 /*return*/, papaparse.unparse(mappedData, settings)];
2715
2732
  }
2716
2733
  });
2717
2734
  });
@@ -2719,23 +2736,14 @@
2719
2736
  },
2720
2737
  {
2721
2738
  subvalueName: 'CELL',
2722
- mapValues: function (value, mapCallback) {
2739
+ mapValues: function (value, settings, mapCallback) {
2723
2740
  return __awaiter(this, void 0, void 0, function () {
2724
2741
  var csv, mappedData;
2725
2742
  var _this = this;
2726
2743
  return __generator(this, function (_a) {
2727
2744
  switch (_a.label) {
2728
2745
  case 0:
2729
- csv = papaparse.parse(value, {
2730
- header: true,
2731
- delimiter: ',',
2732
- quoteChar: '"',
2733
- newline: '\r\n',
2734
- skipEmptyLines: true,
2735
- // encoding: 'utf8',
2736
- // <- TODO: !!!!!! DEFAULT_CSV_OPTIONS
2737
- // <- TODO: [🧠] How to define parsing options for formats, its different concept than schema
2738
- });
2746
+ csv = papaparse.parse(value, settings);
2739
2747
  if (csv.errors.length !== 0) {
2740
2748
  throw new ParseError(// <- TODO: !!!!!! Split PipelineParseError and FormatParseError -> CsvParseError
2741
2749
  spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
@@ -2758,16 +2766,7 @@
2758
2766
  }); }))];
2759
2767
  case 1:
2760
2768
  mappedData = _a.sent();
2761
- return [2 /*return*/, papaparse.unparse(mappedData, {
2762
- header: true,
2763
- delimiter: ',',
2764
- quoteChar: '"',
2765
- newline: '\r\n',
2766
- skipEmptyLines: true,
2767
- // encoding: 'utf8',
2768
- // <- TODO: !!!!!! DEFAULT_CSV_OPTIONS
2769
- // <- TODO: [🧠] How to define parsing options for formats, its different concept than schema
2770
- })];
2769
+ return [2 /*return*/, papaparse.unparse(mappedData, settings)];
2771
2770
  }
2772
2771
  });
2773
2772
  });
@@ -2812,17 +2811,20 @@
2812
2811
  var JsonFormatDefinition = {
2813
2812
  formatName: 'JSON',
2814
2813
  mimeType: 'application/json',
2815
- isValid: function (value, schema) {
2814
+ isValid: function (value, settings, schema) {
2816
2815
  TODO_USE(schema /* <- TODO: Use schema here */);
2816
+ TODO_USE(settings /* <- TODO: Use settings here */);
2817
2817
  return isValidJsonString(value);
2818
2818
  },
2819
- canBeValid: function (partialValue, schema) {
2819
+ canBeValid: function (partialValue, settings, schema) {
2820
2820
  TODO_USE(partialValue /* <- TODO: Use partialValue here */);
2821
+ TODO_USE(settings /* <- TODO: Use settings here */);
2821
2822
  TODO_USE(schema /* <- TODO: Use schema here */);
2822
2823
  return true;
2823
2824
  },
2824
- heal: function (value, schema) {
2825
+ heal: function (value, settings, schema) {
2825
2826
  TODO_USE(value /* <- TODO: Use partialValue here */);
2827
+ TODO_USE(settings /* <- TODO: Use settings here */);
2826
2828
  TODO_USE(schema /* <- TODO: Use schema here */);
2827
2829
  throw new Error('Not implemented');
2828
2830
  },
@@ -2831,7 +2833,7 @@
2831
2833
  /**
2832
2834
  * TODO: [🧠] Maybe propper instance of object
2833
2835
  * TODO: [0] Make string_serialized_json
2834
- * TODO: [1] Make type for JSON Schema
2836
+ * TODO: [1] Make type for JSON Settings and Schema
2835
2837
  * TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
2836
2838
  * TODO: [🍓] In `JsonFormatDefinition` implement simple `isValid`
2837
2839
  * TODO: [🍓] In `JsonFormatDefinition` implement partial `canBeValid`
@@ -2861,7 +2863,7 @@
2861
2863
  subvalueDefinitions: [
2862
2864
  {
2863
2865
  subvalueName: 'LINE',
2864
- mapValues: function (value, mapCallback) {
2866
+ mapValues: function (value, settings, mapCallback) {
2865
2867
  return __awaiter(this, void 0, void 0, function () {
2866
2868
  var lines, mappedLines;
2867
2869
  return __generator(this, function (_a) {
@@ -2887,6 +2889,7 @@
2887
2889
  ],
2888
2890
  };
2889
2891
  /**
2892
+ * TODO: [1] Make type for XML Text and Schema
2890
2893
  * TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages aviable as subvalues
2891
2894
  * TODO: [🍓] In `TextFormatDefinition` implement simple `isValid`
2892
2895
  * TODO: [🍓] In `TextFormatDefinition` implement partial `canBeValid`
@@ -2903,18 +2906,21 @@
2903
2906
  var XmlFormatDefinition = {
2904
2907
  formatName: 'XML',
2905
2908
  mimeType: 'application/xml',
2906
- isValid: function (value, schema) {
2909
+ isValid: function (value, settings, schema) {
2907
2910
  TODO_USE(value /* <- TODO: Use value here */);
2911
+ TODO_USE(settings /* <- TODO: Use settings here */);
2908
2912
  TODO_USE(schema /* <- TODO: Use schema here */);
2909
2913
  return true;
2910
2914
  },
2911
- canBeValid: function (partialValue, schema) {
2915
+ canBeValid: function (partialValue, settings, schema) {
2912
2916
  TODO_USE(partialValue /* <- TODO: Use partialValue here */);
2917
+ TODO_USE(settings /* <- TODO: Use settings here */);
2913
2918
  TODO_USE(schema /* <- TODO: Use schema here */);
2914
2919
  return true;
2915
2920
  },
2916
- heal: function (value, schema) {
2921
+ heal: function (value, settings, schema) {
2917
2922
  TODO_USE(value /* <- TODO: Use partialValue here */);
2923
+ TODO_USE(settings /* <- TODO: Use settings here */);
2918
2924
  TODO_USE(schema /* <- TODO: Use schema here */);
2919
2925
  throw new Error('Not implemented');
2920
2926
  },
@@ -2923,7 +2929,7 @@
2923
2929
  /**
2924
2930
  * TODO: [🧠] Maybe propper instance of object
2925
2931
  * TODO: [0] Make string_serialized_xml
2926
- * TODO: [1] Make type for XML Schema
2932
+ * TODO: [1] Make type for XML Settings and Schema
2927
2933
  * TODO: [🧠] What to use for validating XMLs - XSD,...
2928
2934
  * TODO: [🍓] In `XmlFormatDefinition` implement simple `isValid`
2929
2935
  * TODO: [🍓] In `XmlFormatDefinition` implement partial `canBeValid`
@@ -3741,12 +3747,12 @@
3741
3747
  */
3742
3748
  function executeFormatCells(options) {
3743
3749
  return __awaiter(this, void 0, void 0, function () {
3744
- var template, jokerParameterNames, parameters, priority, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, resultString;
3750
+ var template, jokerParameterNames, parameters, priority, pipelineIdentification, settings, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
3745
3751
  var _this = this;
3746
3752
  return __generator(this, function (_a) {
3747
3753
  switch (_a.label) {
3748
3754
  case 0:
3749
- template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, pipelineIdentification = options.pipelineIdentification;
3755
+ template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, pipelineIdentification = options.pipelineIdentification, settings = options.settings;
3750
3756
  if (template.foreach === undefined) {
3751
3757
  return [2 /*return*/, /* not await */ executeAttempts(options)];
3752
3758
  }
@@ -3775,7 +3781,11 @@
3775
3781
  .map(function (subvalueName) { return "- ".concat(subvalueName); })
3776
3782
  .join('\n')), "\n\n [\u26F7] This should never happen because cell name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
3777
3783
  }
3778
- return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
3784
+ if (formatDefinition.formatName === 'CSV') {
3785
+ formatSettings = settings.csvSettings;
3786
+ // <- TODO: !!!!!! More universal, make simmilar pattern for other formats for example \n vs \r\n in text
3787
+ }
3788
+ return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
3779
3789
  var mappedParameters, allSubparameters, subresultString;
3780
3790
  return __generator(this, function (_a) {
3781
3791
  switch (_a.label) {
@@ -4410,7 +4420,7 @@
4410
4420
  function createPipelineExecutor(options) {
4411
4421
  var _this = this;
4412
4422
  var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
4413
- var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? MAX_EXECUTION_ATTEMPTS : _b, _c = settings.maxParallelCount, maxParallelCount = _c === void 0 ? MAX_PARALLEL_COUNT : _c, _d = settings.isVerbose, isVerbose = _d === void 0 ? IS_VERBOSE : _d, _e = settings.isNotPreparedWarningSupressed, isNotPreparedWarningSupressed = _e === void 0 ? false : _e;
4423
+ var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? MAX_EXECUTION_ATTEMPTS : _b, _c = settings.maxParallelCount, maxParallelCount = _c === void 0 ? MAX_PARALLEL_COUNT : _c, _d = settings.csvSettings, csvSettings = _d === void 0 ? DEFAULT_CSV_SETTINGS : _d, _e = settings.isVerbose, isVerbose = _e === void 0 ? IS_VERBOSE : _e, _f = settings.isNotPreparedWarningSupressed, isNotPreparedWarningSupressed = _f === void 0 ? false : _f;
4414
4424
  validatePipeline(pipeline);
4415
4425
  var pipelineIdentification = (function () {
4416
4426
  // Note: This is a 😐 implementation of [🚞]
@@ -4445,6 +4455,7 @@
4445
4455
  settings: {
4446
4456
  maxExecutionAttempts: maxExecutionAttempts,
4447
4457
  maxParallelCount: maxParallelCount,
4458
+ csvSettings: csvSettings,
4448
4459
  isVerbose: isVerbose,
4449
4460
  isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
4450
4461
  },
@@ -7193,7 +7204,7 @@
7193
7204
  function extractOneBlockFromMarkdown(markdown) {
7194
7205
  var codeBlocks = extractAllBlocksFromMarkdown(markdown);
7195
7206
  if (codeBlocks.length !== 1) {
7196
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n There should be exactly 1 code block, found ".concat(codeBlocks.length, " code blocks\n\n ").concat(block(codeBlocks.map(function (block, i) { return "Block ".concat(i + 1, ":\n").concat(block.content); }).join('\n\n\n')), "\n "); }));
7207
+ throw new ParseError(spaceTrim__default["default"](function (block) { return "\n There should be exactly 1 code block in template, found ".concat(codeBlocks.length, " code blocks\n\n ").concat(block(codeBlocks.map(function (block, i) { return "Block ".concat(i + 1, ":\n").concat(block.content); }).join('\n\n\n')), "\n "); }));
7197
7208
  }
7198
7209
  return codeBlocks[0];
7199
7210
  }