@promptbook/openai 0.50.0-13 → 0.50.0-15
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/utils.index.d.ts +9 -2
- package/esm/typings/conversion/utils/extractParametersFromPromptTemplate.d.ts +13 -0
- package/esm/typings/conversion/utils/extractParametersFromPromptTemplate.test.d.ts +1 -0
- package/esm/typings/conversion/utils/extractVariables.d.ts +4 -3
- package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +1 -1
- package/esm/typings/utils/extractParameters.d.ts +1 -3
- package/esm/typings/utils/sets/difference.d.ts +4 -0
- package/esm/typings/utils/sets/difference.test.d.ts +1 -0
- package/esm/typings/utils/sets/intersection.d.ts +4 -0
- package/esm/typings/utils/sets/intersection.test.d.ts +1 -0
- package/esm/typings/utils/sets/union.d.ts +4 -0
- package/esm/typings/utils/sets/union.test.d.ts +1 -0
- package/package.json +2 -2
- package/umd/typings/_packages/utils.index.d.ts +9 -2
- package/umd/typings/conversion/utils/extractParametersFromPromptTemplate.d.ts +13 -0
- package/umd/typings/conversion/utils/extractParametersFromPromptTemplate.test.d.ts +1 -0
- package/umd/typings/conversion/utils/extractVariables.d.ts +4 -3
- package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +1 -1
- package/umd/typings/utils/extractParameters.d.ts +1 -3
- package/umd/typings/utils/sets/difference.d.ts +4 -0
- package/umd/typings/utils/sets/difference.test.d.ts +1 -0
- package/umd/typings/utils/sets/intersection.d.ts +4 -0
- package/umd/typings/utils/sets/intersection.test.d.ts +1 -0
- package/umd/typings/utils/sets/union.d.ts +4 -0
- package/umd/typings/utils/sets/union.test.d.ts +1 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { spaceTrim } from 'spacetrim';
|
|
2
2
|
import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString';
|
|
3
3
|
import { renderPromptbookMermaid } from '../conversion/prettify/renderPromptbookMermaid';
|
|
4
|
+
import { extractParametersFromPromptTemplate } from '../conversion/utils/extractParametersFromPromptTemplate';
|
|
5
|
+
import { extractVariables } from '../conversion/utils/extractVariables';
|
|
4
6
|
import { parseNumber } from '../conversion/utils/parseNumber';
|
|
5
7
|
import { renameParameter } from '../conversion/utils/renameParameter';
|
|
6
8
|
import { titleToName } from '../conversion/utils/titleToName';
|
|
@@ -16,6 +18,7 @@ import { countPages } from '../utils/expectation-counters/countPages';
|
|
|
16
18
|
import { countParagraphs } from '../utils/expectation-counters/countParagraphs';
|
|
17
19
|
import { countSentences, splitIntoSentences } from '../utils/expectation-counters/countSentences';
|
|
18
20
|
import { countWords } from '../utils/expectation-counters/countWords';
|
|
21
|
+
import { extractParameters } from '../utils/extractParameters';
|
|
19
22
|
import { isValidJsonString } from '../utils/isValidJsonString';
|
|
20
23
|
import { extractAllBlocksFromMarkdown } from '../utils/markdown/extractAllBlocksFromMarkdown';
|
|
21
24
|
import { extractAllListItemsFromMarkdown } from '../utils/markdown/extractAllListItemsFromMarkdown';
|
|
@@ -42,12 +45,15 @@ import { searchKeywords } from '../utils/normalization/searchKeywords';
|
|
|
42
45
|
import { extractBlock } from '../utils/postprocessing/extractBlock';
|
|
43
46
|
import { removeEmojis } from '../utils/removeEmojis';
|
|
44
47
|
import { removeQuotes } from '../utils/removeQuotes';
|
|
48
|
+
import { difference } from '../utils/sets/difference';
|
|
49
|
+
import { intersection } from '../utils/sets/intersection';
|
|
50
|
+
import { union } from '../utils/sets/union';
|
|
45
51
|
import { trimCodeBlock } from '../utils/trimCodeBlock';
|
|
46
52
|
import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
|
|
47
53
|
import { unwrapResult } from '../utils/unwrapResult';
|
|
48
54
|
export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
|
|
49
55
|
extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
|
|
50
|
-
extractOneBlockFromMarkdown, isPassingExpectations, isValidJsonString, parseNumber, // <- [🌻]
|
|
56
|
+
extractOneBlockFromMarkdown, extractParameters, extractVariables, isPassingExpectations, isValidJsonString, parseNumber, // <- [🌻]
|
|
51
57
|
prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, spaceTrim, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
|
|
52
58
|
export { countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords };
|
|
53
59
|
export { splitIntoSentences };
|
|
@@ -59,7 +65,8 @@ export declare const normalizeTo: {
|
|
|
59
65
|
'kebab-case': typeof normalizeToKebabCase;
|
|
60
66
|
};
|
|
61
67
|
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, titleToName, };
|
|
62
|
-
export { renameParameter, renderPromptbookMermaid };
|
|
68
|
+
export { extractParametersFromPromptTemplate, renameParameter, renderPromptbookMermaid };
|
|
69
|
+
export { difference, intersection, union };
|
|
63
70
|
/**
|
|
64
71
|
* TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
|
|
65
72
|
* Note: [🕙] It does not make sence to have simple lower / UPPER case normalization
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PromptTemplateJson } from '../../types/PromptbookJson/PromptTemplateJson';
|
|
2
|
+
import { string_name } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Parses the prompt template and returns the set of all used parameters
|
|
5
|
+
*
|
|
6
|
+
* @param promptTemplate the template with used parameters
|
|
7
|
+
* @returns the set of parameter names
|
|
8
|
+
* @throws {PromptbookSyntaxError} if the script is invalid
|
|
9
|
+
*/
|
|
10
|
+
export declare function extractParametersFromPromptTemplate(promptTemplate: Pick<PromptTemplateJson, 'title' | 'description' | 'executionType' | 'content'>): Set<string_name>;
|
|
11
|
+
/**
|
|
12
|
+
* TODO: [🔣] If script require contentLanguage
|
|
13
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,7 +5,8 @@ import { string_javascript, string_javascript_name } from '../../types/typeAlias
|
|
|
5
5
|
* @param script from which to extract the variables
|
|
6
6
|
* @returns the list of variable names
|
|
7
7
|
* @throws {PromptbookSyntaxError} if the script is invalid
|
|
8
|
-
*
|
|
9
|
-
* @private within the promptbookStringToJson
|
|
10
8
|
*/
|
|
11
|
-
export declare function extractVariables(script: string_javascript):
|
|
9
|
+
export declare function extractVariables(script: string_javascript): Set<string_javascript_name>;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🔣] Support for multiple languages - python, java,...
|
|
12
|
+
*/
|
|
@@ -32,7 +32,7 @@ export type Expectations = Partial<Record<Lowercase<ExpectationUnit>, {
|
|
|
32
32
|
/**
|
|
33
33
|
* Units of text measurement
|
|
34
34
|
*/
|
|
35
|
-
export declare const EXPECTATION_UNITS: readonly ["CHARACTERS", "WORDS", "SENTENCES", "
|
|
35
|
+
export declare const EXPECTATION_UNITS: readonly ["CHARACTERS", "WORDS", "SENTENCES", "LINES", "PARAGRAPHS", "PAGES"];
|
|
36
36
|
/**
|
|
37
37
|
* Unit of text measurement
|
|
38
38
|
*/
|
|
@@ -4,7 +4,5 @@ import { string_name, string_template } from '../types/typeAliases';
|
|
|
4
4
|
*
|
|
5
5
|
* @param template the template with parameters in {curly} braces
|
|
6
6
|
* @returns the list of parameter names
|
|
7
|
-
*
|
|
8
|
-
* @private within the library
|
|
9
7
|
*/
|
|
10
|
-
export declare function extractParameters(template: string_template):
|
|
8
|
+
export declare function extractParameters(template: string_template): Set<string_name>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/openai",
|
|
3
|
-
"version": "0.50.0-
|
|
3
|
+
"version": "0.50.0-15",
|
|
4
4
|
"description": "Library to supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
],
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@promptbook/core": "0.50.0-
|
|
51
|
+
"@promptbook/core": "0.50.0-15"
|
|
52
52
|
},
|
|
53
53
|
"main": "./umd/index.umd.js",
|
|
54
54
|
"module": "./esm/index.es.js",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { spaceTrim } from 'spacetrim';
|
|
2
2
|
import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString';
|
|
3
3
|
import { renderPromptbookMermaid } from '../conversion/prettify/renderPromptbookMermaid';
|
|
4
|
+
import { extractParametersFromPromptTemplate } from '../conversion/utils/extractParametersFromPromptTemplate';
|
|
5
|
+
import { extractVariables } from '../conversion/utils/extractVariables';
|
|
4
6
|
import { parseNumber } from '../conversion/utils/parseNumber';
|
|
5
7
|
import { renameParameter } from '../conversion/utils/renameParameter';
|
|
6
8
|
import { titleToName } from '../conversion/utils/titleToName';
|
|
@@ -16,6 +18,7 @@ import { countPages } from '../utils/expectation-counters/countPages';
|
|
|
16
18
|
import { countParagraphs } from '../utils/expectation-counters/countParagraphs';
|
|
17
19
|
import { countSentences, splitIntoSentences } from '../utils/expectation-counters/countSentences';
|
|
18
20
|
import { countWords } from '../utils/expectation-counters/countWords';
|
|
21
|
+
import { extractParameters } from '../utils/extractParameters';
|
|
19
22
|
import { isValidJsonString } from '../utils/isValidJsonString';
|
|
20
23
|
import { extractAllBlocksFromMarkdown } from '../utils/markdown/extractAllBlocksFromMarkdown';
|
|
21
24
|
import { extractAllListItemsFromMarkdown } from '../utils/markdown/extractAllListItemsFromMarkdown';
|
|
@@ -42,12 +45,15 @@ import { searchKeywords } from '../utils/normalization/searchKeywords';
|
|
|
42
45
|
import { extractBlock } from '../utils/postprocessing/extractBlock';
|
|
43
46
|
import { removeEmojis } from '../utils/removeEmojis';
|
|
44
47
|
import { removeQuotes } from '../utils/removeQuotes';
|
|
48
|
+
import { difference } from '../utils/sets/difference';
|
|
49
|
+
import { intersection } from '../utils/sets/intersection';
|
|
50
|
+
import { union } from '../utils/sets/union';
|
|
45
51
|
import { trimCodeBlock } from '../utils/trimCodeBlock';
|
|
46
52
|
import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
|
|
47
53
|
import { unwrapResult } from '../utils/unwrapResult';
|
|
48
54
|
export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
|
|
49
55
|
extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
|
|
50
|
-
extractOneBlockFromMarkdown, isPassingExpectations, isValidJsonString, parseNumber, // <- [🌻]
|
|
56
|
+
extractOneBlockFromMarkdown, extractParameters, extractVariables, isPassingExpectations, isValidJsonString, parseNumber, // <- [🌻]
|
|
51
57
|
prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, spaceTrim, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
|
|
52
58
|
export { countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords };
|
|
53
59
|
export { splitIntoSentences };
|
|
@@ -59,7 +65,8 @@ export declare const normalizeTo: {
|
|
|
59
65
|
'kebab-case': typeof normalizeToKebabCase;
|
|
60
66
|
};
|
|
61
67
|
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, titleToName, };
|
|
62
|
-
export { renameParameter, renderPromptbookMermaid };
|
|
68
|
+
export { extractParametersFromPromptTemplate, renameParameter, renderPromptbookMermaid };
|
|
69
|
+
export { difference, intersection, union };
|
|
63
70
|
/**
|
|
64
71
|
* TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
|
|
65
72
|
* Note: [🕙] It does not make sence to have simple lower / UPPER case normalization
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PromptTemplateJson } from '../../types/PromptbookJson/PromptTemplateJson';
|
|
2
|
+
import { string_name } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Parses the prompt template and returns the set of all used parameters
|
|
5
|
+
*
|
|
6
|
+
* @param promptTemplate the template with used parameters
|
|
7
|
+
* @returns the set of parameter names
|
|
8
|
+
* @throws {PromptbookSyntaxError} if the script is invalid
|
|
9
|
+
*/
|
|
10
|
+
export declare function extractParametersFromPromptTemplate(promptTemplate: Pick<PromptTemplateJson, 'title' | 'description' | 'executionType' | 'content'>): Set<string_name>;
|
|
11
|
+
/**
|
|
12
|
+
* TODO: [🔣] If script require contentLanguage
|
|
13
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,7 +5,8 @@ import { string_javascript, string_javascript_name } from '../../types/typeAlias
|
|
|
5
5
|
* @param script from which to extract the variables
|
|
6
6
|
* @returns the list of variable names
|
|
7
7
|
* @throws {PromptbookSyntaxError} if the script is invalid
|
|
8
|
-
*
|
|
9
|
-
* @private within the promptbookStringToJson
|
|
10
8
|
*/
|
|
11
|
-
export declare function extractVariables(script: string_javascript):
|
|
9
|
+
export declare function extractVariables(script: string_javascript): Set<string_javascript_name>;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🔣] Support for multiple languages - python, java,...
|
|
12
|
+
*/
|
|
@@ -32,7 +32,7 @@ export type Expectations = Partial<Record<Lowercase<ExpectationUnit>, {
|
|
|
32
32
|
/**
|
|
33
33
|
* Units of text measurement
|
|
34
34
|
*/
|
|
35
|
-
export declare const EXPECTATION_UNITS: readonly ["CHARACTERS", "WORDS", "SENTENCES", "
|
|
35
|
+
export declare const EXPECTATION_UNITS: readonly ["CHARACTERS", "WORDS", "SENTENCES", "LINES", "PARAGRAPHS", "PAGES"];
|
|
36
36
|
/**
|
|
37
37
|
* Unit of text measurement
|
|
38
38
|
*/
|
|
@@ -4,7 +4,5 @@ import { string_name, string_template } from '../types/typeAliases';
|
|
|
4
4
|
*
|
|
5
5
|
* @param template the template with parameters in {curly} braces
|
|
6
6
|
* @returns the list of parameter names
|
|
7
|
-
*
|
|
8
|
-
* @private within the library
|
|
9
7
|
*/
|
|
10
|
-
export declare function extractParameters(template: string_template):
|
|
8
|
+
export declare function extractParameters(template: string_template): Set<string_name>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|