@promptbook/openai 0.32.5 → 0.33.0-1
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.
- package/esm/typings/execution/PtpExecutor.d.ts +2 -2
- package/esm/typings/types/Command.d.ts +15 -2
- package/esm/typings/types/PromptTemplatePipelineJson/PromptTemplateJson.d.ts +15 -0
- package/esm/typings/types/PromptTemplatePipelineJson/PromptTemplateParameterJson.d.ts +6 -0
- package/esm/typings/utils/extractParameters.d.ts +4 -1
- package/esm/typings/utils/iterateListParameters.d.ts +8 -0
- package/esm/typings/utils/iterateListParameters.test.d.ts +1 -0
- package/esm/typings/utils/postprocessing/test/assertsPostprocessingFunctionIsWorking.d.ts +6 -0
- package/esm/typings/utils/postprocessing/test/postprocessing.test.d.ts +1 -0
- package/esm/typings/utils/postprocessing-splitters/test/assertsSplitterFunctionIsWorking.d.ts +6 -0
- package/esm/typings/utils/postprocessing-splitters/test/postprocessing-splitters.test.d.ts +1 -0
- package/package.json +2 -2
- package/umd/typings/execution/PtpExecutor.d.ts +2 -2
- package/umd/typings/types/Command.d.ts +15 -2
- package/umd/typings/types/PromptTemplatePipelineJson/PromptTemplateJson.d.ts +15 -0
- package/umd/typings/types/PromptTemplatePipelineJson/PromptTemplateParameterJson.d.ts +6 -0
- package/umd/typings/utils/extractParameters.d.ts +4 -1
- package/umd/typings/utils/iterateListParameters.d.ts +8 -0
- package/umd/typings/utils/iterateListParameters.test.d.ts +1 -0
- package/umd/typings/utils/postprocessing/test/assertsPostprocessingFunctionIsWorking.d.ts +6 -0
- package/umd/typings/utils/postprocessing/test/postprocessing.test.d.ts +1 -0
- package/umd/typings/utils/postprocessing-splitters/test/assertsSplitterFunctionIsWorking.d.ts +6 -0
- package/umd/typings/utils/postprocessing-splitters/test/postprocessing-splitters.test.d.ts +1 -0
|
@@ -13,7 +13,7 @@ import type { ExecutionReportJson } from '../types/execution-report/ExecutionRep
|
|
|
13
13
|
* @see https://github.com/webgptorg/promptbook#executor
|
|
14
14
|
*/
|
|
15
15
|
export interface PtpExecutor {
|
|
16
|
-
(inputParameters: Record<string_name, string
|
|
16
|
+
(inputParameters: Record<string_name, string | Array<string>>, onProgress: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
|
|
17
17
|
/**
|
|
18
18
|
* Whether the execution was successful
|
|
19
19
|
*/
|
|
@@ -31,7 +31,7 @@ export interface PtpExecutor {
|
|
|
31
31
|
*
|
|
32
32
|
* Note: If the execution was not successful, there are only some of the result parameters
|
|
33
33
|
*/
|
|
34
|
-
outputParameters: Record<string_name, string
|
|
34
|
+
outputParameters: Record<string_name, string | Array<string>>;
|
|
35
35
|
}>;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
@@ -6,7 +6,7 @@ import type { ExpectationAmount, ExpectationUnit } from './PromptTemplatePipelin
|
|
|
6
6
|
* Command is one piece of the prompt template which adds some logic to the prompt template or the whole pipeline.
|
|
7
7
|
* It is parsed from the markdown from ul/ol items - one command per one item.
|
|
8
8
|
*/
|
|
9
|
-
export type Command = PtbkUrlCommand | PtbkVersionCommand | ExecuteCommand | ModelCommand | JokerCommand | ParameterCommand | PostprocessCommand | ExpectCommand;
|
|
9
|
+
export type Command = PtbkUrlCommand | PtbkVersionCommand | ExecuteCommand | ModelCommand | JokerCommand | ParameterCommand | PostprocessCommand | SplitCommand | JoinCommand | ExpectCommand;
|
|
10
10
|
/**
|
|
11
11
|
* PtpVersion command tells which version is .ptp file using
|
|
12
12
|
*
|
|
@@ -65,12 +65,25 @@ export interface ParameterCommand {
|
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Postprocess command describes which function to use for postprocessing
|
|
68
|
-
* This will be created as separate EXECUTE SCRIPT block bellow
|
|
69
68
|
*/
|
|
70
69
|
export interface PostprocessCommand {
|
|
71
70
|
readonly type: 'POSTPROCESS';
|
|
72
71
|
readonly functionName: string_name;
|
|
73
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Split command describes which function to use for split postprocessing
|
|
75
|
+
*/
|
|
76
|
+
export interface SplitCommand {
|
|
77
|
+
readonly type: 'SPLIT';
|
|
78
|
+
readonly functionName: string_name;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Join command describes which function to use for join postprocessing
|
|
82
|
+
*/
|
|
83
|
+
export interface JoinCommand {
|
|
84
|
+
readonly type: 'JOIN';
|
|
85
|
+
readonly functionName: string_name;
|
|
86
|
+
}
|
|
74
87
|
/**
|
|
75
88
|
* Expect command describes the desired output of the prompt template (after post-processing)
|
|
76
89
|
* It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
|
|
@@ -85,6 +85,13 @@ interface PromptTemplateJsonCommon {
|
|
|
85
85
|
* If theese parameters meet the expectations requirements, they are used instead of executing this prompt template
|
|
86
86
|
*/
|
|
87
87
|
readonly jokers?: Array<string>;
|
|
88
|
+
/**
|
|
89
|
+
* Iterate through following array parameters
|
|
90
|
+
*/
|
|
91
|
+
readonly iterators?: Array<{
|
|
92
|
+
parameterName: string_name;
|
|
93
|
+
indexName: string_name;
|
|
94
|
+
}>;
|
|
88
95
|
/**
|
|
89
96
|
* Type of the execution
|
|
90
97
|
* This determines if the prompt template is send to LLM, user or some scripting evaluation
|
|
@@ -98,6 +105,14 @@ interface PromptTemplateJsonCommon {
|
|
|
98
105
|
* List of postprocessing steps that are executed after the prompt template
|
|
99
106
|
*/
|
|
100
107
|
readonly postprocessing?: Array<string_javascript_name>;
|
|
108
|
+
/**
|
|
109
|
+
* Split postprocessing function
|
|
110
|
+
*/
|
|
111
|
+
readonly split?: string_javascript_name;
|
|
112
|
+
/**
|
|
113
|
+
* Join postprocessing function
|
|
114
|
+
*/
|
|
115
|
+
readonly join?: string_javascript_name;
|
|
101
116
|
/**
|
|
102
117
|
* Expect this amount of each unit in the answer
|
|
103
118
|
*
|
|
@@ -9,6 +9,12 @@ export interface PromptTemplateParameterJson {
|
|
|
9
9
|
* - It should start lowercase and contain letters and numbers
|
|
10
10
|
*/
|
|
11
11
|
readonly name: string_name;
|
|
12
|
+
/**
|
|
13
|
+
* The type of the parameter
|
|
14
|
+
*
|
|
15
|
+
* - 'LIST' means `Array<string>`
|
|
16
|
+
*/
|
|
17
|
+
readonly type: 'string' | 'list';
|
|
12
18
|
/**
|
|
13
19
|
* The parameter is input of the pipeline
|
|
14
20
|
*
|
|
@@ -7,4 +7,7 @@ import { string_name, string_template } from '../types/typeAliases';
|
|
|
7
7
|
*
|
|
8
8
|
* @private within the library
|
|
9
9
|
*/
|
|
10
|
-
export declare function extractParameters(template: string_template): Array<
|
|
10
|
+
export declare function extractParameters(template: string_template): Array<{
|
|
11
|
+
parameterName: string_name;
|
|
12
|
+
indexName?: string_name;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { string_javascript_name } from '../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Iterates over nested for loops from 0 to i-1, j-1, k-1, ...
|
|
4
|
+
* Each index add new dimension of the iteration
|
|
5
|
+
*
|
|
6
|
+
* @private within the library
|
|
7
|
+
*/
|
|
8
|
+
export declare function iterateListParameters<TIndexes extends Record<string_javascript_name, number>>(indexRangeValues: TIndexes): Generator<TIndexes>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/openai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0-1",
|
|
4
4
|
"description": "Library to supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"openai": "4.2.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@promptbook/core": "0.
|
|
40
|
+
"@promptbook/core": "0.33.0-1"
|
|
41
41
|
},
|
|
42
42
|
"main": "./umd/index.umd.js",
|
|
43
43
|
"module": "./esm/index.es.js",
|
|
@@ -13,7 +13,7 @@ import type { ExecutionReportJson } from '../types/execution-report/ExecutionRep
|
|
|
13
13
|
* @see https://github.com/webgptorg/promptbook#executor
|
|
14
14
|
*/
|
|
15
15
|
export interface PtpExecutor {
|
|
16
|
-
(inputParameters: Record<string_name, string
|
|
16
|
+
(inputParameters: Record<string_name, string | Array<string>>, onProgress: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
|
|
17
17
|
/**
|
|
18
18
|
* Whether the execution was successful
|
|
19
19
|
*/
|
|
@@ -31,7 +31,7 @@ export interface PtpExecutor {
|
|
|
31
31
|
*
|
|
32
32
|
* Note: If the execution was not successful, there are only some of the result parameters
|
|
33
33
|
*/
|
|
34
|
-
outputParameters: Record<string_name, string
|
|
34
|
+
outputParameters: Record<string_name, string | Array<string>>;
|
|
35
35
|
}>;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
@@ -6,7 +6,7 @@ import type { ExpectationAmount, ExpectationUnit } from './PromptTemplatePipelin
|
|
|
6
6
|
* Command is one piece of the prompt template which adds some logic to the prompt template or the whole pipeline.
|
|
7
7
|
* It is parsed from the markdown from ul/ol items - one command per one item.
|
|
8
8
|
*/
|
|
9
|
-
export type Command = PtbkUrlCommand | PtbkVersionCommand | ExecuteCommand | ModelCommand | JokerCommand | ParameterCommand | PostprocessCommand | ExpectCommand;
|
|
9
|
+
export type Command = PtbkUrlCommand | PtbkVersionCommand | ExecuteCommand | ModelCommand | JokerCommand | ParameterCommand | PostprocessCommand | SplitCommand | JoinCommand | ExpectCommand;
|
|
10
10
|
/**
|
|
11
11
|
* PtpVersion command tells which version is .ptp file using
|
|
12
12
|
*
|
|
@@ -65,12 +65,25 @@ export interface ParameterCommand {
|
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Postprocess command describes which function to use for postprocessing
|
|
68
|
-
* This will be created as separate EXECUTE SCRIPT block bellow
|
|
69
68
|
*/
|
|
70
69
|
export interface PostprocessCommand {
|
|
71
70
|
readonly type: 'POSTPROCESS';
|
|
72
71
|
readonly functionName: string_name;
|
|
73
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Split command describes which function to use for split postprocessing
|
|
75
|
+
*/
|
|
76
|
+
export interface SplitCommand {
|
|
77
|
+
readonly type: 'SPLIT';
|
|
78
|
+
readonly functionName: string_name;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Join command describes which function to use for join postprocessing
|
|
82
|
+
*/
|
|
83
|
+
export interface JoinCommand {
|
|
84
|
+
readonly type: 'JOIN';
|
|
85
|
+
readonly functionName: string_name;
|
|
86
|
+
}
|
|
74
87
|
/**
|
|
75
88
|
* Expect command describes the desired output of the prompt template (after post-processing)
|
|
76
89
|
* It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
|
|
@@ -85,6 +85,13 @@ interface PromptTemplateJsonCommon {
|
|
|
85
85
|
* If theese parameters meet the expectations requirements, they are used instead of executing this prompt template
|
|
86
86
|
*/
|
|
87
87
|
readonly jokers?: Array<string>;
|
|
88
|
+
/**
|
|
89
|
+
* Iterate through following array parameters
|
|
90
|
+
*/
|
|
91
|
+
readonly iterators?: Array<{
|
|
92
|
+
parameterName: string_name;
|
|
93
|
+
indexName: string_name;
|
|
94
|
+
}>;
|
|
88
95
|
/**
|
|
89
96
|
* Type of the execution
|
|
90
97
|
* This determines if the prompt template is send to LLM, user or some scripting evaluation
|
|
@@ -98,6 +105,14 @@ interface PromptTemplateJsonCommon {
|
|
|
98
105
|
* List of postprocessing steps that are executed after the prompt template
|
|
99
106
|
*/
|
|
100
107
|
readonly postprocessing?: Array<string_javascript_name>;
|
|
108
|
+
/**
|
|
109
|
+
* Split postprocessing function
|
|
110
|
+
*/
|
|
111
|
+
readonly split?: string_javascript_name;
|
|
112
|
+
/**
|
|
113
|
+
* Join postprocessing function
|
|
114
|
+
*/
|
|
115
|
+
readonly join?: string_javascript_name;
|
|
101
116
|
/**
|
|
102
117
|
* Expect this amount of each unit in the answer
|
|
103
118
|
*
|
|
@@ -9,6 +9,12 @@ export interface PromptTemplateParameterJson {
|
|
|
9
9
|
* - It should start lowercase and contain letters and numbers
|
|
10
10
|
*/
|
|
11
11
|
readonly name: string_name;
|
|
12
|
+
/**
|
|
13
|
+
* The type of the parameter
|
|
14
|
+
*
|
|
15
|
+
* - 'LIST' means `Array<string>`
|
|
16
|
+
*/
|
|
17
|
+
readonly type: 'string' | 'list';
|
|
12
18
|
/**
|
|
13
19
|
* The parameter is input of the pipeline
|
|
14
20
|
*
|
|
@@ -7,4 +7,7 @@ import { string_name, string_template } from '../types/typeAliases';
|
|
|
7
7
|
*
|
|
8
8
|
* @private within the library
|
|
9
9
|
*/
|
|
10
|
-
export declare function extractParameters(template: string_template): Array<
|
|
10
|
+
export declare function extractParameters(template: string_template): Array<{
|
|
11
|
+
parameterName: string_name;
|
|
12
|
+
indexName?: string_name;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { string_javascript_name } from '../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Iterates over nested for loops from 0 to i-1, j-1, k-1, ...
|
|
4
|
+
* Each index add new dimension of the iteration
|
|
5
|
+
*
|
|
6
|
+
* @private within the library
|
|
7
|
+
*/
|
|
8
|
+
export declare function iterateListParameters<TIndexes extends Record<string_javascript_name, number>>(indexRangeValues: TIndexes): Generator<TIndexes>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|