@promptbook/openai 0.25.0 → 0.26.0
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.
|
@@ -66,13 +66,25 @@ export interface PostprocessCommand {
|
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Expect command describes the desired output of the prompt template (after post-processing)
|
|
69
|
+
* 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.
|
|
70
|
+
*/
|
|
71
|
+
export type ExpectCommand = ExpectAmountCommand | ExpectFormatCommand;
|
|
72
|
+
/**
|
|
73
|
+
* Expect amount command describes the desired output of the prompt template (after post-processing)
|
|
69
74
|
* It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs,...
|
|
70
75
|
*
|
|
71
76
|
* Note: LLMs work with tokens, not characters, but in Promptbooks we want to use some human-recognisable and cross-model interoperable units.
|
|
72
77
|
*/
|
|
73
|
-
export interface
|
|
74
|
-
readonly type: '
|
|
78
|
+
export interface ExpectAmountCommand {
|
|
79
|
+
readonly type: 'EXPECT_AMOUNT';
|
|
75
80
|
readonly sign: 'EXACTLY' | 'MINIMUM' | 'MAXIMUM';
|
|
76
81
|
readonly unit: ExpectationUnit;
|
|
77
82
|
readonly amount: ExpectationAmount;
|
|
78
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Represents a command that expects a specific format.
|
|
86
|
+
*/
|
|
87
|
+
export interface ExpectFormatCommand {
|
|
88
|
+
readonly type: 'EXPECT_FORMAT';
|
|
89
|
+
readonly format: 'JSON';
|
|
90
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { number_integer, number_positive_or_zero, string_javascript, string_markdown, string_name, string_prompt, string_template } from '../.././types/typeAliases';
|
|
2
|
+
import { ExpectFormatCommand } from '../Command';
|
|
2
3
|
import { ExecutionType } from '../ExecutionTypes';
|
|
3
4
|
import { ModelRequirements } from '../ModelRequirements';
|
|
4
5
|
import { ScriptLanguage } from '../ScriptLanguage';
|
|
@@ -12,12 +13,18 @@ export type PromptTemplateJson = NaturalTemplateJson | SimpleTemplateJson | Scri
|
|
|
12
13
|
export interface NaturalTemplateJson extends PromptTemplateJsonCommon {
|
|
13
14
|
readonly executionType: 'PROMPT_TEMPLATE';
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Expect this amount of each unit in the answer
|
|
17
|
+
*
|
|
18
|
+
* For example 5 words, 3 sentences, 2 paragraphs, ...
|
|
16
19
|
*/
|
|
17
|
-
readonly
|
|
20
|
+
readonly expectAmount?: Partial<Record<Lowercase<ExpectationUnit>, {
|
|
18
21
|
min?: ExpectationAmount;
|
|
19
22
|
max?: ExpectationAmount;
|
|
20
23
|
}>>;
|
|
24
|
+
/**
|
|
25
|
+
* Expect this format of the answer
|
|
26
|
+
*/
|
|
27
|
+
readonly expectFormat?: ExpectFormatCommand['format'];
|
|
21
28
|
/**
|
|
22
29
|
* Requirements for the model
|
|
23
30
|
* - This is required only for executionType PROMPT_TEMPLATE
|
|
@@ -31,7 +38,7 @@ export declare const EXPECTATION_UNITS: readonly ["CHARACTERS", "WORDS", "SENTEN
|
|
|
31
38
|
/**
|
|
32
39
|
* Unit of text measurement
|
|
33
40
|
*/
|
|
34
|
-
export type ExpectationUnit =
|
|
41
|
+
export type ExpectationUnit = typeof EXPECTATION_UNITS[number];
|
|
35
42
|
/**
|
|
36
43
|
* Amount of text measurement
|
|
37
44
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/openai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
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.26.0"
|
|
41
41
|
},
|
|
42
42
|
"main": "./umd/index.umd.js",
|
|
43
43
|
"module": "./esm/index.es.js",
|
|
@@ -66,13 +66,25 @@ export interface PostprocessCommand {
|
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Expect command describes the desired output of the prompt template (after post-processing)
|
|
69
|
+
* 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.
|
|
70
|
+
*/
|
|
71
|
+
export type ExpectCommand = ExpectAmountCommand | ExpectFormatCommand;
|
|
72
|
+
/**
|
|
73
|
+
* Expect amount command describes the desired output of the prompt template (after post-processing)
|
|
69
74
|
* It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs,...
|
|
70
75
|
*
|
|
71
76
|
* Note: LLMs work with tokens, not characters, but in Promptbooks we want to use some human-recognisable and cross-model interoperable units.
|
|
72
77
|
*/
|
|
73
|
-
export interface
|
|
74
|
-
readonly type: '
|
|
78
|
+
export interface ExpectAmountCommand {
|
|
79
|
+
readonly type: 'EXPECT_AMOUNT';
|
|
75
80
|
readonly sign: 'EXACTLY' | 'MINIMUM' | 'MAXIMUM';
|
|
76
81
|
readonly unit: ExpectationUnit;
|
|
77
82
|
readonly amount: ExpectationAmount;
|
|
78
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Represents a command that expects a specific format.
|
|
86
|
+
*/
|
|
87
|
+
export interface ExpectFormatCommand {
|
|
88
|
+
readonly type: 'EXPECT_FORMAT';
|
|
89
|
+
readonly format: 'JSON';
|
|
90
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { number_integer, number_positive_or_zero, string_javascript, string_markdown, string_name, string_prompt, string_template } from '../.././types/typeAliases';
|
|
2
|
+
import { ExpectFormatCommand } from '../Command';
|
|
2
3
|
import { ExecutionType } from '../ExecutionTypes';
|
|
3
4
|
import { ModelRequirements } from '../ModelRequirements';
|
|
4
5
|
import { ScriptLanguage } from '../ScriptLanguage';
|
|
@@ -12,12 +13,18 @@ export type PromptTemplateJson = NaturalTemplateJson | SimpleTemplateJson | Scri
|
|
|
12
13
|
export interface NaturalTemplateJson extends PromptTemplateJsonCommon {
|
|
13
14
|
readonly executionType: 'PROMPT_TEMPLATE';
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Expect this amount of each unit in the answer
|
|
17
|
+
*
|
|
18
|
+
* For example 5 words, 3 sentences, 2 paragraphs, ...
|
|
16
19
|
*/
|
|
17
|
-
readonly
|
|
20
|
+
readonly expectAmount?: Partial<Record<Lowercase<ExpectationUnit>, {
|
|
18
21
|
min?: ExpectationAmount;
|
|
19
22
|
max?: ExpectationAmount;
|
|
20
23
|
}>>;
|
|
24
|
+
/**
|
|
25
|
+
* Expect this format of the answer
|
|
26
|
+
*/
|
|
27
|
+
readonly expectFormat?: ExpectFormatCommand['format'];
|
|
21
28
|
/**
|
|
22
29
|
* Requirements for the model
|
|
23
30
|
* - This is required only for executionType PROMPT_TEMPLATE
|
|
@@ -31,7 +38,7 @@ export declare const EXPECTATION_UNITS: readonly ["CHARACTERS", "WORDS", "SENTEN
|
|
|
31
38
|
/**
|
|
32
39
|
* Unit of text measurement
|
|
33
40
|
*/
|
|
34
|
-
export type ExpectationUnit =
|
|
41
|
+
export type ExpectationUnit = typeof EXPECTATION_UNITS[number];
|
|
35
42
|
/**
|
|
36
43
|
* Amount of text measurement
|
|
37
44
|
*/
|