@promptbook/openai 0.44.0-1 → 0.44.0-11

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/typings/_packages/core.index.d.ts +2 -1
  2. package/esm/typings/_packages/utils.index.d.ts +3 -2
  3. package/esm/typings/config.d.ts +4 -0
  4. package/esm/typings/execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools.d.ts +1 -1
  5. package/esm/typings/execution/plugins/natural-execution-tools/mocked/MockedFackedNaturalExecutionTools.d.ts +19 -0
  6. package/esm/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.d.ts +15 -0
  7. package/esm/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.test.d.ts +1 -0
  8. package/esm/typings/execution/plugins/natural-execution-tools/mocked/faked-completion.test.d.ts +1 -0
  9. package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionToolsOptions.d.ts +5 -1
  10. package/esm/typings/execution/utils/checkExpectations.d.ts +25 -0
  11. package/esm/typings/execution/utils/checkExpectations.test.d.ts +1 -0
  12. package/esm/typings/types/Prompt.d.ts +13 -0
  13. package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +14 -4
  14. package/package.json +2 -2
  15. package/umd/typings/_packages/core.index.d.ts +2 -1
  16. package/umd/typings/_packages/utils.index.d.ts +3 -2
  17. package/umd/typings/config.d.ts +4 -0
  18. package/umd/typings/execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools.d.ts +1 -1
  19. package/umd/typings/execution/plugins/natural-execution-tools/mocked/MockedFackedNaturalExecutionTools.d.ts +19 -0
  20. package/umd/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.d.ts +15 -0
  21. package/umd/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.test.d.ts +1 -0
  22. package/umd/typings/execution/plugins/natural-execution-tools/mocked/faked-completion.test.d.ts +1 -0
  23. package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionToolsOptions.d.ts +5 -1
  24. package/umd/typings/execution/utils/checkExpectations.d.ts +25 -0
  25. package/umd/typings/execution/utils/checkExpectations.test.d.ts +1 -0
  26. package/umd/typings/types/Prompt.d.ts +13 -0
  27. package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +14 -4
@@ -2,6 +2,7 @@ import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
2
2
  import { validatePromptbookJson } from '../conversion/validation/validatePromptbookJson';
3
3
  import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
4
4
  import { MockedEchoNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools';
5
+ import { MockedFackedNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedFackedNaturalExecutionTools';
5
6
  import { CallbackInterfaceTools } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools';
6
7
  import { CallbackInterfaceToolsOptions } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions';
7
8
  import { SimplePromptInterfaceTools } from '../execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools';
@@ -15,6 +16,6 @@ export { ExecutionTypes, PROMPTBOOK_VERSION };
15
16
  export { createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookSublibrary, SimplePromptbookLibrary, };
16
17
  export { SimplePromptInterfaceTools };
17
18
  export { promptbookStringToJson, validatePromptbookJson };
18
- export { MockedEchoNaturalExecutionTools };
19
+ export { MockedEchoNaturalExecutionTools, MockedFackedNaturalExecutionTools };
19
20
  export { createPromptbookExecutor };
20
21
  export { CallbackInterfaceTools, CallbackInterfaceToolsOptions };
@@ -1,6 +1,7 @@
1
1
  import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString';
2
2
  import { parseNumber } from '../conversion/utils/parseNumber';
3
3
  import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
4
+ import { checkExpectations, isPassingExpectations } from '../execution/utils/checkExpectations';
4
5
  import { replaceParameters } from '../execution/utils/replaceParameters';
5
6
  import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
6
7
  import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
@@ -40,9 +41,9 @@ import { removeQuotes } from '../utils/removeQuotes';
40
41
  import { trimCodeBlock } from '../utils/trimCodeBlock';
41
42
  import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
42
43
  import { unwrapResult } from '../utils/unwrapResult';
43
- export { assertsExecutionSuccessful, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
44
+ export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
44
45
  extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
45
- extractOneBlockFromMarkdown, isValidJsonString, parseNumber, // <- [🌻]
46
+ extractOneBlockFromMarkdown, isPassingExpectations, isValidJsonString, parseNumber, // <- [🌻]
46
47
  prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
47
48
  export { countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords };
48
49
  export { splitIntoSentences };
@@ -2,3 +2,7 @@
2
2
  * The maximum number of iterations for a loops
3
3
  */
4
4
  export declare const LOOP_LIMIT = 1000;
5
+ /**
6
+ * The maximum number of iterations for a loops which adds characters one by one
7
+ */
8
+ export declare const CHARACTER_LOOP_LIMIT = 100000;
@@ -18,5 +18,5 @@ export declare class MockedEchoNaturalExecutionTools implements NaturalExecution
18
18
  gptComplete(prompt: Prompt): Promise<PromptCompletionResult>;
19
19
  }
20
20
  /**
21
- * TODO: Allow in spaceTrim: nesting with > ${block(prompt.request)}
21
+ * TODO: Allow in spaceTrim: nesting with > ${block(prompt.request)}, same as replace params
22
22
  */
@@ -0,0 +1,19 @@
1
+ import { Prompt } from '../../../../types/Prompt';
2
+ import { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
3
+ import { NaturalExecutionTools } from '../../../NaturalExecutionTools';
4
+ import { PromptChatResult, PromptCompletionResult } from '../../../PromptResult';
5
+ /**
6
+ * Mocked execution Tools for just faking expected responses for testing purposes
7
+ */
8
+ export declare class MockedFackedNaturalExecutionTools implements NaturalExecutionTools {
9
+ private readonly options;
10
+ constructor(options: CommonExecutionToolsOptions);
11
+ /**
12
+ * Fakes chat model
13
+ */
14
+ gptChat(prompt: Prompt): Promise<PromptChatResult & PromptCompletionResult>;
15
+ /**
16
+ * Fakes completion model
17
+ */
18
+ gptComplete(prompt: Prompt): Promise<PromptCompletionResult>;
19
+ }
@@ -0,0 +1,15 @@
1
+ import type { Expectations } from '../../../../types/PromptbookJson/PromptTemplateJson';
2
+ import { PostprocessingFunction } from '../../script-execution-tools/javascript/JavascriptExecutionToolsOptions';
3
+ /**
4
+ * Gets the expectations and creates a fake text that meets the expectations
5
+ *
6
+ * Note: You can provide postprocessing functions to modify the text before checking the expectations
7
+ * The result will be the text BEFORE the postprocessing
8
+ *
9
+ * @private internal util for MockedFackedNaturalExecutionTools
10
+ */
11
+ export declare function $fakeTextToExpectations(expectations: Expectations, postprocessing?: Array<PostprocessingFunction>): Promise<string>;
12
+ /**
13
+ * TODO: Implement better - create FakeLLM from this
14
+ * TODO: [💝] Unite object for expecting amount and format - use here also a format
15
+ */
@@ -15,8 +15,12 @@ export type JavascriptExecutionToolsOptions = CommonExecutionToolsOptions & {
15
15
  * Note: There are also some built-in functions available:
16
16
  * @see ./JavascriptEvalExecutionTools.ts
17
17
  */
18
- functions?: Record<string_javascript_name, ((value: string) => Promisable<string>) | Function>;
18
+ functions?: Record<string_javascript_name, PostprocessingFunction>;
19
19
  };
20
+ /**
21
+ * Function that can be used to postprocess the output of the LLM
22
+ */
23
+ export type PostprocessingFunction = ((value: string) => Promisable<string>) | Function;
20
24
  /**
21
25
  * TODO: [🧠][💙] Distinct between options passed into ExecutionTools and to ExecutionTools.execute
22
26
  */
@@ -0,0 +1,25 @@
1
+ import type { Expectations } from '../../types/PromptbookJson/PromptTemplateJson';
2
+ /**
3
+ * Function checkExpectations will check if the expectations on given value are met
4
+ *
5
+ * Note: There are two simmilar functions:
6
+ * - `checkExpectations` which throws an error if the expectations are not met
7
+ * - `isPassingExpectations` which returns a boolean
8
+ *
9
+ * @throws {ExpectError} if the expectations are not met
10
+ * @returns {void} Nothing
11
+ */
12
+ export declare function checkExpectations(expectations: Expectations, value: string): void;
13
+ /**
14
+ * Function checkExpectations will check if the expectations on given value are met
15
+ *
16
+ * Note: There are two simmilar functions:
17
+ * - `checkExpectations` which throws an error if the expectations are not met
18
+ * - `isPassingExpectations` which returns a boolean
19
+ *
20
+ * @returns {boolean} True if the expectations are met
21
+ */
22
+ export declare function isPassingExpectations(expectations: Expectations, value: string): boolean;
23
+ /**
24
+ * TODO: [💝] Unite object for expecting amount and format
25
+ */
@@ -1,5 +1,7 @@
1
1
  import type { string_name, string_prompt, string_promptbook_url_with_hashtemplate, string_title } from '.././types/typeAliases';
2
+ import { PostprocessingFunction } from '../execution/plugins/script-execution-tools/javascript/JavascriptExecutionToolsOptions';
2
3
  import type { ModelRequirements } from './ModelRequirements';
4
+ import type { Expectations } from './PromptbookJson/PromptTemplateJson';
3
5
  /**
4
6
  * Prompt in a text along with model requirements, but without any execution or templating logic.
5
7
  *
@@ -23,6 +25,17 @@ export type Prompt = {
23
25
  * Requirements for the model
24
26
  */
25
27
  readonly modelRequirements: ModelRequirements;
28
+ /**
29
+ * List of postprocessing steps that are executed after the prompt
30
+ */
31
+ readonly postprocessing?: Array<PostprocessingFunction>;
32
+ /**
33
+ * Expectations for the answer
34
+ *
35
+ * For example 5 words, 3 sentences, 2 paragraphs, ...
36
+ * If not set, nothing is expected from the answer
37
+ */
38
+ readonly expectations?: Expectations;
26
39
  /**
27
40
  * Unique identifier of the promptbook with specific template name as hash
28
41
  *
@@ -18,6 +18,17 @@ export type NaturalTemplateJson = PromptTemplateJsonCommon & {
18
18
  */
19
19
  readonly modelRequirements: ModelRequirements;
20
20
  };
21
+ /**
22
+ * Expect this amount of each unit in the answer
23
+ *
24
+ * For example 5 words, 3 sentences, 2 paragraphs, ...
25
+ *
26
+ * Note: Expectations are performed after all postprocessing steps
27
+ */
28
+ export type Expectations = Partial<Record<Lowercase<ExpectationUnit>, {
29
+ min?: ExpectationAmount;
30
+ max?: ExpectationAmount;
31
+ }>>;
21
32
  /**
22
33
  * Units of text measurement
23
34
  */
@@ -105,14 +116,12 @@ interface PromptTemplateJsonCommon {
105
116
  *
106
117
  * Note: Expectations are performed after all postprocessing steps
107
118
  */
108
- readonly expectAmount?: Partial<Record<Lowercase<ExpectationUnit>, {
109
- min?: ExpectationAmount;
110
- max?: ExpectationAmount;
111
- }>>;
119
+ readonly expectations?: Expectations;
112
120
  /**
113
121
  * Expect this format of the answer
114
122
  *
115
123
  * Note: Expectations are performed after all postprocessing steps
124
+ * @deprecated [💝]
116
125
  */
117
126
  readonly expectFormat?: ExpectFormatCommand['format'];
118
127
  /**
@@ -122,5 +131,6 @@ interface PromptTemplateJsonCommon {
122
131
  }
123
132
  export {};
124
133
  /**
134
+ * TODO: [💝] Unite object for expecting amount and format - remove expectFormat
125
135
  * TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
126
136
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.44.0-1",
3
+ "version": "0.44.0-11",
4
4
  "description": "Library to supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -38,7 +38,7 @@
38
38
  "openai": "4.2.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "@promptbook/core": "0.44.0-1"
41
+ "@promptbook/core": "0.44.0-11"
42
42
  },
43
43
  "main": "./umd/index.umd.js",
44
44
  "module": "./esm/index.es.js",
@@ -2,6 +2,7 @@ import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
2
2
  import { validatePromptbookJson } from '../conversion/validation/validatePromptbookJson';
3
3
  import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
4
4
  import { MockedEchoNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools';
5
+ import { MockedFackedNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedFackedNaturalExecutionTools';
5
6
  import { CallbackInterfaceTools } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools';
6
7
  import { CallbackInterfaceToolsOptions } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions';
7
8
  import { SimplePromptInterfaceTools } from '../execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools';
@@ -15,6 +16,6 @@ export { ExecutionTypes, PROMPTBOOK_VERSION };
15
16
  export { createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookSublibrary, SimplePromptbookLibrary, };
16
17
  export { SimplePromptInterfaceTools };
17
18
  export { promptbookStringToJson, validatePromptbookJson };
18
- export { MockedEchoNaturalExecutionTools };
19
+ export { MockedEchoNaturalExecutionTools, MockedFackedNaturalExecutionTools };
19
20
  export { createPromptbookExecutor };
20
21
  export { CallbackInterfaceTools, CallbackInterfaceToolsOptions };
@@ -1,6 +1,7 @@
1
1
  import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString';
2
2
  import { parseNumber } from '../conversion/utils/parseNumber';
3
3
  import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
4
+ import { checkExpectations, isPassingExpectations } from '../execution/utils/checkExpectations';
4
5
  import { replaceParameters } from '../execution/utils/replaceParameters';
5
6
  import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
6
7
  import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
@@ -40,9 +41,9 @@ import { removeQuotes } from '../utils/removeQuotes';
40
41
  import { trimCodeBlock } from '../utils/trimCodeBlock';
41
42
  import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
42
43
  import { unwrapResult } from '../utils/unwrapResult';
43
- export { assertsExecutionSuccessful, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
44
+ export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
44
45
  extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
45
- extractOneBlockFromMarkdown, isValidJsonString, parseNumber, // <- [🌻]
46
+ extractOneBlockFromMarkdown, isPassingExpectations, isValidJsonString, parseNumber, // <- [🌻]
46
47
  prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
47
48
  export { countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords };
48
49
  export { splitIntoSentences };
@@ -2,3 +2,7 @@
2
2
  * The maximum number of iterations for a loops
3
3
  */
4
4
  export declare const LOOP_LIMIT = 1000;
5
+ /**
6
+ * The maximum number of iterations for a loops which adds characters one by one
7
+ */
8
+ export declare const CHARACTER_LOOP_LIMIT = 100000;
@@ -18,5 +18,5 @@ export declare class MockedEchoNaturalExecutionTools implements NaturalExecution
18
18
  gptComplete(prompt: Prompt): Promise<PromptCompletionResult>;
19
19
  }
20
20
  /**
21
- * TODO: Allow in spaceTrim: nesting with > ${block(prompt.request)}
21
+ * TODO: Allow in spaceTrim: nesting with > ${block(prompt.request)}, same as replace params
22
22
  */
@@ -0,0 +1,19 @@
1
+ import { Prompt } from '../../../../types/Prompt';
2
+ import { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
3
+ import { NaturalExecutionTools } from '../../../NaturalExecutionTools';
4
+ import { PromptChatResult, PromptCompletionResult } from '../../../PromptResult';
5
+ /**
6
+ * Mocked execution Tools for just faking expected responses for testing purposes
7
+ */
8
+ export declare class MockedFackedNaturalExecutionTools implements NaturalExecutionTools {
9
+ private readonly options;
10
+ constructor(options: CommonExecutionToolsOptions);
11
+ /**
12
+ * Fakes chat model
13
+ */
14
+ gptChat(prompt: Prompt): Promise<PromptChatResult & PromptCompletionResult>;
15
+ /**
16
+ * Fakes completion model
17
+ */
18
+ gptComplete(prompt: Prompt): Promise<PromptCompletionResult>;
19
+ }
@@ -0,0 +1,15 @@
1
+ import type { Expectations } from '../../../../types/PromptbookJson/PromptTemplateJson';
2
+ import { PostprocessingFunction } from '../../script-execution-tools/javascript/JavascriptExecutionToolsOptions';
3
+ /**
4
+ * Gets the expectations and creates a fake text that meets the expectations
5
+ *
6
+ * Note: You can provide postprocessing functions to modify the text before checking the expectations
7
+ * The result will be the text BEFORE the postprocessing
8
+ *
9
+ * @private internal util for MockedFackedNaturalExecutionTools
10
+ */
11
+ export declare function $fakeTextToExpectations(expectations: Expectations, postprocessing?: Array<PostprocessingFunction>): Promise<string>;
12
+ /**
13
+ * TODO: Implement better - create FakeLLM from this
14
+ * TODO: [💝] Unite object for expecting amount and format - use here also a format
15
+ */
@@ -15,8 +15,12 @@ export type JavascriptExecutionToolsOptions = CommonExecutionToolsOptions & {
15
15
  * Note: There are also some built-in functions available:
16
16
  * @see ./JavascriptEvalExecutionTools.ts
17
17
  */
18
- functions?: Record<string_javascript_name, ((value: string) => Promisable<string>) | Function>;
18
+ functions?: Record<string_javascript_name, PostprocessingFunction>;
19
19
  };
20
+ /**
21
+ * Function that can be used to postprocess the output of the LLM
22
+ */
23
+ export type PostprocessingFunction = ((value: string) => Promisable<string>) | Function;
20
24
  /**
21
25
  * TODO: [🧠][💙] Distinct between options passed into ExecutionTools and to ExecutionTools.execute
22
26
  */
@@ -0,0 +1,25 @@
1
+ import type { Expectations } from '../../types/PromptbookJson/PromptTemplateJson';
2
+ /**
3
+ * Function checkExpectations will check if the expectations on given value are met
4
+ *
5
+ * Note: There are two simmilar functions:
6
+ * - `checkExpectations` which throws an error if the expectations are not met
7
+ * - `isPassingExpectations` which returns a boolean
8
+ *
9
+ * @throws {ExpectError} if the expectations are not met
10
+ * @returns {void} Nothing
11
+ */
12
+ export declare function checkExpectations(expectations: Expectations, value: string): void;
13
+ /**
14
+ * Function checkExpectations will check if the expectations on given value are met
15
+ *
16
+ * Note: There are two simmilar functions:
17
+ * - `checkExpectations` which throws an error if the expectations are not met
18
+ * - `isPassingExpectations` which returns a boolean
19
+ *
20
+ * @returns {boolean} True if the expectations are met
21
+ */
22
+ export declare function isPassingExpectations(expectations: Expectations, value: string): boolean;
23
+ /**
24
+ * TODO: [💝] Unite object for expecting amount and format
25
+ */
@@ -1,5 +1,7 @@
1
1
  import type { string_name, string_prompt, string_promptbook_url_with_hashtemplate, string_title } from '.././types/typeAliases';
2
+ import { PostprocessingFunction } from '../execution/plugins/script-execution-tools/javascript/JavascriptExecutionToolsOptions';
2
3
  import type { ModelRequirements } from './ModelRequirements';
4
+ import type { Expectations } from './PromptbookJson/PromptTemplateJson';
3
5
  /**
4
6
  * Prompt in a text along with model requirements, but without any execution or templating logic.
5
7
  *
@@ -23,6 +25,17 @@ export type Prompt = {
23
25
  * Requirements for the model
24
26
  */
25
27
  readonly modelRequirements: ModelRequirements;
28
+ /**
29
+ * List of postprocessing steps that are executed after the prompt
30
+ */
31
+ readonly postprocessing?: Array<PostprocessingFunction>;
32
+ /**
33
+ * Expectations for the answer
34
+ *
35
+ * For example 5 words, 3 sentences, 2 paragraphs, ...
36
+ * If not set, nothing is expected from the answer
37
+ */
38
+ readonly expectations?: Expectations;
26
39
  /**
27
40
  * Unique identifier of the promptbook with specific template name as hash
28
41
  *
@@ -18,6 +18,17 @@ export type NaturalTemplateJson = PromptTemplateJsonCommon & {
18
18
  */
19
19
  readonly modelRequirements: ModelRequirements;
20
20
  };
21
+ /**
22
+ * Expect this amount of each unit in the answer
23
+ *
24
+ * For example 5 words, 3 sentences, 2 paragraphs, ...
25
+ *
26
+ * Note: Expectations are performed after all postprocessing steps
27
+ */
28
+ export type Expectations = Partial<Record<Lowercase<ExpectationUnit>, {
29
+ min?: ExpectationAmount;
30
+ max?: ExpectationAmount;
31
+ }>>;
21
32
  /**
22
33
  * Units of text measurement
23
34
  */
@@ -105,14 +116,12 @@ interface PromptTemplateJsonCommon {
105
116
  *
106
117
  * Note: Expectations are performed after all postprocessing steps
107
118
  */
108
- readonly expectAmount?: Partial<Record<Lowercase<ExpectationUnit>, {
109
- min?: ExpectationAmount;
110
- max?: ExpectationAmount;
111
- }>>;
119
+ readonly expectations?: Expectations;
112
120
  /**
113
121
  * Expect this format of the answer
114
122
  *
115
123
  * Note: Expectations are performed after all postprocessing steps
124
+ * @deprecated [💝]
116
125
  */
117
126
  readonly expectFormat?: ExpectFormatCommand['format'];
118
127
  /**
@@ -122,5 +131,6 @@ interface PromptTemplateJsonCommon {
122
131
  }
123
132
  export {};
124
133
  /**
134
+ * TODO: [💝] Unite object for expecting amount and format - remove expectFormat
125
135
  * TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
126
136
  */