@promptbook/node 0.69.0-1 โ†’ 0.69.0-4

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 (27) hide show
  1. package/esm/index.es.js +1000 -911
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/core.index.d.ts +1 -1
  4. package/esm/typings/src/_packages/types.index.d.ts +6 -0
  5. package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +2 -6
  6. package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +26 -0
  7. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -4
  8. package/esm/typings/src/config.d.ts +7 -1
  9. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -0
  10. package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +2 -1
  11. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +4 -0
  12. package/esm/typings/src/execution/createPipelineExecutor/CreatePipelineExecutorOptions.d.ts +20 -0
  13. package/esm/typings/src/execution/createPipelineExecutor/CreatePipelineExecutorSettings.d.ts +30 -0
  14. package/esm/typings/src/execution/createPipelineExecutor/createPipelineExecutor.d.ts +24 -0
  15. package/esm/typings/src/execution/createPipelineExecutor/executeSingleTemplate.d.ts +27 -0
  16. package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +8 -0
  17. package/esm/typings/src/execution/createPipelineExecutor/getContextForTemplate.d.ts +8 -0
  18. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTemplate.d.ts +9 -0
  19. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTemplate.d.ts +8 -0
  20. package/esm/typings/src/execution/createPipelineExecutor/getSamplesForTemplate.d.ts +8 -0
  21. package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +1 -0
  22. package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +5 -0
  23. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +3 -0
  24. package/package.json +2 -2
  25. package/umd/index.umd.js +1000 -911
  26. package/umd/index.umd.js.map +1 -1
  27. package/esm/typings/src/execution/createPipelineExecutor.d.ts +0 -72
@@ -38,7 +38,7 @@ import { PipelineLogicError } from '../errors/PipelineLogicError';
38
38
  import { PipelineUrlError } from '../errors/PipelineUrlError';
39
39
  import { UnexpectedError } from '../errors/UnexpectedError';
40
40
  import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
41
- import { createPipelineExecutor } from '../execution/createPipelineExecutor';
41
+ import { createPipelineExecutor } from '../execution/createPipelineExecutor/createPipelineExecutor';
42
42
  import { embeddingVectorToString } from '../execution/embeddingVectorToString';
43
43
  import { ZERO_USAGE } from '../execution/utils/addUsage';
44
44
  import { addUsage } from '../execution/utils/addUsage';
@@ -7,6 +7,7 @@ import type { PipelineTemplateCommandParser } from '../commands/_common/types/Co
7
7
  import type { CommandParserInput } from '../commands/_common/types/CommandParser';
8
8
  import type { CommandUsagePlace } from '../commands/_common/types/CommandUsagePlaces';
9
9
  import type { ExpectCommand } from '../commands/EXPECT/ExpectCommand';
10
+ import type { ForeachJson } from '../commands/FOREACH/ForeachJson';
10
11
  import type { FormatCommand } from '../commands/FORMAT/FormatCommand';
11
12
  import type { TemplateType } from '../commands/TEMPLATE/TemplateTypes';
12
13
  import type { PipelineStringToJsonOptions } from '../conversion/pipelineStringToJson';
@@ -15,6 +16,8 @@ import type { renderPipelineMermaidOptions } from '../conversion/prettify/render
15
16
  import type { ErrorJson } from '../errors/utils/ErrorJson';
16
17
  import type { AvailableModel } from '../execution/AvailableModel';
17
18
  import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionToolsOptions';
19
+ import type { CreatePipelineExecutorOptions } from '../execution/createPipelineExecutor/CreatePipelineExecutorOptions';
20
+ import type { CreatePipelineExecutorSettings } from '../execution/createPipelineExecutor/CreatePipelineExecutorSettings';
18
21
  import type { EmbeddingVector } from '../execution/EmbeddingVector';
19
22
  import type { ExecutionTools } from '../execution/ExecutionTools';
20
23
  import type { LlmExecutionTools } from '../execution/LlmExecutionTools';
@@ -232,6 +235,7 @@ export type { PipelineTemplateCommandParser };
232
235
  export type { CommandParserInput };
233
236
  export type { CommandUsagePlace };
234
237
  export type { ExpectCommand };
238
+ export type { ForeachJson };
235
239
  export type { FormatCommand };
236
240
  export type { TemplateType };
237
241
  export type { PipelineStringToJsonOptions };
@@ -240,6 +244,8 @@ export type { renderPipelineMermaidOptions };
240
244
  export type { ErrorJson };
241
245
  export type { AvailableModel };
242
246
  export type { CommonExecutionToolsOptions };
247
+ export type { CreatePipelineExecutorOptions };
248
+ export type { CreatePipelineExecutorSettings };
243
249
  export type { EmbeddingVector };
244
250
  export type { ExecutionTools };
245
251
  export type { LlmExecutionTools };
@@ -1,5 +1,4 @@
1
- import type { string_parameter_name } from '../../types/typeAliases';
2
- import type { TODO_string } from '../../utils/organization/TODO_string';
1
+ import type { ForeachJson } from './ForeachJson';
3
2
  /**
4
3
  * Parsed FOREACH command <- Write [๐Ÿญ] !!!!!!
5
4
  *
@@ -8,7 +7,4 @@ import type { TODO_string } from '../../utils/organization/TODO_string';
8
7
  */
9
8
  export type ForeachCommand = {
10
9
  readonly type: 'FOREACH';
11
- formatName: TODO_string;
12
- cellName: TODO_string;
13
- parameterName: string_parameter_name;
14
- };
10
+ } & ForeachJson;
@@ -0,0 +1,26 @@
1
+ import type { string_parameter_name } from '../../types/typeAliases';
2
+ import type { TODO_string } from '../../utils/organization/TODO_string';
3
+ /**
4
+ * @@@
5
+ */
6
+ export type ForeachJson = {
7
+ /**
8
+ * @@@
9
+ */
10
+ readonly formatName: TODO_string;
11
+ /**
12
+ * @@@
13
+ */
14
+ readonly cellName: TODO_string;
15
+ /**
16
+ * @@@
17
+ */
18
+ readonly parameterName: string_parameter_name;
19
+ /**
20
+ * @@@
21
+ */
22
+ readonly subparameterName: string_parameter_name;
23
+ };
24
+ /**
25
+ * TODO: [๐Ÿง ] Betetr name for `parameterName` and `subparameterName`
26
+ */
@@ -156,28 +156,28 @@ export type CommandParserInput = {
156
156
  * @@@
157
157
  *
158
158
  * @example 'promptbook version 0.62.0'
159
- * @example 'FOREACH List Line -> `{customer}`'
159
+ * @example 'FOREACH List Line `{customers}` -> `{customer}`'
160
160
  */
161
161
  readonly raw: string_markdown_text;
162
162
  /**
163
163
  * @@@
164
164
  *
165
165
  * @example '0.62.0'
166
- * @example 'List Line -> `{customer}`'
166
+ * @example 'List Line `{customers}` -> `{customer}`'
167
167
  */
168
168
  readonly rawArgs: string_markdown_text;
169
169
  /**
170
170
  * @@@
171
171
  *
172
172
  * @example 'PROMPTBOOK_VERSION_0_62_0'
173
- * @example 'FOREACH_LIST_LINE_CUSTOMER'
173
+ * @example 'FOREACH_LIST_LINE_CUSTOMERS_CUSTOMER'
174
174
  */
175
175
  readonly normalized: string_name & string_SCREAMING_CASE;
176
176
  /**
177
177
  * @@@
178
178
  *
179
179
  * @example [ '0.62.0' ]
180
- * @example [ 'List', 'Line', '', '{customer}' ]
180
+ * @example [ 'List', 'Line', '{customers}', '', '{customer}' ]
181
181
  */
182
182
  readonly args: Array<string_name>;
183
183
  };
@@ -148,7 +148,13 @@ export declare const IS_VERBOSE = false;
148
148
  *
149
149
  * @private within the repository
150
150
  */
151
- export declare const DEBUG_ALLOW_PAYED_TESTING: boolean;
151
+ export declare const IS_COST_PREVENTED: boolean;
152
+ /**
153
+ * @@@
154
+ *
155
+ * @private within the repository
156
+ */
157
+ export declare const IS_PIPELINE_LOGIC_VALIDATED: boolean;
152
158
  /**
153
159
  * TODO: [๐Ÿง ][๐Ÿงœโ€โ™‚๏ธ] Maybe join remoteUrl and path into single value
154
160
  */
@@ -22,6 +22,9 @@ export type renderPipelineMermaidOptions = {
22
22
  */
23
23
  export declare function renderPromptbookMermaid(pipelineJson: PipelineJson, options?: renderPipelineMermaidOptions): string;
24
24
  /**
25
+ * TODO: !!!!!! FOREACH in mermaid graph
26
+ * TODO: !!!!!! Knowledge in mermaid graph
27
+ * TODO: !!!!!! Personas in mermaid graph
25
28
  * TODO: Maybe use some Mermaid package instead of string templating
26
29
  * TODO: [๐Ÿ•Œ] When more than 2 functionalities, split into separate functions
27
30
  */
@@ -1,3 +1,4 @@
1
+ import type { ReadonlyDeep } from 'type-fest';
1
2
  import type { TemplateJson } from '../../types/PipelineJson/TemplateJson';
2
3
  import type { string_parameter_name } from '../../types/typeAliases';
3
4
  /**
@@ -8,7 +9,7 @@ import type { string_parameter_name } from '../../types/typeAliases';
8
9
  * @throws {ParseError} if the script is invalid
9
10
  * @public exported from `@promptbook/utils`
10
11
  */
11
- export declare function extractParameterNamesFromTemplate(template: Pick<TemplateJson, 'title' | 'description' | 'templateType' | 'content' | 'preparedContent' | 'jokerParameterNames'>): Set<string_parameter_name>;
12
+ export declare function extractParameterNamesFromTemplate(template: ReadonlyDeep<Pick<TemplateJson, 'title' | 'description' | 'templateType' | 'content' | 'preparedContent' | 'jokerParameterNames' | 'foreach'>>): Set<string_parameter_name>;
12
13
  /**
13
14
  * TODO: [๐Ÿ”ฃ] If script require contentLanguage
14
15
  */
@@ -15,6 +15,10 @@ import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
15
15
  * @public exported from `@promptbook/core`
16
16
  */
17
17
  export declare function validatePipeline(pipeline: PipelineJson): PipelineJson;
18
+ /**
19
+ * @private internal function for `validatePipeline`
20
+ */
21
+ export declare function validatePipelineCore(pipeline: PipelineJson): void;
18
22
  /**
19
23
  * TODO: [๐Ÿง ] Work with promptbookVersion
20
24
  * TODO: Use here some json-schema, Zod or something similar and change it to:
@@ -0,0 +1,20 @@
1
+ import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
2
+ import type { ExecutionTools } from '../ExecutionTools';
3
+ import type { CreatePipelineExecutorSettings } from './CreatePipelineExecutorSettings';
4
+ /**
5
+ * Options for `createPipelineExecutor`
6
+ */
7
+ export interface CreatePipelineExecutorOptions {
8
+ /**
9
+ * The pipeline to be executed
10
+ */
11
+ readonly pipeline: PipelineJson;
12
+ /**
13
+ * The execution tools to be used during the execution of the pipeline
14
+ */
15
+ readonly tools: ExecutionTools;
16
+ /**
17
+ * Optional settings for the pipeline executor
18
+ */
19
+ readonly settings?: Partial<CreatePipelineExecutorSettings>;
20
+ }
@@ -0,0 +1,30 @@
1
+ export type CreatePipelineExecutorSettings = {
2
+ /**
3
+ * When executor does not satisfy expectations it will be retried this amount of times
4
+ *
5
+ * @default MAX_EXECUTION_ATTEMPTS
6
+ */
7
+ readonly maxExecutionAttempts?: number;
8
+ /**
9
+ * Maximum number of tasks running in parallel
10
+ *
11
+ * @default MAX_PARALLEL_COUNT
12
+ */
13
+ readonly maxParallelCount?: number;
14
+ /**
15
+ * If true, the preparation logs additional information
16
+ *
17
+ * @default false
18
+ */
19
+ readonly isVerbose?: boolean;
20
+ /**
21
+ * If you pass fully prepared pipeline, this does not matter
22
+ *
23
+ * Otherwise:
24
+ * If false or not set, warning is shown when pipeline is not prepared
25
+ * If true, warning is suppressed
26
+ *
27
+ * @default false
28
+ */
29
+ readonly isNotPreparedWarningSupressed?: boolean;
30
+ };
@@ -0,0 +1,24 @@
1
+ import type { PipelineExecutor } from '../PipelineExecutor';
2
+ import type { CreatePipelineExecutorOptions } from './CreatePipelineExecutorOptions';
3
+ /**
4
+ * Creates executor function from pipeline and execution tools.
5
+ *
6
+ * @returns The executor function
7
+ * @throws {PipelineLogicError} on logical error in the pipeline
8
+ * @public exported from `@promptbook/core`
9
+ */
10
+ export declare function createPipelineExecutor(options: CreatePipelineExecutorOptions): PipelineExecutor;
11
+ /**
12
+ * TODO: [๐Ÿคนโ€โ™‚๏ธ] Make some smarter system for limiting concurrent executions MAX_PARALLEL_TOTAL, MAX_PARALLEL_PER_LLM
13
+ * TODO: !!! Identify not only pipeline BUT exact template ${block(pipelineIdentification)}
14
+ * TODO: Use isVerbose here (not only pass to `preparePipeline`)
15
+ * TODO: [๐Ÿง ][๐ŸŒณ] Use here `countTotalUsage` and put preparation and prepared pipiline to report
16
+ * TODO: [๐Ÿช‚] Use maxParallelCount here (not only pass to `preparePipeline`)
17
+ * TODO: [โ™ˆ] Probbably move expectations from templates to parameters
18
+ * TODO: [๐Ÿง ] When not meet expectations in DIALOG_TEMPLATE, make some way to tell the user
19
+ * TODO: [๐Ÿ‘ง] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
20
+ * Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
21
+ * TODO: [๐Ÿง ][๐Ÿธ] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
22
+ * TODO: [๐Ÿ› ] Actions, instruments (and maybe knowledge) => Functions and tools
23
+ * TODO: [๐Ÿง ][๐Ÿ’ท] `assertsExecutionSuccessful` should be the method of `PipelineExecutor` result BUT maybe NOT to preserve pure JSON object
24
+ */
@@ -0,0 +1,27 @@
1
+ import { Promisable, ReadonlyDeep } from 'type-fest';
2
+ import type { ExecutionReportJson } from '../../types/execution-report/ExecutionReportJson';
3
+ import type { ExecutionTools } from '../ExecutionTools';
4
+ import { MultipleLlmExecutionTools } from '../../llm-providers/multiple/MultipleLlmExecutionTools';
5
+ import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
6
+ import type { TemplateJson } from '../../types/PipelineJson/TemplateJson';
7
+ import type { TaskProgress } from '../../types/TaskProgress';
8
+ import type { Parameters } from '../../types/typeAliases';
9
+ type executeSingleTemplateOptions = {
10
+ currentTemplate: ReadonlyDeep<TemplateJson>;
11
+ preparedPipeline: ReadonlyDeep<PipelineJson>;
12
+ parametersToPass: Readonly<Parameters>;
13
+ tools: Omit<ExecutionTools, 'llm'>;
14
+ llmTools: MultipleLlmExecutionTools;
15
+ onProgress: (taskProgress: TaskProgress) => Promisable<void>;
16
+ maxExecutionAttempts: number;
17
+ $executionReport: ExecutionReportJson;
18
+ pipelineIdentification: string;
19
+ };
20
+ /**
21
+ * @private @@@
22
+ */
23
+ export declare function executeSingleTemplate(options: executeSingleTemplateOptions): Promise<Readonly<Parameters>>;
24
+ export {};
25
+ /**
26
+ * TODO: [๐Ÿคนโ€โ™‚๏ธ]
27
+ */
@@ -0,0 +1,8 @@
1
+ import type { ReadonlyDeep } from 'type-fest';
2
+ import { PipelineExecutionError } from '../../errors/PipelineExecutionError';
3
+ import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
4
+ import type { Parameters } from '../../types/typeAliases';
5
+ /**
6
+ * @private @@@
7
+ */
8
+ export declare function filterJustOutputParameters(preparedPipeline: ReadonlyDeep<PipelineJson>, parametersToPass: Readonly<Parameters>, $warnings: PipelineExecutionError[], pipelineIdentification: string): Parameters;
@@ -0,0 +1,8 @@
1
+ import type { ReadonlyDeep } from 'type-fest';
2
+ import type { TemplateJson } from '../../types/PipelineJson/TemplateJson';
3
+ import type { string_markdown } from '../../types/typeAliases';
4
+ import type { string_parameter_value } from '../../types/typeAliases';
5
+ /**
6
+ * @private @@@
7
+ */
8
+ export declare function getContextForTemplate(template: ReadonlyDeep<TemplateJson>): Promise<string_parameter_value & string_markdown>;
@@ -0,0 +1,9 @@
1
+ import type { ReadonlyDeep } from 'type-fest';
2
+ import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
3
+ import type { TemplateJson } from '../../types/PipelineJson/TemplateJson';
4
+ import type { string_markdown } from '../../types/typeAliases';
5
+ import type { string_parameter_value } from '../../types/typeAliases';
6
+ /**
7
+ * @private @@@
8
+ */
9
+ export declare function getKnowledgeForTemplate(preparedPipeline: ReadonlyDeep<PipelineJson>, template: ReadonlyDeep<TemplateJson>): Promise<string_parameter_value & string_markdown>;
@@ -0,0 +1,8 @@
1
+ import type { ReadonlyDeep } from 'type-fest';
2
+ import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
3
+ import type { TemplateJson } from '../../types/PipelineJson/TemplateJson';
4
+ import type { ReservedParameters } from '../../types/typeAliases';
5
+ /**
6
+ * @private @@@
7
+ */
8
+ export declare function getReservedParametersForTemplate(preparedPipeline: ReadonlyDeep<PipelineJson>, template: ReadonlyDeep<TemplateJson>, pipelineIdentification: string): Promise<Readonly<ReservedParameters>>;
@@ -0,0 +1,8 @@
1
+ import type { ReadonlyDeep } from 'type-fest';
2
+ import type { TemplateJson } from '../../types/PipelineJson/TemplateJson';
3
+ import type { string_markdown } from '../../types/typeAliases';
4
+ import type { string_parameter_value } from '../../types/typeAliases';
5
+ /**
6
+ * @private @@@
7
+ */
8
+ export declare function getSamplesForTemplate(template: ReadonlyDeep<TemplateJson>): Promise<string_parameter_value & string_markdown>;
@@ -33,6 +33,7 @@ export type ParameterJson = {
33
33
  readonly sampleValues?: Array<string_parameter_value>;
34
34
  };
35
35
  /**
36
+ * TODO: [๐Ÿง ] !!!!!! Should be here registered subparameter from foreach or not?
36
37
  * TODO: [โ™ˆ] Probbably move expectations from templates to parameters
37
38
  * TODO: [๐Ÿ™] Make some standard order of json properties
38
39
  */
@@ -1,3 +1,4 @@
1
+ import type { ForeachJson } from '../../commands/FOREACH/ForeachJson';
1
2
  import type { FormatCommand } from '../../commands/FORMAT/FormatCommand';
2
3
  import type { TemplateType } from '../../commands/TEMPLATE/TemplateTypes';
3
4
  import type { string_javascript } from '../typeAliases';
@@ -42,6 +43,10 @@ export interface TemplateJsonCommon {
42
43
  * @see https://github.com/webgptorg/promptbook/discussions/66
43
44
  */
44
45
  readonly jokerParameterNames?: Array<string_parameter_name>;
46
+ /**
47
+ * @@@
48
+ */
49
+ readonly foreach?: ForeachJson;
45
50
  /**
46
51
  * Type of the execution
47
52
  * This determines if the template is send to LLM, user or some scripting evaluation
@@ -39,3 +39,6 @@ export type ExecutionReportJson = {
39
39
  */
40
40
  readonly promptExecutions: Array<ExecutionPromptReportJson>;
41
41
  };
42
+ /**
43
+ * TODO: !!!!!! FOREACH in report
44
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.69.0-1",
3
+ "version": "0.69.0-4",
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-1"
50
+ "@promptbook/core": "0.69.0-4"
51
51
  },
52
52
  "dependencies": {
53
53
  "colors": "1.4.0",