@promptbook/openai 0.44.0-10 → 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.
@@ -1,11 +1,15 @@
1
1
  import type { Expectations } from '../../../../types/PromptbookJson/PromptTemplateJson';
2
+ import { PostprocessingFunction } from '../../script-execution-tools/javascript/JavascriptExecutionToolsOptions';
2
3
  /**
3
4
  * Gets the expectations and creates a fake text that meets the expectations
4
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
+ *
5
9
  * @private internal util for MockedFackedNaturalExecutionTools
6
10
  */
7
- export declare function $fakeTextToExpectations(expectations: Expectations): string;
11
+ export declare function $fakeTextToExpectations(expectations: Expectations, postprocessing?: Array<PostprocessingFunction>): Promise<string>;
8
12
  /**
9
- * TODO: Implement better
13
+ * TODO: Implement better - create FakeLLM from this
10
14
  * TODO: [💝] Unite object for expecting amount and format - use here also a format
11
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
  */
@@ -1,4 +1,5 @@
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';
3
4
  import type { Expectations } from './PromptbookJson/PromptTemplateJson';
4
5
  /**
@@ -24,6 +25,10 @@ export type Prompt = {
24
25
  * Requirements for the model
25
26
  */
26
27
  readonly modelRequirements: ModelRequirements;
28
+ /**
29
+ * List of postprocessing steps that are executed after the prompt
30
+ */
31
+ readonly postprocessing?: Array<PostprocessingFunction>;
27
32
  /**
28
33
  * Expectations for the answer
29
34
  *
@@ -121,6 +121,7 @@ interface PromptTemplateJsonCommon {
121
121
  * Expect this format of the answer
122
122
  *
123
123
  * Note: Expectations are performed after all postprocessing steps
124
+ * @deprecated [💝]
124
125
  */
125
126
  readonly expectFormat?: ExpectFormatCommand['format'];
126
127
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.44.0-10",
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-10"
41
+ "@promptbook/core": "0.44.0-11"
42
42
  },
43
43
  "main": "./umd/index.umd.js",
44
44
  "module": "./esm/index.es.js",
@@ -1,11 +1,15 @@
1
1
  import type { Expectations } from '../../../../types/PromptbookJson/PromptTemplateJson';
2
+ import { PostprocessingFunction } from '../../script-execution-tools/javascript/JavascriptExecutionToolsOptions';
2
3
  /**
3
4
  * Gets the expectations and creates a fake text that meets the expectations
4
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
+ *
5
9
  * @private internal util for MockedFackedNaturalExecutionTools
6
10
  */
7
- export declare function $fakeTextToExpectations(expectations: Expectations): string;
11
+ export declare function $fakeTextToExpectations(expectations: Expectations, postprocessing?: Array<PostprocessingFunction>): Promise<string>;
8
12
  /**
9
- * TODO: Implement better
13
+ * TODO: Implement better - create FakeLLM from this
10
14
  * TODO: [💝] Unite object for expecting amount and format - use here also a format
11
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
  */
@@ -1,4 +1,5 @@
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';
3
4
  import type { Expectations } from './PromptbookJson/PromptTemplateJson';
4
5
  /**
@@ -24,6 +25,10 @@ export type Prompt = {
24
25
  * Requirements for the model
25
26
  */
26
27
  readonly modelRequirements: ModelRequirements;
28
+ /**
29
+ * List of postprocessing steps that are executed after the prompt
30
+ */
31
+ readonly postprocessing?: Array<PostprocessingFunction>;
27
32
  /**
28
33
  * Expectations for the answer
29
34
  *
@@ -121,6 +121,7 @@ interface PromptTemplateJsonCommon {
121
121
  * Expect this format of the answer
122
122
  *
123
123
  * Note: Expectations are performed after all postprocessing steps
124
+ * @deprecated [💝]
124
125
  */
125
126
  readonly expectFormat?: ExpectFormatCommand['format'];
126
127
  /**