@promptbook/remote-client 0.61.0-15 → 0.61.0-17

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.
Files changed (87) hide show
  1. package/esm/index.es.js +1 -1
  2. package/esm/typings/promptbook-collection/index.d.ts +12 -15
  3. package/esm/typings/src/_packages/core.index.d.ts +2 -1
  4. package/esm/typings/src/_packages/node.index.d.ts +2 -1
  5. package/esm/typings/src/_packages/types.index.d.ts +2 -3
  6. package/esm/typings/src/_packages/utils.index.d.ts +4 -3
  7. package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -3
  8. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +28 -3
  9. package/esm/typings/src/config.d.ts +26 -1
  10. package/esm/typings/src/config.test.d.ts +4 -0
  11. package/esm/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts +2 -2
  12. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
  13. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +3 -0
  14. package/esm/typings/src/execution/PipelineExecutor.d.ts +5 -5
  15. package/esm/typings/src/execution/PromptResultUsage.d.ts +3 -3
  16. package/esm/typings/src/execution/ScriptExecutionTools.d.ts +2 -3
  17. package/esm/typings/src/execution/createPipelineExecutor.d.ts +16 -3
  18. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
  19. package/esm/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +27 -0
  20. package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +1 -1
  21. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
  22. package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +1 -1
  23. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
  24. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +2 -2
  25. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -2
  26. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +3 -3
  27. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -3
  28. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +10 -0
  29. package/esm/typings/src/prepare/preparePipeline.d.ts +1 -0
  30. package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +2 -1
  31. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -0
  32. package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +3 -0
  33. package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +4 -0
  34. package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +5 -3
  35. package/esm/typings/src/types/Prompt.d.ts +7 -10
  36. package/esm/typings/src/types/typeAliases.d.ts +44 -4
  37. package/esm/typings/src/utils/deepFreeze.d.ts +10 -1
  38. package/esm/typings/src/utils/extractParameters.d.ts +2 -2
  39. package/esm/typings/src/{execution/utils → utils}/replaceParameters.d.ts +2 -4
  40. package/esm/typings/src/utils/sets/difference.d.ts +3 -0
  41. package/package.json +2 -2
  42. package/umd/index.umd.js +1 -1
  43. package/umd/typings/promptbook-collection/index.d.ts +12 -15
  44. package/umd/typings/src/_packages/core.index.d.ts +2 -1
  45. package/umd/typings/src/_packages/node.index.d.ts +2 -1
  46. package/umd/typings/src/_packages/types.index.d.ts +2 -3
  47. package/umd/typings/src/_packages/utils.index.d.ts +4 -3
  48. package/umd/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -3
  49. package/umd/typings/src/commands/_common/types/CommandParser.d.ts +28 -3
  50. package/umd/typings/src/config.d.ts +26 -1
  51. package/umd/typings/src/config.test.d.ts +4 -0
  52. package/umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts +2 -2
  53. package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
  54. package/umd/typings/src/conversion/validation/validatePipeline.d.ts +3 -0
  55. package/umd/typings/src/execution/PipelineExecutor.d.ts +5 -5
  56. package/umd/typings/src/execution/PromptResultUsage.d.ts +3 -3
  57. package/umd/typings/src/execution/ScriptExecutionTools.d.ts +2 -3
  58. package/umd/typings/src/execution/createPipelineExecutor.d.ts +16 -3
  59. package/umd/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
  60. package/umd/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +27 -0
  61. package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +1 -1
  62. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
  63. package/umd/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +1 -1
  64. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
  65. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +2 -2
  66. package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -2
  67. package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +3 -3
  68. package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -3
  69. package/umd/typings/src/prepare/isPipelinePrepared.d.ts +10 -0
  70. package/umd/typings/src/prepare/isPipelinePrepared.test.d.ts +1 -0
  71. package/umd/typings/src/prepare/preparePipeline.d.ts +1 -0
  72. package/umd/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +2 -1
  73. package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -0
  74. package/umd/typings/src/types/PipelineJson/PromptDialogJson.d.ts +3 -0
  75. package/umd/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +4 -0
  76. package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +5 -3
  77. package/umd/typings/src/types/Prompt.d.ts +7 -10
  78. package/umd/typings/src/types/typeAliases.d.ts +44 -4
  79. package/umd/typings/src/utils/deepFreeze.d.ts +10 -1
  80. package/umd/typings/src/utils/extractParameters.d.ts +2 -2
  81. package/umd/typings/src/{execution/utils → utils}/replaceParameters.d.ts +2 -4
  82. package/umd/typings/src/utils/replaceParameters.test.d.ts +1 -0
  83. package/umd/typings/src/utils/sets/difference.d.ts +3 -0
  84. package/esm/typings/src/types/Parameters.d.ts +0 -14
  85. package/umd/typings/src/types/Parameters.d.ts +0 -14
  86. /package/esm/typings/src/{execution/utils/replaceParameters.test.d.ts → prepare/isPipelinePrepared.test.d.ts} +0 -0
  87. /package/{umd/typings/src/execution → esm/typings/src}/utils/replaceParameters.test.d.ts +0 -0
@@ -79,6 +79,7 @@ export type PipelineJson = {
79
79
  readonly preparations: Array<PreparationJson>;
80
80
  };
81
81
  /**
82
+ * TODO: [🧠] Maybe wrap all {parameterNames} in brackets for example { "resultingParameterName": "{foo}" }
82
83
  * Note: There was a proposal for multiple types of promptbook objects 78816ff33e2705ee1a187aa2eb8affd976d4ea1a
83
84
  * But then immediately reverted back to the single type
84
85
  * With knowledge as part of the promptbook and collection just as a collection of promptbooks
@@ -7,3 +7,6 @@ import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
7
7
  export interface PromptDialogJson extends PromptTemplateJsonCommon {
8
8
  readonly blockType: 'PROMPT_DIALOG';
9
9
  }
10
+ /**
11
+ * TODO: [🧠][🥜]
12
+ */
@@ -7,3 +7,7 @@ import type { SimpleTemplateJson } from './SimpleTemplateJson';
7
7
  * Describes one prompt template in the promptbook
8
8
  */
9
9
  export type PromptTemplateJson = LlmTemplateJson | SimpleTemplateJson | ScriptJson | PromptDialogJson | ___ | ___ | ___ | ___;
10
+ /**
11
+ * TODO: [🧠][🥜] What is propper name for this - "Template", "Prompt template",...
12
+ * TODO: [🧠][🥜] Reduce confusion of `PromptTemplateJson` vs (`LlmTemplateJson` which is 'PROMPT_TEMPLATE')
13
+ */
@@ -5,6 +5,7 @@ import type { string_javascript_name } from '../typeAliases';
5
5
  import type { string_markdown } from '../typeAliases';
6
6
  import type { string_markdown_text } from '../typeAliases';
7
7
  import type { string_name } from '../typeAliases';
8
+ import type { string_parameter_name } from '../typeAliases';
8
9
  import type { string_prompt } from '../typeAliases';
9
10
  import type { string_template } from '../typeAliases';
10
11
  import type { Expectations } from './Expectations';
@@ -34,13 +35,13 @@ export interface PromptTemplateJsonCommon {
34
35
  *
35
36
  * Note: Joker is one of the dependent parameters
36
37
  */
37
- readonly dependentParameterNames: Array<string_name>;
38
+ readonly dependentParameterNames: Array<string_parameter_name>;
38
39
  /**
39
40
  * If theese parameters meet the expectations requirements, they are used instead of executing this prompt template
40
41
  *
41
42
  * @see https://github.com/webgptorg/promptbook/discussions/66
42
43
  */
43
- readonly jokers?: Array<string>;
44
+ readonly jokerParameterNames?: Array<string_parameter_name>;
44
45
  /**
45
46
  * Type of the execution
46
47
  * This determines if the prompt template is send to LLM, user or some scripting evaluation
@@ -55,7 +56,7 @@ export interface PromptTemplateJsonCommon {
55
56
  *
56
57
  * @see https://github.com/webgptorg/promptbook/discussions/31
57
58
  */
58
- readonly postprocessing?: Array<string_javascript_name>;
59
+ readonly postprocessingFunctionNames?: Array<string_javascript_name>;
59
60
  /**
60
61
  * Expect this amount of each unit in the answer
61
62
  *
@@ -79,6 +80,7 @@ export interface PromptTemplateJsonCommon {
79
80
  readonly resultingParameterName: string_name;
80
81
  }
81
82
  /**
83
+ * TODO: [🧠][🥜]
82
84
  * TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
83
85
  * TODO: [♈] Probbably move expectations from templates to parameters
84
86
  */
@@ -5,10 +5,10 @@ import type { CompletionModelRequirements } from './ModelRequirements';
5
5
  import type { EmbeddingModelRequirements } from './ModelRequirements';
6
6
  import type { ModelRequirements } from './ModelRequirements';
7
7
  import type { Expectations } from './PipelineJson/Expectations';
8
- import type { string_parameter_name } from './typeAliases';
9
- import type { string_parameter_value } from './typeAliases';
8
+ import type { Parameters } from './typeAliases';
10
9
  import type { string_pipeline_url_with_hashtemplate } from './typeAliases';
11
10
  import type { string_prompt } from './typeAliases';
11
+ import type { string_template } from './typeAliases';
12
12
  import type { string_title } from './typeAliases';
13
13
  /**
14
14
  * Prompt in a text along with model requirements, but without any execution or templating logic.
@@ -63,12 +63,11 @@ export type CommonPrompt = {
63
63
  */
64
64
  readonly title: string_title;
65
65
  /**
66
- * The text of the prompt
66
+ * The text of the prompt with placeholders for parameters
67
67
  *
68
- * Note: This is not a template, this is exactly the text that will be sent to the model
69
- * @example "What is the capital of France?"
68
+ * @example "What is the capital of {country}?"
70
69
  */
71
- readonly content: string_prompt;
70
+ readonly content: string_prompt & string_template;
72
71
  /**
73
72
  * Requirements for the model
74
73
  */
@@ -98,11 +97,9 @@ export type CommonPrompt = {
98
97
  */
99
98
  readonly pipelineUrl?: string_pipeline_url_with_hashtemplate;
100
99
  /**
101
- * Parameters used in the prompt
102
- *
103
- * Note: This is redundant (same information is in pipelineUrl+content) but useful for logging and debugging
100
+ * Parameters used in the `content`
104
101
  */
105
- readonly parameters: Record<string_parameter_name, string_parameter_value>;
102
+ readonly parameters: Parameters;
106
103
  };
107
104
  /**
108
105
  * TODO: [🔼] !!!! Export all from `@promptbook/types`
@@ -1,3 +1,4 @@
1
+ import { RESERVED_PARAMETER_NAMES } from '../config';
1
2
  /**
2
3
  * Semantic helper
3
4
  */
@@ -17,7 +18,7 @@ export type string_prompt = string;
17
18
  /**
18
19
  * Semantic helper
19
20
  *
20
- * For example `"A cat wearing a {ITEM}"`
21
+ * For example `"A cat wearing a {item}"`
21
22
  */
22
23
  export type string_template = string;
23
24
  /**
@@ -85,14 +86,36 @@ export type string_name = string;
85
86
  *
86
87
  * For example `"eventName"`
87
88
  */
88
- export type string_parameter_name = string;
89
+ export type string_parameter_name = string_name;
89
90
  /**
90
91
  * Semantic helper
91
- * Unique identifier of anything
92
+ * Unique identifier of parameter
92
93
  *
93
94
  * For example `"DevConf 2024"`
94
95
  */
95
96
  export type string_parameter_value = string;
97
+ /**
98
+ * Parameters of the pipeline
99
+ *
100
+ * There are three types of parameters:
101
+ * - **INPUT PARAMETERs** are required to execute the pipeline.
102
+ * - **Intermediate parameters** are used internally in the pipeline.
103
+ * - **OUTPUT PARAMETERs** are not used internally in the pipeline, but are returned as the result of the pipeline execution.
104
+ *
105
+ * @see https://ptbk.io/parameters
106
+ */
107
+ export type Parameters = Exclude<Record<string_parameter_name, string_parameter_value>, ReservedParameters>;
108
+ /**
109
+ * Semantic helper
110
+ * Unique identifier of reserved parameter
111
+ *
112
+ * For example `"context"`
113
+ */
114
+ export type string_reserved_parameter_name = typeof RESERVED_PARAMETER_NAMES[number];
115
+ /**
116
+ * @@@
117
+ */
118
+ export type ReservedParameters = Record<string_reserved_parameter_name, string_parameter_value>;
96
119
  /**
97
120
  * Semantic helper
98
121
  * Title of anything
@@ -115,8 +138,21 @@ export type string_persona_description = string;
115
138
  * For example `"./pavol-hejny-cv.pdf"`
116
139
  * For example `"Pavol Hejný has web https://pavolhejny.com/"`
117
140
  * For example `"Pavol Hejný is web developer and creator of Promptbook and Collboard"`
141
+ *
142
+ * @@@ string_knowledge_source vs string_knowledge_source_link
143
+ */
144
+ export type string_knowledge_source = string_knowledge_source_link | string_markdown;
145
+ /**
146
+ * One link to knowledge source
147
+ *
148
+ * It can be a link or relative path
149
+ *
150
+ * For example `"https://pavolhejny.com/"`
151
+ * For example `"./pavol-hejny-cv.pdf"`
152
+ *
153
+ * @@@ string_knowledge_source vs string_knowledge_source_link
118
154
  */
119
- export type string_knowledge_source = string_url | string_file_path | string;
155
+ export type string_knowledge_source_link = string_url | string_file_path;
120
156
  /**
121
157
  * Semantic helper
122
158
  *
@@ -160,6 +196,10 @@ export type string_markdown_section_content = string;
160
196
  * For example `"**Hello** World!"`
161
197
  */
162
198
  export type string_markdown_text = string;
199
+ /**
200
+ * @@@
201
+ */
202
+ export type string_promptbook_documentation_url = `https://github.com/webgptorg/promptbook/discussions/${number | '@@'}`;
163
203
  /**
164
204
  * Semantic helper
165
205
  *
@@ -4,9 +4,18 @@ import type { ReadonlyDeep } from 'type-fest';
4
4
  *
5
5
  * @returns The same object as the input, but deeply frozen
6
6
  *
7
- * Note: This function mutates the object
7
+ * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
8
8
  */
9
9
  export declare function deepFreeze<TObject>(objectValue: TObject): ReadonlyDeep<TObject>;
10
+ /**
11
+ * @@@
12
+ * @@@
13
+ *
14
+ * @returns The same object as the input, but deeply frozen
15
+ *
16
+ * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
17
+ */
18
+ export declare function deepFreezeWithSameType<TObject>(objectValue: TObject): TObject;
10
19
  /**
11
20
  * TODO: [🔼] Export from `@promptbook/utils`
12
21
  * TODO: [🧠] Is there a way how to meaningfully test this utility
@@ -1,4 +1,4 @@
1
- import type { string_name } from '../types/typeAliases';
1
+ import type { string_parameter_name } from '../types/typeAliases';
2
2
  import type { string_template } from '../types/typeAliases';
3
3
  /**
4
4
  * Parses the template and returns the list of all parameter names
@@ -6,4 +6,4 @@ import type { string_template } from '../types/typeAliases';
6
6
  * @param template the template with parameters in {curly} braces
7
7
  * @returns the list of parameter names
8
8
  */
9
- export declare function extractParameters(template: string_template): Set<string_name>;
9
+ export declare function extractParameters(template: string_template): Set<string_parameter_name>;
@@ -1,5 +1,5 @@
1
- import type { Parameters } from '../../types/Parameters';
2
- import type { string_template } from '../../types/typeAliases';
1
+ import type { Parameters } from '../types/typeAliases';
2
+ import type { string_template } from '../types/typeAliases';
3
3
  /**
4
4
  * Replaces parameters in template with values from parameters object
5
5
  *
@@ -7,7 +7,5 @@ import type { string_template } from '../../types/typeAliases';
7
7
  * @param parameters the object with parameters
8
8
  * @returns the template with replaced parameters
9
9
  * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
10
- *
11
- * @private within the createPipelineExecutor
12
10
  */
13
11
  export declare function replaceParameters(template: string_template, parameters: Parameters): string;
@@ -4,3 +4,6 @@
4
4
  * @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
5
5
  */
6
6
  export declare function difference<TItem>(a: Set<TItem>, b: Set<TItem>, isEqual?: (a: TItem, b: TItem) => boolean): Set<TItem>;
7
+ /**
8
+ * TODO: [🧠][💯] Maybe also implement symmetricDifference
9
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-client",
3
- "version": "0.61.0-15",
3
+ "version": "0.61.0-17",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -47,7 +47,7 @@
47
47
  }
48
48
  ],
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.61.0-15"
50
+ "@promptbook/core": "0.61.0-17"
51
51
  },
52
52
  "main": "./umd/index.umd.js",
53
53
  "module": "./esm/index.es.js",
package/umd/index.umd.js CHANGED
@@ -218,7 +218,7 @@
218
218
  /**
219
219
  * The version of the Promptbook library
220
220
  */
221
- var PROMPTBOOK_VERSION = '0.61.0-14';
221
+ var PROMPTBOOK_VERSION = '0.61.0-16';
222
222
  // TODO: !!!! List here all the versions and annotate + put into script
223
223
 
224
224
  exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
@@ -9,16 +9,15 @@ declare const _default: ({
9
9
  isOutput: boolean;
10
10
  }[];
11
11
  promptTemplates: {
12
+ blockType: string;
12
13
  name: string;
13
14
  title: string;
14
- dependentParameterNames: string[];
15
- blockType: string;
16
- personaName: null;
17
15
  modelRequirements: {
18
16
  modelVariant: string;
19
17
  modelName: string;
20
18
  };
21
19
  content: string;
20
+ dependentParameterNames: string[];
22
21
  resultingParameterName: string;
23
22
  }[];
24
23
  knowledgeSources: never[];
@@ -91,22 +90,21 @@ declare const _default: ({
91
90
  isOutput: boolean;
92
91
  }[];
93
92
  promptTemplates: {
93
+ blockType: string;
94
94
  name: string;
95
95
  title: string;
96
- dependentParameterNames: string[];
97
- blockType: string;
96
+ modelRequirements: {
97
+ modelVariant: string;
98
+ modelName: string;
99
+ };
100
+ content: string;
98
101
  expectations: {
99
102
  words: {
100
103
  min: number;
101
104
  max: number;
102
105
  };
103
106
  };
104
- personaName: null;
105
- modelRequirements: {
106
- modelVariant: string;
107
- modelName: string;
108
- };
109
- content: string;
107
+ dependentParameterNames: string[];
110
108
  resultingParameterName: string;
111
109
  }[];
112
110
  knowledgeSources: never[];
@@ -179,17 +177,16 @@ declare const _default: ({
179
177
  isOutput: boolean;
180
178
  }[];
181
179
  promptTemplates: {
180
+ blockType: string;
182
181
  name: string;
183
182
  title: string;
184
- dependentParameterNames: string[];
185
- blockType: string;
186
- expectFormat: string;
187
- personaName: null;
188
183
  modelRequirements: {
189
184
  modelVariant: string;
190
185
  modelName: string;
191
186
  };
192
187
  content: string;
188
+ expectFormat: string;
189
+ dependentParameterNames: string[];
193
190
  resultingParameterName: string;
194
191
  }[];
195
192
  knowledgeSources: never[];
@@ -9,6 +9,7 @@ import { pipelineJsonToString } from '../conversion/pipelineJsonToString';
9
9
  import { pipelineStringToJson } from '../conversion/pipelineStringToJson';
10
10
  import { pipelineStringToJsonSync } from '../conversion/pipelineStringToJsonSync';
11
11
  import { prettifyPipelineString } from '../conversion/prettify/prettifyPipelineString';
12
+ import { stringifyPipelineJson } from '../conversion/utils/stringifyPipelineJson';
12
13
  import { validatePipeline } from '../conversion/validation/validatePipeline';
13
14
  import { CollectionError } from '../errors/CollectionError';
14
15
  import { NotFoundError } from '../errors/NotFoundError';
@@ -41,7 +42,7 @@ export { BlockTypes, RESERVED_PARAMETER_NAMES };
41
42
  export { addUsage, assertsExecutionSuccessful, checkExpectations, embeddingVectorToString, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, isPassingExpectations, prepareKnowledgeFromMarkdown, prettifyPipelineString, usageToWorktime, };
42
43
  export { collectionToJson, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createSubcollection, };
43
44
  export { SimplePromptInterfaceTools };
44
- export { pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, validatePipeline };
45
+ export { pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, stringifyPipelineJson, validatePipeline, };
45
46
  export { preparePipeline, unpreparePipeline };
46
47
  export { createPipelineExecutor, joinLlmExecutionTools };
47
48
  export { CallbackInterfaceTools, CallbackInterfaceToolsOptions };
@@ -1,4 +1,5 @@
1
1
  import { createCollectionFromDirectory } from '../collection/constructors/createCollectionFromDirectory';
2
+ import { createLlmToolsFromEnv } from '../llm-providers/_common/createLlmToolsFromEnv';
2
3
  import { PROMPTBOOK_VERSION } from '../version';
3
4
  export { PROMPTBOOK_VERSION };
4
- export { createCollectionFromDirectory };
5
+ export { createCollectionFromDirectory, createLlmToolsFromEnv };
@@ -12,7 +12,6 @@ import type { UncertainNumber } from '../execution/UncertainNumber';
12
12
  import type { UserInterfaceTools, UserInterfaceToolsPromptDialogOptions } from '../execution/UserInterfaceTools';
13
13
  import type { ModelRequirements } from '../types/ModelRequirements';
14
14
  import type { ModelVariant } from '../types/ModelVariant';
15
- import type { Parameters } from '../types/Parameters';
16
15
  import type { ExpectationAmount, ExpectationUnit, Expectations } from '../types/PipelineJson/Expectations';
17
16
  import { EXPECTATION_UNITS } from '../types/PipelineJson/Expectations';
18
17
  import { KnowledgePiecePreparedJson } from '../types/PipelineJson/KnowledgePieceJson';
@@ -32,12 +31,12 @@ import type { ScriptLanguage } from '../types/ScriptLanguage';
32
31
  import type { TaskProgress } from '../types/TaskProgress';
33
32
  import type { ExecutionReportJson } from '../types/execution-report/ExecutionReportJson';
34
33
  import type { string_char_emoji } from '../types/typeAliasEmoji';
35
- import type { client_id, number_model_temperature, number_seed, string_char, 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_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 } from '../types/typeAliases';
34
+ import type { Parameters, ReservedParameters, client_id, number_model_temperature, number_seed, string_char, 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_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 } from '../types/typeAliases';
36
35
  import type { FromtoItems } from '../utils/FromtoItems';
37
36
  import { PROMPTBOOK_VERSION, string_promptbook_version } from '../version';
38
37
  export { PROMPTBOOK_VERSION };
39
38
  export { EXPECTATION_UNITS };
40
- 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, 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_version, 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, 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, };
41
40
  /**
42
41
  * TODO: Delete type aliases (from ../types/typeAliases) that are not exported here
43
42
  */
@@ -5,7 +5,6 @@ import { extractVariables } from '../conversion/utils/extractVariables';
5
5
  import { renameParameter } from '../conversion/utils/renameParameter';
6
6
  import { titleToName } from '../conversion/utils/titleToName';
7
7
  import { forEachAsync } from '../execution/utils/forEachAsync';
8
- import { replaceParameters } from '../execution/utils/replaceParameters';
9
8
  import { isValidJsonString } from '../formats/json/utils/isValidJsonString';
10
9
  import { extractBlock } from '../postprocessing/utils/extractBlock';
11
10
  import { $currentDate } from '../utils/currentDate';
@@ -38,6 +37,7 @@ import { parseNumber } from '../utils/parseNumber';
38
37
  import { $randomSeed } from '../utils/random/randomSeed';
39
38
  import { removeEmojis } from '../utils/removeEmojis';
40
39
  import { removeQuotes } from '../utils/removeQuotes';
40
+ import { replaceParameters } from '../utils/replaceParameters';
41
41
  import { difference } from '../utils/sets/difference';
42
42
  import { intersection } from '../utils/sets/intersection';
43
43
  import { union } from '../utils/sets/union';
@@ -55,9 +55,10 @@ import { isValidUrl } from '../utils/validators/url/isValidUrl';
55
55
  import { isValidUuid } from '../utils/validators/uuid/isValidUuid';
56
56
  import { PROMPTBOOK_VERSION } from '../version';
57
57
  export { forEachAsync, PROMPTBOOK_VERSION };
58
+ export { extractParameters, extractVariables, replaceParameters, spaceTrim };
58
59
  export { $currentDate, $randomSeed, extractBlock, // <- [🌻] + maybe export through `@promptbook/markdown-utils`
59
- extractParameters, extractVariables, isHostnameOnPrivateNetwork, isUrlOnPrivateNetwork, isValidFilePath, isValidJavascriptName, isValidJsonString, isValidPipelineUrl, isValidPromptbookVersion, isValidSemanticVersion, isValidUrl, isValidUuid, parseNumber, // <- [🌻]
60
- removeEmojis, removeQuotes, replaceParameters, spaceTrim, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
60
+ isHostnameOnPrivateNetwork, isUrlOnPrivateNetwork, isValidFilePath, isValidJavascriptName, isValidJsonString, isValidPipelineUrl, isValidPromptbookVersion, isValidSemanticVersion, isValidUrl, isValidUuid, parseNumber, // <- [🌻]
61
+ removeEmojis, removeQuotes, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
61
62
  export { countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords };
62
63
  export { splitIntoSentences };
63
64
  export declare const normalizeTo: {
@@ -1,5 +1,4 @@
1
- import type { string_file_relative_path } from '../../types/typeAliases';
2
- import type { string_url } from '../../types/typeAliases';
1
+ import type { string_knowledge_source } from '../../types/typeAliases';
3
2
  /**
4
3
  * Parsed KNOWLEDGE command
5
4
  *
@@ -8,5 +7,5 @@ import type { string_url } from '../../types/typeAliases';
8
7
  */
9
8
  export type KnowledgeCommand = {
10
9
  readonly type: 'KNOWLEDGE';
11
- readonly source: string_url | string_file_relative_path;
10
+ readonly source: string_knowledge_source;
12
11
  };
@@ -1,7 +1,9 @@
1
1
  import type { WritableDeep } from 'type-fest';
2
+ import type { PromptTemplateJson } from '../../../types/PipelineJson/PromptTemplateJson';
2
3
  import type { PipelineJson } from '../../../types/PipelineJson/PipelineJson';
3
4
  import type { string_markdown_text } from '../../../types/typeAliases';
4
5
  import type { string_name } from '../../../types/typeAliases';
6
+ import type { string_promptbook_documentation_url } from '../../../types/typeAliases';
5
7
  import type { string_SCREAMING_CASE } from '../../../utils/normalization/normalizeTo_SCREAMING_CASE';
6
8
  import type { CommandUsagePlace } from './CommandUsagePlaces';
7
9
  export type CommandParser<TCommand extends {
@@ -12,13 +14,16 @@ export type CommandParser<TCommand extends {
12
14
  readonly deprecatedNames?: Array<string_name & string_SCREAMING_CASE>;
13
15
  readonly usagePlaces: Array<CommandUsagePlace>;
14
16
  readonly description: string_markdown_text;
15
- readonly discussionUrl: `https://github.com/webgptorg/promptbook/discussions/${number | '@@'}`;
17
+ readonly documentationUrl: string_promptbook_documentation_url;
16
18
  readonly examples: Array<string_markdown_text>;
17
19
  /**
18
20
  * @throws {ParsingError} if the parsing fails
19
21
  */
20
22
  parse(input: CommandParserInput): TCommand;
21
- applyToPipelineJson?(pipelineJson: WritableDeep<PipelineJson>, personaCommand: TCommand): void;
23
+ /**
24
+ * @@@ Mutated by the command
25
+ */
26
+ applyToPipelineJson?(command: TCommand, subjects: ApplyToPipelineJsonSubjects): void;
22
27
  };
23
28
  export type CommandParserInput = {
24
29
  readonly usagePlace: CommandUsagePlace;
@@ -27,10 +32,30 @@ export type CommandParserInput = {
27
32
  readonly normalized: string_name & string_SCREAMING_CASE;
28
33
  readonly args: Array<string_name & string_SCREAMING_CASE>;
29
34
  };
35
+ /**
36
+ * @@@ Mutated by the command
37
+ */
38
+ export type ApplyToPipelineJsonSubjects = {
39
+ /**
40
+ * @@@ Mutated by the command
41
+ */
42
+ readonly pipelineJson: WritableDeep<PipelineJson>;
43
+ /**
44
+ * @@@
45
+ *
46
+ * @@@ Mutated by the command
47
+ *
48
+ * When used in
49
+ * - `PIPELINE_HEAD` it is `null`
50
+ * - `PIPELINE_TEMPLATE` it is the prompt template
51
+ */
52
+ readonly templateJson: null | Partial<WritableDeep<PromptTemplateJson>>;
53
+ };
30
54
  /**
31
55
  * TODO: @@@ Annotate all
56
+ * TODO: [🍧][♓️] Add order here
32
57
  * TODO: [🧠] Maybe put flag if it is for whole `.ptbk.md` file of just one section
33
- * TODO: [🍧] CommandParser should have applyToPipelineJson method
58
+ * TODO: [🍧] All commands must implement `applyToPipelineJson` method
34
59
  * which will apply parsed command to the pipeline JSON
35
60
  * it will be called from `pipelineStringToJsonSync`
36
61
  * and replace hardcoded switch statement and [💐]
@@ -10,10 +10,28 @@ export declare const CHARACTER_LOOP_LIMIT = 100000;
10
10
  * The maximum number of (LLM) tasks running in parallel
11
11
  */
12
12
  export declare const MAX_PARALLEL_COUNT = 5;
13
+ /**
14
+ * The maximum number of attempts to execute LLM task before giving up
15
+ */
16
+ export declare const MAX_EXECUTION_ATTEMPTS = 3;
13
17
  /**
14
18
  * The maximum length of the (generated) filename
15
19
  */
16
20
  export declare const MAX_FILENAME_LENGTH = 30;
21
+ /**
22
+ * @@@
23
+ * TODO: [🐝] !!! Use
24
+ */
25
+ export declare const MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = 3;
26
+ /**
27
+ * @@@
28
+ * TODO: [🐝] !!! Use
29
+ */
30
+ export declare const MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = 200;
31
+ /**
32
+ * Where to store the cache of executions for promptbook CLI
33
+ */
34
+ export declare const EXECUTIONS_CACHE_DIRNAME = "/.promptbook/executions-cache";
17
35
  /**
18
36
  * The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
19
37
  */
@@ -21,8 +39,15 @@ export declare const PIPELINE_COLLECTION_BASE_FILENAME = "index";
21
39
  /**
22
40
  * The names of the parameters that are reserved for special purposes
23
41
  */
24
- export declare const RESERVED_PARAMETER_NAMES: readonly string[];
42
+ export declare const RESERVED_PARAMETER_NAMES: readonly ["context", "currentDate"];
43
+ /**
44
+ * @@@
45
+ */
46
+ export declare const DEBUG_ALLOW_PAYED_TESTING: boolean;
25
47
  /**
26
48
  * Nonce which is used for replacing things in strings
27
49
  */
28
50
  export declare const REPLACING_NONCE = "u$k42k%!V2zo34w7Fu#@QUHYPW";
51
+ /**
52
+ * TODO: [🔼] Export all to core
53
+ */
@@ -0,0 +1,4 @@
1
+ export {};
2
+ /**
3
+ * TODO: [🧠] Maybe more elegant how to prevent accidental costs
4
+ */
@@ -1,5 +1,5 @@
1
1
  import type { PromptTemplateJson } from '../../types/PipelineJson/PromptTemplateJson';
2
- import type { string_name } from '../../types/typeAliases';
2
+ import type { string_parameter_name } from '../../types/typeAliases';
3
3
  /**
4
4
  * Parses the prompt template and returns the set of all used parameters
5
5
  *
@@ -7,7 +7,7 @@ import type { string_name } from '../../types/typeAliases';
7
7
  * @returns the set of parameter names
8
8
  * @throws {ParsingError} if the script is invalid
9
9
  */
10
- export declare function extractParametersFromPromptTemplate(promptTemplate: Pick<PromptTemplateJson, 'title' | 'description' | 'blockType' | 'content'>): Set<string_name>;
10
+ export declare function extractParametersFromPromptTemplate(promptTemplate: Pick<PromptTemplateJson, 'title' | 'description' | 'blockType' | 'content' | 'jokerParameterNames'>): Set<string_parameter_name>;
11
11
  /**
12
12
  * TODO: [🔣] If script require contentLanguage
13
13
  */
@@ -7,7 +7,7 @@ import type { string_json } from '../../types/typeAliases';
7
7
  */
8
8
  export declare function stringifyPipelineJson<TType>(pipeline: TType): string_json<TType>;
9
9
  /**
10
+ * TODO: !!!! Not Working propperly @see https://promptbook.studio/samples/mixed-knowledge.ptbk.md
10
11
  * TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
11
- * TODO: [🔼] Export alongside pipelineStringToJson
12
12
  * TODO: [🧠] Maybe more elegant solution than replacing via regex
13
13
  */
@@ -28,6 +28,9 @@ export declare function validatePipeline(pipeline: PipelineJson): PipelineJson;
28
28
  /**
29
29
  * TODO: [🧠][🐣] !!!! Validate that all samples match expectations
30
30
  * TODO: [🧠][🐣] !!!! Validate that knowledge is valid (non-void)
31
+ * TODO: [🧠][🐣] !!!! Validate that persona can be used only with CHAT variant
32
+ * TODO: !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
33
+ * TODO: !!!! Validate that reserved parameter is not used as joker
31
34
  * TODO: [🧠] !!! Validationg not only logic itself but imports around - files and websites and rerefenced pipelines exists
32
35
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
33
36
  */
@@ -1,8 +1,8 @@
1
1
  import type { Promisable } from 'type-fest';
2
+ import { PipelineExecutionError } from '../errors/PipelineExecutionError';
2
3
  import type { TaskProgress } from '../types/TaskProgress';
3
4
  import type { ExecutionReportJson } from '../types/execution-report/ExecutionReportJson';
4
- import type { string_parameter_name } from '../types/typeAliases';
5
- import type { string_parameter_value } from '../types/typeAliases';
5
+ import type { Parameters } from '../types/typeAliases';
6
6
  import type { PromptResultUsage } from './PromptResultUsage';
7
7
  /**
8
8
  * Executor is a simple async function that takes INPUT PARAMETERs and returns result parameters _(along with all intermediate parameters and INPUT PARAMETERs = it extends input object)_.
@@ -13,7 +13,7 @@ import type { PromptResultUsage } from './PromptResultUsage';
13
13
  * @see https://github.com/webgptorg/promptbook#executor
14
14
  */
15
15
  export type PipelineExecutor = {
16
- (inputParameters: Record<string_parameter_name, string_parameter_value>, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
16
+ (inputParameters: Parameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
17
17
  /**
18
18
  * Whether the execution was successful, details are aviable in `executionReport`
19
19
  */
@@ -25,7 +25,7 @@ export type PipelineExecutor = {
25
25
  /**
26
26
  * Errors that occured during the execution, details are aviable in `executionReport`
27
27
  */
28
- readonly errors: Array<Error>;
28
+ readonly errors: Array<PipelineExecutionError | Error>;
29
29
  /**
30
30
  * The report of the execution with all details
31
31
  */
@@ -35,7 +35,7 @@ export type PipelineExecutor = {
35
35
  *
36
36
  * Note: If the execution was not successful, there are only some of the result parameters
37
37
  */
38
- readonly outputParameters: Record<string_parameter_name, string_parameter_value>;
38
+ readonly outputParameters: Parameters;
39
39
  }>;
40
40
  };
41
41
  /**