@promptbook/types 0.69.0-2 → 0.69.0-5

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 (18) hide show
  1. package/esm/typings/src/_packages/core.index.d.ts +1 -1
  2. package/esm/typings/src/_packages/types.index.d.ts +4 -0
  3. package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +2 -1
  4. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +5 -3
  5. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +20 -0
  6. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +30 -0
  7. package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +10 -0
  8. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +55 -0
  9. package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +62 -0
  10. package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatCell.d.ts +30 -0
  11. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempt.d.ts +30 -0
  12. package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +34 -0
  13. package/esm/typings/src/execution/createPipelineExecutor/getContextForTemplate.d.ts +10 -0
  14. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTemplate.d.ts +27 -0
  15. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTemplate.d.ts +30 -0
  16. package/esm/typings/src/execution/createPipelineExecutor/getSamplesForTemplate.d.ts +10 -0
  17. package/package.json +2 -2
  18. 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/00-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';
@@ -16,6 +16,8 @@ import type { renderPipelineMermaidOptions } from '../conversion/prettify/render
16
16
  import type { ErrorJson } from '../errors/utils/ErrorJson';
17
17
  import type { AvailableModel } from '../execution/AvailableModel';
18
18
  import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionToolsOptions';
19
+ import type { CreatePipelineExecutorOptions } from '../execution/createPipelineExecutor/00-CreatePipelineExecutorOptions';
20
+ import type { CreatePipelineExecutorSettings } from '../execution/createPipelineExecutor/00-CreatePipelineExecutorSettings';
19
21
  import type { EmbeddingVector } from '../execution/EmbeddingVector';
20
22
  import type { ExecutionTools } from '../execution/ExecutionTools';
21
23
  import type { LlmExecutionTools } from '../execution/LlmExecutionTools';
@@ -242,6 +244,8 @@ export type { renderPipelineMermaidOptions };
242
244
  export type { ErrorJson };
243
245
  export type { AvailableModel };
244
246
  export type { CommonExecutionToolsOptions };
247
+ export type { CreatePipelineExecutorOptions };
248
+ export type { CreatePipelineExecutorSettings };
245
249
  export type { EmbeddingVector };
246
250
  export type { ExecutionTools };
247
251
  export type { LlmExecutionTools };
@@ -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' | 'foreach'>): 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
  */
@@ -1,7 +1,8 @@
1
+ import { ReadonlyDeep } from 'type-fest';
2
+ import type { ErrorJson } from '../errors/utils/ErrorJson';
1
3
  import type { ExecutionReportJson } from '../types/execution-report/ExecutionReportJson';
2
- import type { Parameters } from '../types/typeAliases';
3
4
  import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
4
- import type { ErrorJson } from '../errors/utils/ErrorJson';
5
+ import type { Parameters } from '../types/typeAliases';
5
6
  import type { PromptResultUsage } from './PromptResultUsage';
6
7
  /**
7
8
  * @@@
@@ -41,9 +42,10 @@ export type PipelineExecutorResult = {
41
42
  * Note: If you called `createPipelineExecutor` with fully prepared pipeline, this is the same object as this pipeline
42
43
  * If you passed not fully prepared pipeline, this is same pipeline but fully prepared
43
44
  */
44
- readonly preparedPipeline: PipelineJson;
45
+ readonly preparedPipeline: ReadonlyDeep<PipelineJson>;
45
46
  };
46
47
  /**
48
+ * TODO: !!!!!! Maybe add ReadonlyDeep< to all
47
49
  * TODO: [🧠] Should this file be in /execution or /types folder?
48
50
  * TODO: [🧠] Maybe constrain `ErrorJson` -> `ErrorJson & { name: 'PipelineExecutionError' | 'Error' }`
49
51
  */
@@ -0,0 +1,20 @@
1
+ import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
2
+ import type { ExecutionTools } from '../ExecutionTools';
3
+ import type { CreatePipelineExecutorSettings } from './00-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,10 @@
1
+ import type { PipelineExecutor } from '../PipelineExecutor';
2
+ import type { CreatePipelineExecutorOptions } from './00-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;
@@ -0,0 +1,55 @@
1
+ import type { Promisable, ReadonlyDeep } from 'type-fest';
2
+ import type { CreatePipelineExecutorSettings } from './00-CreatePipelineExecutorSettings';
3
+ import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
4
+ import type { TaskProgress } from '../../types/TaskProgress';
5
+ import type { Parameters } from '../../types/typeAliases';
6
+ import type { ExecutionTools } from '../ExecutionTools';
7
+ import type { PipelineExecutorResult } from '../PipelineExecutorResult';
8
+ /**
9
+ * @@@
10
+ *
11
+ * @private internal type of `executePipelinex`
12
+ */
13
+ type ExecutePipelineOptions = {
14
+ /**
15
+ * @@@
16
+ */
17
+ readonly inputParameters: Readonly<Parameters>;
18
+ /**
19
+ * @@@
20
+ */
21
+ readonly tools: ExecutionTools;
22
+ /**
23
+ * @@@
24
+ */
25
+ readonly onProgress?: (taskProgress: TaskProgress) => Promisable<void>;
26
+ /**
27
+ * @@@
28
+ */
29
+ readonly pipeline: PipelineJson;
30
+ /**
31
+ * @@@
32
+ */
33
+ readonly preparedPipeline: ReadonlyDeep<PipelineJson>;
34
+ /**
35
+ * @@@
36
+ */
37
+ readonly setPreparedPipeline: (preparedPipeline: ReadonlyDeep<PipelineJson>) => void;
38
+ /**
39
+ * @@@
40
+ */
41
+ readonly pipelineIdentification: string;
42
+ /**
43
+ * Settings for the pipeline executor
44
+ */
45
+ readonly settings: CreatePipelineExecutorSettings;
46
+ };
47
+ /**
48
+ * @@@
49
+ *
50
+ * Note: This is not a `PipelineExecutor` (which is binded with one exact pipeline), but a utility function of `createPipelineExecutor` which creates `PipelineExecutor`
51
+ *
52
+ * @private internal utility of `createPipelineExecutor`
53
+ */
54
+ export declare function executePipeline(options: ExecutePipelineOptions): Promise<PipelineExecutorResult>;
55
+ export {};
@@ -0,0 +1,62 @@
1
+ import { Promisable, ReadonlyDeep } from 'type-fest';
2
+ import { MultipleLlmExecutionTools } from '../../llm-providers/multiple/MultipleLlmExecutionTools';
3
+ import type { ExecutionReportJson } from '../../types/execution-report/ExecutionReportJson';
4
+ import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
5
+ import type { TemplateJson } from '../../types/PipelineJson/TemplateJson';
6
+ import type { TaskProgress } from '../../types/TaskProgress';
7
+ import type { Parameters } from '../../types/typeAliases';
8
+ import type { ExecutionTools } from '../ExecutionTools';
9
+ import type { CreatePipelineExecutorSettings } from './00-CreatePipelineExecutorSettings';
10
+ /**
11
+ * @@@
12
+ *
13
+ * @private internal type of `executeTemplate`
14
+ */
15
+ type executeSingleTemplateOptions = {
16
+ /**
17
+ * @@@
18
+ */
19
+ readonly currentTemplate: ReadonlyDeep<TemplateJson>;
20
+ /**
21
+ * @@@
22
+ */
23
+ readonly preparedPipeline: ReadonlyDeep<PipelineJson>;
24
+ /**
25
+ * @@@
26
+ */
27
+ readonly parametersToPass: Readonly<Parameters>;
28
+ /**
29
+ * @@@
30
+ */
31
+ readonly tools: Omit<ExecutionTools, 'llm'>;
32
+ /**
33
+ * @@@
34
+ */
35
+ readonly llmTools: MultipleLlmExecutionTools;
36
+ /**
37
+ * @@@
38
+ */
39
+ readonly onProgress: (taskProgress: TaskProgress) => Promisable<void>;
40
+ /**
41
+ * Settings for the pipeline executor
42
+ */
43
+ readonly settings: CreatePipelineExecutorSettings;
44
+ /**
45
+ * @@@
46
+ */
47
+ readonly $executionReport: ExecutionReportJson;
48
+ /**
49
+ * @@@
50
+ */
51
+ readonly pipelineIdentification: string;
52
+ };
53
+ /**
54
+ * @@@
55
+ *
56
+ * @private internal utility of `createPipelineExecutor`
57
+ */
58
+ export declare function executeTemplate(options: executeSingleTemplateOptions): Promise<Readonly<Parameters>>;
59
+ export {};
60
+ /**
61
+ * TODO: [🤹‍♂️]
62
+ */
@@ -0,0 +1,30 @@
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 { TODO_any } from '../../utils/organization/TODO_any';
5
+ /**
6
+ * @@@
7
+ *
8
+ * @private internal type of `executeFormatCell`
9
+ */
10
+ type ExecuteFormatCellOptions = {
11
+ /**
12
+ * @@@
13
+ */
14
+ readonly preparedPipeline: ReadonlyDeep<PipelineJson>;
15
+ /**
16
+ * @@@
17
+ */
18
+ readonly template: ReadonlyDeep<TemplateJson>;
19
+ /**
20
+ * @@@
21
+ */
22
+ readonly pipelineIdentification: string;
23
+ };
24
+ /**
25
+ * @@@
26
+ *
27
+ * @private internal utility of `createPipelineExecutor`
28
+ */
29
+ export declare function executeFormatCell(options: ExecuteFormatCellOptions): Promise<TODO_any>;
30
+ export {};
@@ -0,0 +1,30 @@
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 { TODO_any } from '../../utils/organization/TODO_any';
5
+ /**
6
+ * @@@
7
+ *
8
+ * @private internal type of `executeAttempt`
9
+ */
10
+ type ExecuteAttemptOptions = {
11
+ /**
12
+ * @@@
13
+ */
14
+ readonly preparedPipeline: ReadonlyDeep<PipelineJson>;
15
+ /**
16
+ * @@@
17
+ */
18
+ readonly template: ReadonlyDeep<TemplateJson>;
19
+ /**
20
+ * @@@
21
+ */
22
+ readonly pipelineIdentification: string;
23
+ };
24
+ /**
25
+ * @@@
26
+ *
27
+ * @private internal utility of `createPipelineExecutor`
28
+ */
29
+ export declare function executeAttempt(options: ExecuteAttemptOptions): Promise<TODO_any>;
30
+ export {};
@@ -0,0 +1,34 @@
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
+ * @@@
7
+ *
8
+ * @private internal type of `createPipelineExecutor`
9
+ */
10
+ type FilterJustOutputParametersOptions = {
11
+ /**
12
+ * @@@
13
+ */
14
+ readonly preparedPipeline: ReadonlyDeep<PipelineJson>;
15
+ /**
16
+ * @@@
17
+ */
18
+ readonly parametersToPass: Readonly<Parameters>;
19
+ /**
20
+ * @@@
21
+ */
22
+ readonly $warnings: PipelineExecutionError[];
23
+ /**
24
+ * @@@
25
+ */
26
+ readonly pipelineIdentification: string;
27
+ };
28
+ /**
29
+ * @@@
30
+ *
31
+ * @private internal utility of `createPipelineExecutor`
32
+ */
33
+ export declare function filterJustOutputParameters(options: FilterJustOutputParametersOptions): Parameters;
34
+ export {};
@@ -0,0 +1,10 @@
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
+ * @@@
7
+ *
8
+ * @private internal utility of `createPipelineExecutor`
9
+ */
10
+ export declare function getContextForTemplate(template: ReadonlyDeep<TemplateJson>): Promise<string_parameter_value & string_markdown>;
@@ -0,0 +1,27 @@
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
+ * @@@
8
+ *
9
+ * @private internal type of `getKnowledgeForTemplate`
10
+ */
11
+ type GetKnowledgeForTemplateOptions = {
12
+ /**
13
+ * @@@
14
+ */
15
+ readonly preparedPipeline: ReadonlyDeep<PipelineJson>;
16
+ /**
17
+ * @@@
18
+ */
19
+ readonly template: ReadonlyDeep<TemplateJson>;
20
+ };
21
+ /**
22
+ * @@@
23
+ *
24
+ * @private internal utility of `createPipelineExecutor`
25
+ */
26
+ export declare function getKnowledgeForTemplate(options: GetKnowledgeForTemplateOptions): Promise<string_parameter_value & string_markdown>;
27
+ export {};
@@ -0,0 +1,30 @@
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
+ * @@@
7
+ *
8
+ * @private internal type of `getReservedParametersForTemplate`
9
+ */
10
+ type GetReservedParametersForTemplateOptions = {
11
+ /**
12
+ * @@@
13
+ */
14
+ readonly preparedPipeline: ReadonlyDeep<PipelineJson>;
15
+ /**
16
+ * @@@
17
+ */
18
+ readonly template: ReadonlyDeep<TemplateJson>;
19
+ /**
20
+ * @@@
21
+ */
22
+ readonly pipelineIdentification: string;
23
+ };
24
+ /**
25
+ * @@@
26
+ *
27
+ * @private internal utility of `createPipelineExecutor`
28
+ */
29
+ export declare function getReservedParametersForTemplate(options: GetReservedParametersForTemplateOptions): Promise<Readonly<ReservedParameters>>;
30
+ export {};
@@ -0,0 +1,10 @@
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
+ * @@@
7
+ *
8
+ * @private internal utility of `createPipelineExecutor`
9
+ */
10
+ export declare function getSamplesForTemplate(template: ReadonlyDeep<TemplateJson>): Promise<string_parameter_value & string_markdown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/types",
3
- "version": "0.69.0-2",
3
+ "version": "0.69.0-5",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -45,6 +45,6 @@
45
45
  ],
46
46
  "typings": "./esm/typings/src/_packages/types.index.d.ts",
47
47
  "peerDependencies": {
48
- "@promptbook/core": "0.69.0-2"
48
+ "@promptbook/core": "0.69.0-5"
49
49
  }
50
50
  }
@@ -1,72 +0,0 @@
1
- import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
2
- import type { ExecutionTools } from './ExecutionTools';
3
- import type { PipelineExecutor } from './PipelineExecutor';
4
- type CreatePipelineExecutorSettings = {
5
- /**
6
- * When executor does not satisfy expectations it will be retried this amount of times
7
- *
8
- * @default MAX_EXECUTION_ATTEMPTS
9
- */
10
- readonly maxExecutionAttempts?: number;
11
- /**
12
- * Maximum number of tasks running in parallel
13
- *
14
- * @default MAX_PARALLEL_COUNT
15
- */
16
- readonly maxParallelCount?: number;
17
- /**
18
- * If true, the preparation logs additional information
19
- *
20
- * @default false
21
- */
22
- readonly isVerbose?: boolean;
23
- /**
24
- * If you pass fully prepared pipeline, this does not matter
25
- *
26
- * Otherwise:
27
- * If false or not set, warning is shown when pipeline is not prepared
28
- * If true, warning is suppressed
29
- *
30
- * @default false
31
- */
32
- readonly isNotPreparedWarningSupressed?: boolean;
33
- };
34
- /**
35
- * Options for `createPipelineExecutor`
36
- */
37
- interface CreatePipelineExecutorOptions {
38
- /**
39
- * The pipeline to be executed
40
- */
41
- readonly pipeline: PipelineJson;
42
- /**
43
- * The execution tools to be used during the execution of the pipeline
44
- */
45
- readonly tools: ExecutionTools;
46
- /**
47
- * Optional settings for the pipeline executor
48
- */
49
- readonly settings?: Partial<CreatePipelineExecutorSettings>;
50
- }
51
- /**
52
- * Creates executor function from pipeline and execution tools.
53
- *
54
- * @returns The executor function
55
- * @throws {PipelineLogicError} on logical error in the pipeline
56
- * @public exported from `@promptbook/core`
57
- */
58
- export declare function createPipelineExecutor(options: CreatePipelineExecutorOptions): PipelineExecutor;
59
- export {};
60
- /**
61
- * TODO: !!! Identify not only pipeline BUT exact template ${block(pipelineIdentification)}
62
- * TODO: Use isVerbose here (not only pass to `preparePipeline`)
63
- * TODO: [🧠][🌳] Use here `countTotalUsage` and put preparation and prepared pipiline to report
64
- * TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
65
- * TODO: [♈] Probbably move expectations from templates to parameters
66
- * TODO: [🧠] When not meet expectations in DIALOG_TEMPLATE, make some way to tell the user
67
- * TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
68
- * Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
69
- * TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
70
- * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
71
- * TODO: [🧠][💷] `assertsExecutionSuccessful` should be the method of `PipelineExecutor` result BUT maybe NOT to preserve pure JSON object
72
- */