@promptbook/types 0.41.110 → 0.41.111-1
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 +2 -1
- package/esm/typings/conversion/promptbookStringToJson.d.ts +2 -0
- package/esm/typings/conversion/utils/extractVariables.d.ts +1 -0
- package/esm/typings/conversion/utils/parseCommand.d.ts +3 -0
- package/esm/typings/conversion/utils/parseNumber.d.ts +3 -0
- package/esm/typings/conversion/validation/validatePromptbookJson.d.ts +1 -1
- package/esm/typings/errors/TemplateError.d.ts +9 -0
- package/esm/typings/execution/PromptbookExecutor.d.ts +1 -3
- package/esm/typings/execution/assertsExecutionSuccessful.d.ts +1 -1
- package/esm/typings/execution/createPromptbookExecutor.d.ts +2 -1
- package/esm/typings/execution/plugins/natural-execution-tools/openai/computeOpenaiUsage.d.ts +5 -0
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +6 -0
- package/esm/typings/execution/utils/replaceParameters.d.ts +1 -0
- package/package.json +2 -2
- package/umd/typings/_packages/utils.index.d.ts +2 -1
- package/umd/typings/conversion/promptbookStringToJson.d.ts +2 -0
- package/umd/typings/conversion/utils/extractVariables.d.ts +1 -0
- package/umd/typings/conversion/utils/parseCommand.d.ts +3 -0
- package/umd/typings/conversion/utils/parseNumber.d.ts +3 -0
- package/umd/typings/conversion/validation/validatePromptbookJson.d.ts +1 -1
- package/umd/typings/errors/TemplateError.d.ts +9 -0
- package/umd/typings/execution/PromptbookExecutor.d.ts +1 -3
- package/umd/typings/execution/assertsExecutionSuccessful.d.ts +1 -1
- package/umd/typings/execution/createPromptbookExecutor.d.ts +2 -1
- package/umd/typings/execution/plugins/natural-execution-tools/openai/computeOpenaiUsage.d.ts +5 -0
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +6 -0
- package/umd/typings/execution/utils/replaceParameters.d.ts +1 -0
|
@@ -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 { replaceParameters } from '../execution/utils/replaceParameters';
|
|
4
5
|
import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
|
|
5
6
|
import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
|
|
6
7
|
import { CountUtils } from '../utils/expectation-counters';
|
|
@@ -25,7 +26,7 @@ import { unwrapResult } from '../utils/unwrapResult';
|
|
|
25
26
|
export { assertsExecutionSuccessful, countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
|
|
26
27
|
extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
|
|
27
28
|
extractOneBlockFromMarkdown, isValidJsonString, parseNumber, // <- [🌻]
|
|
28
|
-
prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
|
|
29
|
+
prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
|
|
29
30
|
/**
|
|
30
31
|
* TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
|
|
31
32
|
*/
|
|
@@ -3,6 +3,8 @@ import { PromptbookString } from '../types/PromptbookString';
|
|
|
3
3
|
/**
|
|
4
4
|
* Parse promptbook from string format to JSON format
|
|
5
5
|
*
|
|
6
|
+
* @throws {PromptbookSyntaxError} if the promptbook string is not valid
|
|
7
|
+
*
|
|
6
8
|
* Note: This function does not validate logic of the pipeline only the syntax
|
|
7
9
|
*/
|
|
8
10
|
export declare function promptbookStringToJson(promptbookString: PromptbookString): PromptbookJson;
|
|
@@ -4,6 +4,7 @@ import { string_javascript, string_javascript_name } from '../../types/typeAlias
|
|
|
4
4
|
*
|
|
5
5
|
* @param script from which to extract the variables
|
|
6
6
|
* @returns the list of variable names
|
|
7
|
+
* @throws {PromptbookSyntaxError} if the script is invalid
|
|
7
8
|
*
|
|
8
9
|
* @private within the promptbookStringToJson
|
|
9
10
|
*/
|
|
@@ -3,6 +3,9 @@ import type { string_markdown_text } from '../../types/typeAliases';
|
|
|
3
3
|
/**
|
|
4
4
|
* Parses one line of ul/ol to command
|
|
5
5
|
*
|
|
6
|
+
* @returns parsed command object
|
|
7
|
+
* @throws {PromptbookSyntaxError} if the command is invalid
|
|
8
|
+
*
|
|
6
9
|
* @private within the promptbookStringToJson
|
|
7
10
|
*/
|
|
8
11
|
export declare function parseCommand(listItem: string_markdown_text): Command;
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* Unlike Number.parseInt, Number.parseFloat it will never ever result in NaN
|
|
5
5
|
* Note: it also works only with decimal numbers
|
|
6
6
|
*
|
|
7
|
+
* @returns parsed number
|
|
8
|
+
* @throws {PromptbookSyntaxError} if the value is not a number
|
|
9
|
+
*
|
|
7
10
|
* @private within the parseCommand
|
|
8
11
|
*/
|
|
9
12
|
export declare function parseNumber(value: string | number): number;
|
|
@@ -10,7 +10,7 @@ import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
|
|
|
10
10
|
* - if it is meaningful
|
|
11
11
|
*
|
|
12
12
|
* @param promptbook valid or invalid PromptbookJson
|
|
13
|
-
* @throws {
|
|
13
|
+
* @throws {PromptbookLogicError} on logical error in the promptbook
|
|
14
14
|
*/
|
|
15
15
|
export declare function validatePromptbookJson(promptbook: PromptbookJson): void;
|
|
16
16
|
/**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This error occurs during the parameter replacement in the template
|
|
3
|
+
*
|
|
4
|
+
* Note: This is a kindof subtype of PromptbookExecutionError because it occurs during the execution of the pipeline
|
|
5
|
+
*/
|
|
6
|
+
export declare class TemplateError extends Error {
|
|
7
|
+
readonly name = "TemplateError";
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
@@ -6,9 +6,7 @@ import type { string_name } from '../types/typeAliases';
|
|
|
6
6
|
* Executor is a simple async function that takes INPUT PARAMETERs and returns result parameters _(along with all intermediate parameters and INPUT PARAMETERs = it extends input object)_.
|
|
7
7
|
* Executor is made by combining execution tools and promptbook library.
|
|
8
8
|
*
|
|
9
|
-
* It can be
|
|
10
|
-
* - From `PromptbookLibrary.getExecutor` method
|
|
11
|
-
* - `createPromptbookExecutor` utility function
|
|
9
|
+
* It can be created with `createPromptbookExecutor` function.
|
|
12
10
|
*
|
|
13
11
|
* @see https://github.com/webgptorg/promptbook#executor
|
|
14
12
|
*/
|
|
@@ -3,7 +3,7 @@ import type { PromptbookExecutor } from './PromptbookExecutor';
|
|
|
3
3
|
* Asserts that the execution of a promptnook is successful
|
|
4
4
|
*
|
|
5
5
|
* @param executionResult - The partial result of the promptnook execution
|
|
6
|
-
* @throws
|
|
6
|
+
* @throws {PromptbookExecutionError} If the execution is not successful or if multiple errors occurred
|
|
7
7
|
*/
|
|
8
8
|
export declare function assertsExecutionSuccessful(executionResult: Pick<Awaited<ReturnType<PromptbookExecutor>>, 'isSuccessful' | 'errors'>): void;
|
|
9
9
|
/**
|
|
@@ -29,7 +29,8 @@ interface CreatePromptbookExecutorOptions {
|
|
|
29
29
|
/**
|
|
30
30
|
* Creates executor function from promptbook and execution tools.
|
|
31
31
|
*
|
|
32
|
-
*
|
|
32
|
+
* @returns The executor function
|
|
33
|
+
* @throws {PromptbookLogicError} on logical error in the promptbook
|
|
33
34
|
*/
|
|
34
35
|
export declare function createPromptbookExecutor(options: CreatePromptbookExecutorOptions): PromptbookExecutor;
|
|
35
36
|
export {};
|
package/esm/typings/execution/plugins/natural-execution-tools/openai/computeOpenaiUsage.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type OpenAI from 'openai';
|
|
2
2
|
import type { PromptResult } from '../../../PromptResult';
|
|
3
|
+
/**
|
|
4
|
+
* !!!
|
|
5
|
+
*
|
|
6
|
+
* @throws {PromptbookExecutionError} If the usage is not defined in the response from OpenAI
|
|
7
|
+
*/
|
|
3
8
|
export declare function computeOpenaiUsage(rawResponse: Pick<OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion, 'model' | 'usage'>): PromptResult['usage'];
|
|
@@ -6,6 +6,7 @@ import { string_template } from '../../types/typeAliases';
|
|
|
6
6
|
* @param template the template with parameters in {curly} braces
|
|
7
7
|
* @param parameters the object with parameters
|
|
8
8
|
* @returns the template with replaced parameters
|
|
9
|
+
* @throws {TemplateError} if parameter is not defined, not closed, or not opened
|
|
9
10
|
*
|
|
10
11
|
* @private within the createPromptbookExecutor
|
|
11
12
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/types",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.111-1",
|
|
4
4
|
"description": "Library to supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"homepage": "https://www.npmjs.com/package/@promptbook/core",
|
|
36
36
|
"dependencies": {},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@promptbook/core": "0.41.
|
|
38
|
+
"@promptbook/core": "0.41.111-1"
|
|
39
39
|
},
|
|
40
40
|
"main": "./umd/index.umd.js",
|
|
41
41
|
"module": "./esm/index.es.js",
|
|
@@ -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 { replaceParameters } from '../execution/utils/replaceParameters';
|
|
4
5
|
import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
|
|
5
6
|
import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
|
|
6
7
|
import { CountUtils } from '../utils/expectation-counters';
|
|
@@ -25,7 +26,7 @@ import { unwrapResult } from '../utils/unwrapResult';
|
|
|
25
26
|
export { assertsExecutionSuccessful, countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
|
|
26
27
|
extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
|
|
27
28
|
extractOneBlockFromMarkdown, isValidJsonString, parseNumber, // <- [🌻]
|
|
28
|
-
prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
|
|
29
|
+
prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
|
|
29
30
|
/**
|
|
30
31
|
* TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
|
|
31
32
|
*/
|
|
@@ -3,6 +3,8 @@ import { PromptbookString } from '../types/PromptbookString';
|
|
|
3
3
|
/**
|
|
4
4
|
* Parse promptbook from string format to JSON format
|
|
5
5
|
*
|
|
6
|
+
* @throws {PromptbookSyntaxError} if the promptbook string is not valid
|
|
7
|
+
*
|
|
6
8
|
* Note: This function does not validate logic of the pipeline only the syntax
|
|
7
9
|
*/
|
|
8
10
|
export declare function promptbookStringToJson(promptbookString: PromptbookString): PromptbookJson;
|
|
@@ -4,6 +4,7 @@ import { string_javascript, string_javascript_name } from '../../types/typeAlias
|
|
|
4
4
|
*
|
|
5
5
|
* @param script from which to extract the variables
|
|
6
6
|
* @returns the list of variable names
|
|
7
|
+
* @throws {PromptbookSyntaxError} if the script is invalid
|
|
7
8
|
*
|
|
8
9
|
* @private within the promptbookStringToJson
|
|
9
10
|
*/
|
|
@@ -3,6 +3,9 @@ import type { string_markdown_text } from '../../types/typeAliases';
|
|
|
3
3
|
/**
|
|
4
4
|
* Parses one line of ul/ol to command
|
|
5
5
|
*
|
|
6
|
+
* @returns parsed command object
|
|
7
|
+
* @throws {PromptbookSyntaxError} if the command is invalid
|
|
8
|
+
*
|
|
6
9
|
* @private within the promptbookStringToJson
|
|
7
10
|
*/
|
|
8
11
|
export declare function parseCommand(listItem: string_markdown_text): Command;
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* Unlike Number.parseInt, Number.parseFloat it will never ever result in NaN
|
|
5
5
|
* Note: it also works only with decimal numbers
|
|
6
6
|
*
|
|
7
|
+
* @returns parsed number
|
|
8
|
+
* @throws {PromptbookSyntaxError} if the value is not a number
|
|
9
|
+
*
|
|
7
10
|
* @private within the parseCommand
|
|
8
11
|
*/
|
|
9
12
|
export declare function parseNumber(value: string | number): number;
|
|
@@ -10,7 +10,7 @@ import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
|
|
|
10
10
|
* - if it is meaningful
|
|
11
11
|
*
|
|
12
12
|
* @param promptbook valid or invalid PromptbookJson
|
|
13
|
-
* @throws {
|
|
13
|
+
* @throws {PromptbookLogicError} on logical error in the promptbook
|
|
14
14
|
*/
|
|
15
15
|
export declare function validatePromptbookJson(promptbook: PromptbookJson): void;
|
|
16
16
|
/**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This error occurs during the parameter replacement in the template
|
|
3
|
+
*
|
|
4
|
+
* Note: This is a kindof subtype of PromptbookExecutionError because it occurs during the execution of the pipeline
|
|
5
|
+
*/
|
|
6
|
+
export declare class TemplateError extends Error {
|
|
7
|
+
readonly name = "TemplateError";
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
@@ -6,9 +6,7 @@ import type { string_name } from '../types/typeAliases';
|
|
|
6
6
|
* Executor is a simple async function that takes INPUT PARAMETERs and returns result parameters _(along with all intermediate parameters and INPUT PARAMETERs = it extends input object)_.
|
|
7
7
|
* Executor is made by combining execution tools and promptbook library.
|
|
8
8
|
*
|
|
9
|
-
* It can be
|
|
10
|
-
* - From `PromptbookLibrary.getExecutor` method
|
|
11
|
-
* - `createPromptbookExecutor` utility function
|
|
9
|
+
* It can be created with `createPromptbookExecutor` function.
|
|
12
10
|
*
|
|
13
11
|
* @see https://github.com/webgptorg/promptbook#executor
|
|
14
12
|
*/
|
|
@@ -3,7 +3,7 @@ import type { PromptbookExecutor } from './PromptbookExecutor';
|
|
|
3
3
|
* Asserts that the execution of a promptnook is successful
|
|
4
4
|
*
|
|
5
5
|
* @param executionResult - The partial result of the promptnook execution
|
|
6
|
-
* @throws
|
|
6
|
+
* @throws {PromptbookExecutionError} If the execution is not successful or if multiple errors occurred
|
|
7
7
|
*/
|
|
8
8
|
export declare function assertsExecutionSuccessful(executionResult: Pick<Awaited<ReturnType<PromptbookExecutor>>, 'isSuccessful' | 'errors'>): void;
|
|
9
9
|
/**
|
|
@@ -29,7 +29,8 @@ interface CreatePromptbookExecutorOptions {
|
|
|
29
29
|
/**
|
|
30
30
|
* Creates executor function from promptbook and execution tools.
|
|
31
31
|
*
|
|
32
|
-
*
|
|
32
|
+
* @returns The executor function
|
|
33
|
+
* @throws {PromptbookLogicError} on logical error in the promptbook
|
|
33
34
|
*/
|
|
34
35
|
export declare function createPromptbookExecutor(options: CreatePromptbookExecutorOptions): PromptbookExecutor;
|
|
35
36
|
export {};
|
package/umd/typings/execution/plugins/natural-execution-tools/openai/computeOpenaiUsage.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type OpenAI from 'openai';
|
|
2
2
|
import type { PromptResult } from '../../../PromptResult';
|
|
3
|
+
/**
|
|
4
|
+
* !!!
|
|
5
|
+
*
|
|
6
|
+
* @throws {PromptbookExecutionError} If the usage is not defined in the response from OpenAI
|
|
7
|
+
*/
|
|
3
8
|
export declare function computeOpenaiUsage(rawResponse: Pick<OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion, 'model' | 'usage'>): PromptResult['usage'];
|
|
@@ -6,6 +6,7 @@ import { string_template } from '../../types/typeAliases';
|
|
|
6
6
|
* @param template the template with parameters in {curly} braces
|
|
7
7
|
* @param parameters the object with parameters
|
|
8
8
|
* @returns the template with replaced parameters
|
|
9
|
+
* @throws {TemplateError} if parameter is not defined, not closed, or not opened
|
|
9
10
|
*
|
|
10
11
|
* @private within the createPromptbookExecutor
|
|
11
12
|
*/
|