@promptbook/openai 0.44.0-0 → 0.44.0-10
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/_packages/utils.index.d.ts +21 -11
- package/esm/typings/config.d.ts +4 -0
- package/esm/typings/errors/PromptbookNotFoundError.d.ts +7 -0
- package/esm/typings/errors/{ExpectError.d.ts → _ExpectError.d.ts} +1 -0
- 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 +11 -0
- package/esm/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.test.d.ts +1 -0
- package/esm/typings/execution/plugins/natural-execution-tools/mocked/faked-completion.test.d.ts +1 -0
- package/esm/typings/execution/utils/checkExpectations.d.ts +25 -0
- package/esm/typings/execution/utils/checkExpectations.test.d.ts +1 -0
- package/esm/typings/types/Prompt.d.ts +8 -0
- package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +13 -4
- package/esm/typings/utils/expectation-counters/countSentences.d.ts +4 -0
- package/package.json +2 -2
- package/umd/typings/_packages/core.index.d.ts +2 -1
- package/umd/typings/_packages/utils.index.d.ts +21 -11
- package/umd/typings/config.d.ts +4 -0
- package/umd/typings/errors/PromptbookNotFoundError.d.ts +7 -0
- package/umd/typings/errors/{ExpectError.d.ts → _ExpectError.d.ts} +1 -0
- 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 +11 -0
- package/umd/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.test.d.ts +1 -0
- package/umd/typings/execution/plugins/natural-execution-tools/mocked/faked-completion.test.d.ts +1 -0
- package/umd/typings/execution/utils/checkExpectations.d.ts +25 -0
- package/umd/typings/execution/utils/checkExpectations.test.d.ts +1 -0
- package/umd/typings/types/Prompt.d.ts +8 -0
- package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +13 -4
- package/umd/typings/utils/expectation-counters/countSentences.d.ts +4 -0
- package/esm/typings/errors/NotFoundError.d.ts +0 -7
- package/umd/typings/errors/NotFoundError.d.ts +0 -7
|
@@ -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';
|
|
@@ -9,7 +10,7 @@ import { countCharacters } from '../utils/expectation-counters/countCharacters';
|
|
|
9
10
|
import { countLines } from '../utils/expectation-counters/countLines';
|
|
10
11
|
import { countPages } from '../utils/expectation-counters/countPages';
|
|
11
12
|
import { countParagraphs } from '../utils/expectation-counters/countParagraphs';
|
|
12
|
-
import { countSentences } from '../utils/expectation-counters/countSentences';
|
|
13
|
+
import { countSentences, splitIntoSentences } from '../utils/expectation-counters/countSentences';
|
|
13
14
|
import { countWords } from '../utils/expectation-counters/countWords';
|
|
14
15
|
import { isValidJsonString } from '../utils/isValidJsonString';
|
|
15
16
|
import { extractAllBlocksFromMarkdown } from '../utils/markdown/extractAllBlocksFromMarkdown';
|
|
@@ -17,16 +18,6 @@ import { extractAllListItemsFromMarkdown } from '../utils/markdown/extractAllLis
|
|
|
17
18
|
import { extractOneBlockFromMarkdown } from '../utils/markdown/extractOneBlockFromMarkdown';
|
|
18
19
|
import { removeContentComments } from '../utils/markdown/removeContentComments';
|
|
19
20
|
import { removeMarkdownFormatting } from '../utils/markdown/removeMarkdownFormatting';
|
|
20
|
-
import { extractBlock } from '../utils/postprocessing/extractBlock';
|
|
21
|
-
import { removeEmojis } from '../utils/removeEmojis';
|
|
22
|
-
import { removeQuotes } from '../utils/removeQuotes';
|
|
23
|
-
import { trimCodeBlock } from '../utils/trimCodeBlock';
|
|
24
|
-
import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
|
|
25
|
-
import { unwrapResult } from '../utils/unwrapResult';
|
|
26
|
-
export { assertsExecutionSuccessful, countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
|
|
27
|
-
extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
|
|
28
|
-
extractOneBlockFromMarkdown, isValidJsonString, parseNumber, // <- [🌻]
|
|
29
|
-
prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
|
|
30
21
|
import { capitalize } from '../utils/normalization/capitalize';
|
|
31
22
|
import { decapitalize } from '../utils/normalization/decapitalize';
|
|
32
23
|
import { DIACRITIC_VARIANTS_LETTERS } from '../utils/normalization/DIACRITIC_VARIANTS_LETTERS';
|
|
@@ -44,6 +35,25 @@ import { parseKeywords } from '../utils/normalization/parseKeywords';
|
|
|
44
35
|
import { parseKeywordsFromString } from '../utils/normalization/parseKeywordsFromString';
|
|
45
36
|
import { removeDiacritics } from '../utils/normalization/removeDiacritics';
|
|
46
37
|
import { searchKeywords } from '../utils/normalization/searchKeywords';
|
|
38
|
+
import { extractBlock } from '../utils/postprocessing/extractBlock';
|
|
39
|
+
import { removeEmojis } from '../utils/removeEmojis';
|
|
40
|
+
import { removeQuotes } from '../utils/removeQuotes';
|
|
41
|
+
import { trimCodeBlock } from '../utils/trimCodeBlock';
|
|
42
|
+
import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
|
|
43
|
+
import { unwrapResult } from '../utils/unwrapResult';
|
|
44
|
+
export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
|
|
45
|
+
extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
|
|
46
|
+
extractOneBlockFromMarkdown, isPassingExpectations, isValidJsonString, parseNumber, // <- [🌻]
|
|
47
|
+
prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
|
|
48
|
+
export { countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords };
|
|
49
|
+
export { splitIntoSentences };
|
|
50
|
+
export declare const normalizeTo: {
|
|
51
|
+
camelCase: typeof normalizeTo_camelCase;
|
|
52
|
+
PascalCase: typeof normalizeTo_PascalCase;
|
|
53
|
+
'SCREAMING-CASE': typeof normalizeTo_SCREAMING_CASE;
|
|
54
|
+
snake_case: typeof normalizeTo_snake_case;
|
|
55
|
+
'kebab-case': typeof normalizeToKebabCase;
|
|
56
|
+
};
|
|
47
57
|
export { capitalize, decapitalize, DIACRITIC_VARIANTS_LETTERS, IKeywords, isValidKeyword, nameToUriPart, nameToUriParts, normalizeTo_camelCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_snake_case, normalizeToKebabCase, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, removeDiacritics, searchKeywords, string_keyword, };
|
|
48
58
|
/**
|
|
49
59
|
* TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
|
package/esm/typings/config.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
3
3
|
*
|
|
4
|
+
* @private Always catched and rethrown as `PromptbookExecutionError`
|
|
4
5
|
* Note: This is a kindof subtype of PromptbookExecutionError
|
|
5
6
|
*/
|
|
6
7
|
export declare class ExpectError extends Error {
|
|
@@ -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,11 @@
|
|
|
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;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: Implement better
|
|
10
|
+
* TODO: [💝] Unite object for expecting amount and format - use here also a format
|
|
11
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/typings/execution/plugins/natural-execution-tools/mocked/faked-completion.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
*
|
|
@@ -122,5 +130,6 @@ interface PromptTemplateJsonCommon {
|
|
|
122
130
|
}
|
|
123
131
|
export {};
|
|
124
132
|
/**
|
|
133
|
+
* TODO: [💝] Unite object for expecting amount and format - remove expectFormat
|
|
125
134
|
* TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
|
|
126
135
|
*/
|
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-10",
|
|
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-10"
|
|
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';
|
|
@@ -9,7 +10,7 @@ import { countCharacters } from '../utils/expectation-counters/countCharacters';
|
|
|
9
10
|
import { countLines } from '../utils/expectation-counters/countLines';
|
|
10
11
|
import { countPages } from '../utils/expectation-counters/countPages';
|
|
11
12
|
import { countParagraphs } from '../utils/expectation-counters/countParagraphs';
|
|
12
|
-
import { countSentences } from '../utils/expectation-counters/countSentences';
|
|
13
|
+
import { countSentences, splitIntoSentences } from '../utils/expectation-counters/countSentences';
|
|
13
14
|
import { countWords } from '../utils/expectation-counters/countWords';
|
|
14
15
|
import { isValidJsonString } from '../utils/isValidJsonString';
|
|
15
16
|
import { extractAllBlocksFromMarkdown } from '../utils/markdown/extractAllBlocksFromMarkdown';
|
|
@@ -17,16 +18,6 @@ import { extractAllListItemsFromMarkdown } from '../utils/markdown/extractAllLis
|
|
|
17
18
|
import { extractOneBlockFromMarkdown } from '../utils/markdown/extractOneBlockFromMarkdown';
|
|
18
19
|
import { removeContentComments } from '../utils/markdown/removeContentComments';
|
|
19
20
|
import { removeMarkdownFormatting } from '../utils/markdown/removeMarkdownFormatting';
|
|
20
|
-
import { extractBlock } from '../utils/postprocessing/extractBlock';
|
|
21
|
-
import { removeEmojis } from '../utils/removeEmojis';
|
|
22
|
-
import { removeQuotes } from '../utils/removeQuotes';
|
|
23
|
-
import { trimCodeBlock } from '../utils/trimCodeBlock';
|
|
24
|
-
import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
|
|
25
|
-
import { unwrapResult } from '../utils/unwrapResult';
|
|
26
|
-
export { assertsExecutionSuccessful, countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
|
|
27
|
-
extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
|
|
28
|
-
extractOneBlockFromMarkdown, isValidJsonString, parseNumber, // <- [🌻]
|
|
29
|
-
prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
|
|
30
21
|
import { capitalize } from '../utils/normalization/capitalize';
|
|
31
22
|
import { decapitalize } from '../utils/normalization/decapitalize';
|
|
32
23
|
import { DIACRITIC_VARIANTS_LETTERS } from '../utils/normalization/DIACRITIC_VARIANTS_LETTERS';
|
|
@@ -44,6 +35,25 @@ import { parseKeywords } from '../utils/normalization/parseKeywords';
|
|
|
44
35
|
import { parseKeywordsFromString } from '../utils/normalization/parseKeywordsFromString';
|
|
45
36
|
import { removeDiacritics } from '../utils/normalization/removeDiacritics';
|
|
46
37
|
import { searchKeywords } from '../utils/normalization/searchKeywords';
|
|
38
|
+
import { extractBlock } from '../utils/postprocessing/extractBlock';
|
|
39
|
+
import { removeEmojis } from '../utils/removeEmojis';
|
|
40
|
+
import { removeQuotes } from '../utils/removeQuotes';
|
|
41
|
+
import { trimCodeBlock } from '../utils/trimCodeBlock';
|
|
42
|
+
import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
|
|
43
|
+
import { unwrapResult } from '../utils/unwrapResult';
|
|
44
|
+
export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
|
|
45
|
+
extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
|
|
46
|
+
extractOneBlockFromMarkdown, isPassingExpectations, isValidJsonString, parseNumber, // <- [🌻]
|
|
47
|
+
prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
|
|
48
|
+
export { countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords };
|
|
49
|
+
export { splitIntoSentences };
|
|
50
|
+
export declare const normalizeTo: {
|
|
51
|
+
camelCase: typeof normalizeTo_camelCase;
|
|
52
|
+
PascalCase: typeof normalizeTo_PascalCase;
|
|
53
|
+
'SCREAMING-CASE': typeof normalizeTo_SCREAMING_CASE;
|
|
54
|
+
snake_case: typeof normalizeTo_snake_case;
|
|
55
|
+
'kebab-case': typeof normalizeToKebabCase;
|
|
56
|
+
};
|
|
47
57
|
export { capitalize, decapitalize, DIACRITIC_VARIANTS_LETTERS, IKeywords, isValidKeyword, nameToUriPart, nameToUriParts, normalizeTo_camelCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_snake_case, normalizeToKebabCase, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, removeDiacritics, searchKeywords, string_keyword, };
|
|
48
58
|
/**
|
|
49
59
|
* TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
|
package/umd/typings/config.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
3
3
|
*
|
|
4
|
+
* @private Always catched and rethrown as `PromptbookExecutionError`
|
|
4
5
|
* Note: This is a kindof subtype of PromptbookExecutionError
|
|
5
6
|
*/
|
|
6
7
|
export declare class ExpectError extends Error {
|
|
@@ -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,11 @@
|
|
|
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;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: Implement better
|
|
10
|
+
* TODO: [💝] Unite object for expecting amount and format - use here also a format
|
|
11
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/umd/typings/execution/plugins/natural-execution-tools/mocked/faked-completion.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
*
|
|
@@ -122,5 +130,6 @@ interface PromptTemplateJsonCommon {
|
|
|
122
130
|
}
|
|
123
131
|
export {};
|
|
124
132
|
/**
|
|
133
|
+
* TODO: [💝] Unite object for expecting amount and format - remove expectFormat
|
|
125
134
|
* TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
|
|
126
135
|
*/
|