@promptbook/openai 0.44.0-1 → 0.44.0-2
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/_packages/core.index.d.ts +2 -1
- package/esm/typings/execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools.d.ts +1 -1
- package/esm/typings/execution/plugins/natural-execution-tools/mocked/MockedFackedNaturalExecutionTools.d.ts +19 -0
- package/esm/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.d.ts +7 -0
- package/esm/typings/types/Prompt.d.ts +8 -0
- package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +12 -4
- package/package.json +2 -2
- package/umd/typings/_packages/core.index.d.ts +2 -1
- package/umd/typings/execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools.d.ts +1 -1
- package/umd/typings/execution/plugins/natural-execution-tools/mocked/MockedFackedNaturalExecutionTools.d.ts +19 -0
- package/umd/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.d.ts +7 -0
- package/umd/typings/types/Prompt.d.ts +8 -0
- package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +12 -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 };
|
|
@@ -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
|
+
}
|
package/esm/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Expectations } from '../../../../types/PromptbookJson/PromptTemplateJson';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the expectations and creates a fake text that meets the expectations
|
|
4
|
+
*
|
|
5
|
+
* @private internal util for MockedFackedNaturalExecutionTools
|
|
6
|
+
*/
|
|
7
|
+
export declare function $fakeTextToExpectations(expectations: Expectations): string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { string_name, string_prompt, string_promptbook_url_with_hashtemplate, string_title } from '.././types/typeAliases';
|
|
2
2
|
import type { ModelRequirements } from './ModelRequirements';
|
|
3
|
+
import type { Expectations } from './PromptbookJson/PromptTemplateJson';
|
|
3
4
|
/**
|
|
4
5
|
* Prompt in a text along with model requirements, but without any execution or templating logic.
|
|
5
6
|
*
|
|
@@ -23,6 +24,13 @@ export type Prompt = {
|
|
|
23
24
|
* Requirements for the model
|
|
24
25
|
*/
|
|
25
26
|
readonly modelRequirements: ModelRequirements;
|
|
27
|
+
/**
|
|
28
|
+
* Expectations for the answer
|
|
29
|
+
*
|
|
30
|
+
* For example 5 words, 3 sentences, 2 paragraphs, ...
|
|
31
|
+
* If not set, nothing is expected from the answer
|
|
32
|
+
*/
|
|
33
|
+
readonly expectations?: Expectations;
|
|
26
34
|
/**
|
|
27
35
|
* Unique identifier of the promptbook with specific template name as hash
|
|
28
36
|
*
|
|
@@ -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,10 +116,7 @@ interface PromptTemplateJsonCommon {
|
|
|
105
116
|
*
|
|
106
117
|
* Note: Expectations are performed after all postprocessing steps
|
|
107
118
|
*/
|
|
108
|
-
readonly
|
|
109
|
-
min?: ExpectationAmount;
|
|
110
|
-
max?: ExpectationAmount;
|
|
111
|
-
}>>;
|
|
119
|
+
readonly expectations?: Expectations;
|
|
112
120
|
/**
|
|
113
121
|
* Expect this format of the answer
|
|
114
122
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/openai",
|
|
3
|
-
"version": "0.44.0-
|
|
3
|
+
"version": "0.44.0-2",
|
|
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-
|
|
41
|
+
"@promptbook/core": "0.44.0-2"
|
|
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 };
|
|
@@ -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
|
+
}
|
package/umd/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Expectations } from '../../../../types/PromptbookJson/PromptTemplateJson';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the expectations and creates a fake text that meets the expectations
|
|
4
|
+
*
|
|
5
|
+
* @private internal util for MockedFackedNaturalExecutionTools
|
|
6
|
+
*/
|
|
7
|
+
export declare function $fakeTextToExpectations(expectations: Expectations): string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { string_name, string_prompt, string_promptbook_url_with_hashtemplate, string_title } from '.././types/typeAliases';
|
|
2
2
|
import type { ModelRequirements } from './ModelRequirements';
|
|
3
|
+
import type { Expectations } from './PromptbookJson/PromptTemplateJson';
|
|
3
4
|
/**
|
|
4
5
|
* Prompt in a text along with model requirements, but without any execution or templating logic.
|
|
5
6
|
*
|
|
@@ -23,6 +24,13 @@ export type Prompt = {
|
|
|
23
24
|
* Requirements for the model
|
|
24
25
|
*/
|
|
25
26
|
readonly modelRequirements: ModelRequirements;
|
|
27
|
+
/**
|
|
28
|
+
* Expectations for the answer
|
|
29
|
+
*
|
|
30
|
+
* For example 5 words, 3 sentences, 2 paragraphs, ...
|
|
31
|
+
* If not set, nothing is expected from the answer
|
|
32
|
+
*/
|
|
33
|
+
readonly expectations?: Expectations;
|
|
26
34
|
/**
|
|
27
35
|
* Unique identifier of the promptbook with specific template name as hash
|
|
28
36
|
*
|
|
@@ -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,10 +116,7 @@ interface PromptTemplateJsonCommon {
|
|
|
105
116
|
*
|
|
106
117
|
* Note: Expectations are performed after all postprocessing steps
|
|
107
118
|
*/
|
|
108
|
-
readonly
|
|
109
|
-
min?: ExpectationAmount;
|
|
110
|
-
max?: ExpectationAmount;
|
|
111
|
-
}>>;
|
|
119
|
+
readonly expectations?: Expectations;
|
|
112
120
|
/**
|
|
113
121
|
* Expect this format of the answer
|
|
114
122
|
*
|