@promptbook/openai 0.61.0-22 → 0.61.0-24

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 (48) hide show
  1. package/README.md +41 -0
  2. package/esm/index.es.js +43 -16
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/types.index.d.ts +2 -2
  5. package/esm/typings/src/config.d.ts +8 -4
  6. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -0
  7. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -0
  8. package/esm/typings/src/execution/PipelineExecutor.d.ts +32 -24
  9. package/esm/typings/src/execution/PromptResultUsage.d.ts +3 -0
  10. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +4 -0
  11. package/esm/typings/src/prepare/preparePipeline.d.ts +0 -1
  12. package/esm/typings/src/prepare/prepareTemplates.d.ts +31 -0
  13. package/esm/typings/src/prepare/unpreparePipeline.d.ts +2 -0
  14. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +3 -0
  15. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +3 -0
  16. package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +1 -0
  17. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +3 -0
  18. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -0
  19. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -0
  20. package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +4 -3
  21. package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +10 -0
  22. package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +1 -0
  23. package/esm/typings/src/types/PipelineJson/ScriptJson.d.ts +5 -2
  24. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +5 -2
  25. package/package.json +2 -2
  26. package/umd/index.umd.js +43 -16
  27. package/umd/index.umd.js.map +1 -1
  28. package/umd/typings/src/_packages/types.index.d.ts +2 -2
  29. package/umd/typings/src/config.d.ts +8 -4
  30. package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -0
  31. package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -0
  32. package/umd/typings/src/execution/PipelineExecutor.d.ts +32 -24
  33. package/umd/typings/src/execution/PromptResultUsage.d.ts +3 -0
  34. package/umd/typings/src/prepare/isPipelinePrepared.d.ts +4 -0
  35. package/umd/typings/src/prepare/preparePipeline.d.ts +0 -1
  36. package/umd/typings/src/prepare/prepareTemplates.d.ts +31 -0
  37. package/umd/typings/src/prepare/unpreparePipeline.d.ts +2 -0
  38. package/umd/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +3 -0
  39. package/umd/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +3 -0
  40. package/umd/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +1 -0
  41. package/umd/typings/src/types/PipelineJson/PersonaJson.d.ts +3 -0
  42. package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -0
  43. package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -0
  44. package/umd/typings/src/types/PipelineJson/PromptDialogJson.d.ts +4 -3
  45. package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +10 -0
  46. package/umd/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +1 -0
  47. package/umd/typings/src/types/PipelineJson/ScriptJson.d.ts +5 -2
  48. package/umd/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +5 -2
@@ -13,30 +13,38 @@ import type { PromptResultUsage } from './PromptResultUsage';
13
13
  * @see https://github.com/webgptorg/promptbook#executor
14
14
  */
15
15
  export type PipelineExecutor = {
16
- (inputParameters: Parameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
17
- /**
18
- * Whether the execution was successful, details are aviable in `executionReport`
19
- */
20
- readonly isSuccessful: boolean;
21
- /**
22
- * Added usage of whole execution, detailed usage is aviable in `executionReport`
23
- */
24
- readonly usage: PromptResultUsage;
25
- /**
26
- * Errors that occured during the execution, details are aviable in `executionReport`
27
- */
28
- readonly errors: Array<PipelineExecutionError | Error>;
29
- /**
30
- * The report of the execution with all details
31
- */
32
- readonly executionReport: ExecutionReportJson;
33
- /**
34
- * Result parameters of the execution
35
- *
36
- * Note: If the execution was not successful, there are only some of the result parameters
37
- */
38
- readonly outputParameters: Parameters;
39
- }>;
16
+ (inputParameters: Parameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<PipelineExecutorResult>;
17
+ };
18
+ /**
19
+ * @@@
20
+ */
21
+ export type PipelineExecutorResult = {
22
+ /**
23
+ * Whether the execution was successful, details are aviable in `executionReport`
24
+ */
25
+ readonly isSuccessful: boolean;
26
+ /**
27
+ * Added usage of whole execution, detailed usage is aviable in `executionReport`
28
+ */
29
+ readonly usage: PromptResultUsage;
30
+ /**
31
+ * Errors that occured during the execution, details are aviable in `executionReport`
32
+ */
33
+ readonly errors: Array<PipelineExecutionError | Error>;
34
+ /**
35
+ * Warnings that occured during the execution, details are aviable in `executionReport`
36
+ */
37
+ readonly warnings: Array<PipelineExecutionError | Error>;
38
+ /**
39
+ * The report of the execution with all details
40
+ */
41
+ readonly executionReport: ExecutionReportJson;
42
+ /**
43
+ * Result parameters of the execution
44
+ *
45
+ * Note: If the execution was not successful, there are only some of the result parameters
46
+ */
47
+ readonly outputParameters: Parameters;
40
48
  };
41
49
  /**
42
50
  * TODO: [🧠] Should this file be in /execution or /types folder?
@@ -24,3 +24,6 @@ export type PromptResultUsage = {
24
24
  * Record of all possible measurable units
25
25
  */
26
26
  export type PromptResultUsageCounts = Record<`${KebabCase<'TOKENS' | ExpectationUnit>}Count`, UncertainNumber>;
27
+ /**
28
+ * TODO: [🍙] Make some standart order of json properties
29
+ */
@@ -7,4 +7,8 @@ export declare function isPipelinePrepared(pipeline: PipelineJson): boolean;
7
7
  * TODO: [🐠] Maybe base this on `makeValidator`
8
8
  * TODO: [🔼] Export via core or utils
9
9
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
10
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
11
+ * - Is context in each template
12
+ * - Are samples prepared
13
+ * - Are templates prepared
10
14
  */
@@ -8,7 +8,6 @@ import type { PrepareOptions } from './PrepareOptions';
8
8
  */
9
9
  export declare function preparePipeline(pipeline: PipelineJson, options: PrepareOptions): Promise<PipelineJson>;
10
10
  /**
11
- * TODO: !!!!! Index the samples and maybe templates
12
11
  * TODO: [🔼] !!! Export via `@promptbook/core`
13
12
  * TODO: Write tests for `preparePipeline`
14
13
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
@@ -0,0 +1,31 @@
1
+ import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
2
+ import type { PromptTemplateJson } from '../types/PipelineJson/PromptTemplateJson';
3
+ import type { PrepareOptions } from './PrepareOptions';
4
+ type PrepareTemplateInput = Pick<PipelineJson, 'promptTemplates' | 'parameters'> & {
5
+ /**
6
+ * @@@
7
+ */
8
+ readonly knowledgePiecesCount: number;
9
+ };
10
+ type PreparedTemplates = {
11
+ /**
12
+ * @@@ Sequence of prompt templates that are chained together to form a pipeline
13
+ */
14
+ readonly promptTemplatesPrepared: Array<PromptTemplateJson>;
15
+ };
16
+ /**
17
+ * @@@
18
+ */
19
+ export declare function prepareTemplates(pipeline: PrepareTemplateInput, options: PrepareOptions): Promise<PreparedTemplates>;
20
+ export {};
21
+ /**
22
+ * TODO: [🧠] Add context to each template (if missing)
23
+ * TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
24
+ * TODO: !!!!! Index the samples and maybe templates
25
+ * TODO: [🔼] !!! Export via `@promptbook/core`
26
+ * TODO: Write tests for `preparePipeline`
27
+ * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
28
+ * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
29
+ * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
30
+ * TODO: [🧠][🥜]
31
+ */
@@ -5,5 +5,7 @@ import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
5
5
  export declare function unpreparePipeline(pipeline: PipelineJson): PipelineJson;
6
6
  /**
7
7
  * TODO: [🔼] !!! Export via `@promptbook/core`
8
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
8
9
  * TODO: Write tests for `preparePipeline`
10
+ * TODO: [🍙] Make some standart order of json properties
9
11
  */
@@ -65,3 +65,6 @@ export type KnowledgePiecePreparedJson = {
65
65
  */
66
66
  readonly preparationIds: Array<number_id>;
67
67
  };
68
+ /**
69
+ * TODO: [🍙] Make some standart order of json properties
70
+ */
@@ -22,3 +22,6 @@ export type KnowledgeSourcePreparedJson = KnowledgeSourceJson & {
22
22
  */
23
23
  readonly preparationIds: Array<number_id>;
24
24
  };
25
+ /**
26
+ * TODO: [🍙] Make some standart order of json properties
27
+ */
@@ -21,4 +21,5 @@ export type LlmTemplateJson = PromptTemplateJsonCommon & {
21
21
  * TODO: [👙][🧠] Maybe add `knowledge`, `actions` and `instruments` to be available granularly for each template
22
22
  * @see https://github.com/webgptorg/promptbook/discussions/79
23
23
  * TODO: [💕][🧠] Just selecting gpt3 or gpt4 level of model
24
+ * TODO: [🍙] Make some standart order of json properties
24
25
  */
@@ -36,3 +36,6 @@ export type PersonaPreparedJson = PersonaJson & {
36
36
  */
37
37
  readonly preparationIds: Array<number_id>;
38
38
  };
39
+ /**
40
+ * TODO: [🍙] Make some standart order of json properties
41
+ */
@@ -79,6 +79,7 @@ export type PipelineJson = {
79
79
  readonly preparations: Array<PreparationJson>;
80
80
  };
81
81
  /**
82
+ * TODO: [🍙] Make some standart order of json properties
82
83
  * TODO: [🧠] Maybe wrap all {parameterNames} in brackets for example { "resultingParameterName": "{foo}" }
83
84
  * Note: There was a proposal for multiple types of promptbook objects 78816ff33e2705ee1a187aa2eb8affd976d4ea1a
84
85
  * But then immediately reverted back to the single type
@@ -16,6 +16,7 @@ export type PreparationJson = {
16
16
  readonly modelUsage: PromptResultUsage;
17
17
  };
18
18
  /**
19
+ * TODO: [🍙] Make some standart order of json properties
19
20
  * TODO: Maybe put here used `modelName`
20
21
  * TODO: [🍥] When using `date` it changes all samples .ptbk.json files each time so until some more elegant solution omit the time from prepared pipeline
21
22
  */
@@ -4,9 +4,10 @@ import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
4
4
  *
5
5
  * @see https://github.com/webgptorg/promptbook/discussions/76
6
6
  */
7
- export interface PromptDialogJson extends PromptTemplateJsonCommon {
7
+ export type PromptDialogJson = PromptTemplateJsonCommon & {
8
8
  readonly blockType: 'PROMPT_DIALOG';
9
- }
9
+ };
10
10
  /**
11
11
  * TODO: [🧠][🥜]
12
- */
12
+ * TODO: [🍙] Make some standart order of json properties
13
+ */
@@ -49,8 +49,18 @@ export interface PromptTemplateJsonCommon {
49
49
  readonly blockType: BlockType;
50
50
  /**
51
51
  * Content of the template with {placeholders} for parameters
52
+ *
53
+ * @@@ content vs preparedContent
52
54
  */
53
55
  readonly content: (string_prompt | string_javascript | string_markdown) & string_template;
56
+ /**
57
+ * @@@ Content of the template with {placeholders} for parameters
58
+ *
59
+ * @@@ content vs preparedContent
60
+ *
61
+ * @default "{content}"
62
+ */
63
+ readonly preparedContent?: (string_prompt | string_javascript | string_markdown) & string_template;
54
64
  /**
55
65
  * List of postprocessing steps that are executed after the prompt template
56
66
  *
@@ -32,4 +32,5 @@ export type PromptTemplateParameterJson = {
32
32
  };
33
33
  /**
34
34
  * TODO: [♈] Probbably move expectations from templates to parameters
35
+ * TODO: [🍙] Make some standart order of json properties
35
36
  */
@@ -5,7 +5,7 @@ import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
5
5
  *
6
6
  * @see https://github.com/webgptorg/promptbook/discussions/77
7
7
  */
8
- export interface ScriptJson extends PromptTemplateJsonCommon {
8
+ export type ScriptJson = PromptTemplateJsonCommon & {
9
9
  readonly blockType: 'SCRIPT';
10
10
  /**
11
11
  * Language of the script
@@ -13,4 +13,7 @@ export interface ScriptJson extends PromptTemplateJsonCommon {
13
13
  *
14
14
  */
15
15
  readonly contentLanguage?: ScriptLanguage;
16
- }
16
+ };
17
+ /**
18
+ * TODO: [🍙] Make some standart order of json properties
19
+ */
@@ -4,6 +4,9 @@ import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
4
4
  *
5
5
  * @see https://github.com/webgptorg/promptbook/discussions/17
6
6
  */
7
- export interface SimpleTemplateJson extends PromptTemplateJsonCommon {
7
+ export type SimpleTemplateJson = PromptTemplateJsonCommon & {
8
8
  readonly blockType: 'SIMPLE_TEMPLATE';
9
- }
9
+ };
10
+ /**
11
+ * TODO: [🍙] Make some standart order of json properties
12
+ */