@promptbook/utils 0.40.0-0 → 0.40.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/index.es.js +147 -96
- package/esm/index.es.js.map +1 -1
- package/esm/typings/_packages/core.index.d.ts +6 -2
- package/esm/typings/_packages/types.index.d.ts +1 -4
- package/esm/typings/_packages/utils.index.d.ts +5 -2
- package/esm/typings/config.d.ts +4 -0
- package/esm/typings/conversion/{_importPromptbook.d.ts → test/_importPromptbook.d.ts} +2 -2
- package/{umd/typings/conversion → esm/typings/conversion/test}/validatePromptbookJson.d.ts +1 -1
- package/{umd/typings → esm/typings/conversion}/utils/extractVariables.d.ts +2 -2
- package/esm/typings/conversion/utils/parseCommand.d.ts +8 -0
- package/{umd/typings → esm/typings/conversion}/utils/parseNumber.d.ts +2 -0
- package/esm/typings/errors/ExpectError.d.ts +2 -0
- package/esm/typings/errors/NotFoundError.d.ts +1 -1
- package/esm/typings/errors/PromptbookExecutionError.d.ts +7 -0
- package/esm/typings/errors/PromptbookLogicError.d.ts +7 -0
- package/esm/typings/errors/PromptbookReferenceError.d.ts +7 -0
- package/esm/typings/errors/PromptbookSyntaxError.d.ts +7 -0
- package/esm/typings/errors/UnexpectedError.d.ts +7 -0
- package/esm/typings/execution/UserInterfaceTools.d.ts +1 -1
- package/esm/typings/execution/createPromptbookExecutor.d.ts +1 -1
- package/{umd/typings → esm/typings/execution}/utils/replaceParameters.d.ts +3 -3
- package/esm/typings/library/PromptbookLibrary.d.ts +1 -1
- package/esm/typings/library/SimplePromptbookLibrary.d.ts +7 -13
- package/esm/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +7 -0
- package/esm/typings/library/constructors/createPromptbookLibraryFromSources.d.ts +16 -0
- package/esm/typings/library/constructors/createPromptbookSublibrary.d.ts +6 -0
- package/esm/typings/utils/markdown/extractOneBlockFromMarkdown.d.ts +3 -0
- package/package.json +3 -3
- package/umd/index.umd.js +147 -96
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/_packages/core.index.d.ts +6 -2
- package/umd/typings/_packages/types.index.d.ts +1 -4
- package/umd/typings/_packages/utils.index.d.ts +5 -2
- package/umd/typings/config.d.ts +4 -0
- package/umd/typings/conversion/{_importPromptbook.d.ts → test/_importPromptbook.d.ts} +2 -2
- package/{esm/typings/conversion → umd/typings/conversion/test}/validatePromptbookJson.d.ts +1 -1
- package/{esm/typings → umd/typings/conversion}/utils/extractVariables.d.ts +2 -2
- package/umd/typings/conversion/utils/parseCommand.d.ts +8 -0
- package/{esm/typings → umd/typings/conversion}/utils/parseNumber.d.ts +2 -0
- package/umd/typings/errors/ExpectError.d.ts +2 -0
- package/umd/typings/errors/NotFoundError.d.ts +1 -1
- package/umd/typings/errors/PromptbookExecutionError.d.ts +7 -0
- package/umd/typings/errors/PromptbookLogicError.d.ts +7 -0
- package/umd/typings/errors/PromptbookReferenceError.d.ts +7 -0
- package/umd/typings/errors/PromptbookSyntaxError.d.ts +7 -0
- package/umd/typings/errors/UnexpectedError.d.ts +7 -0
- package/umd/typings/execution/UserInterfaceTools.d.ts +1 -1
- package/umd/typings/execution/createPromptbookExecutor.d.ts +1 -1
- package/{esm/typings → umd/typings/execution}/utils/replaceParameters.d.ts +3 -3
- package/umd/typings/library/PromptbookLibrary.d.ts +1 -1
- package/umd/typings/library/SimplePromptbookLibrary.d.ts +7 -13
- package/umd/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +7 -0
- package/umd/typings/library/constructors/createPromptbookLibraryFromSources.d.ts +16 -0
- package/umd/typings/library/constructors/createPromptbookSublibrary.d.ts +6 -0
- package/umd/typings/utils/markdown/extractOneBlockFromMarkdown.d.ts +3 -0
- package/esm/typings/conversion/parseCommand.d.ts +0 -6
- package/umd/typings/conversion/parseCommand.d.ts +0 -6
- /package/esm/typings/conversion/{promptbookStringToJson-syntaxErrors.test.d.ts → test/promptbookStringToJson-syntaxErrors.test.d.ts} +0 -0
- /package/esm/typings/conversion/{promptbookStringToJson.test.d.ts → test/promptbookStringToJson.test.d.ts} +0 -0
- /package/esm/typings/conversion/{validatePromptbookJson-logicErrors.test.d.ts → test/validatePromptbookJson-logicErrors.test.d.ts} +0 -0
- /package/esm/typings/conversion/{validatePromptbookJson.test.d.ts → test/validatePromptbookJson.test.d.ts} +0 -0
- /package/esm/typings/{utils → conversion/utils}/extractVariables.test.d.ts +0 -0
- /package/esm/typings/conversion/{parseCommand.test.d.ts → utils/parseCommand.test.d.ts} +0 -0
- /package/esm/typings/{utils → conversion/utils}/parseNumber.test.d.ts +0 -0
- /package/esm/typings/{utils → execution/utils}/replaceParameters.test.d.ts +0 -0
- /package/umd/typings/conversion/{promptbookStringToJson-syntaxErrors.test.d.ts → test/promptbookStringToJson-syntaxErrors.test.d.ts} +0 -0
- /package/umd/typings/conversion/{promptbookStringToJson.test.d.ts → test/promptbookStringToJson.test.d.ts} +0 -0
- /package/umd/typings/conversion/{validatePromptbookJson-logicErrors.test.d.ts → test/validatePromptbookJson-logicErrors.test.d.ts} +0 -0
- /package/umd/typings/conversion/{validatePromptbookJson.test.d.ts → test/validatePromptbookJson.test.d.ts} +0 -0
- /package/umd/typings/{utils → conversion/utils}/extractVariables.test.d.ts +0 -0
- /package/umd/typings/conversion/{parseCommand.test.d.ts → utils/parseCommand.test.d.ts} +0 -0
- /package/umd/typings/{utils → conversion/utils}/parseNumber.test.d.ts +0 -0
- /package/umd/typings/{utils → execution/utils}/replaceParameters.test.d.ts +0 -0
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
|
|
2
|
-
import { validatePromptbookJson } from '../conversion/validatePromptbookJson';
|
|
2
|
+
import { validatePromptbookJson } from '../conversion/test/validatePromptbookJson';
|
|
3
3
|
import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
|
|
4
4
|
import { MockedEchoNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools';
|
|
5
5
|
import { CallbackInterfaceTools } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools';
|
|
6
6
|
import { CallbackInterfaceToolsOptions } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions';
|
|
7
7
|
import { SimplePromptInterfaceTools } from '../execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools';
|
|
8
8
|
import { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
|
|
9
|
+
import { createPromptbookLibraryFromPromise } from '../library/constructors/createPromptbookLibraryFromPromise';
|
|
10
|
+
import { createPromptbookLibraryFromSources } from '../library/constructors/createPromptbookLibraryFromSources';
|
|
11
|
+
import { createPromptbookSublibrary } from '../library/constructors/createPromptbookSublibrary';
|
|
9
12
|
import { ExecutionTypes } from '../types/ExecutionTypes';
|
|
10
13
|
import { PROMPTBOOK_VERSION } from '../version';
|
|
11
|
-
export { ExecutionTypes, PROMPTBOOK_VERSION
|
|
14
|
+
export { ExecutionTypes, PROMPTBOOK_VERSION };
|
|
15
|
+
export { SimplePromptbookLibrary, createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookSublibrary, };
|
|
12
16
|
export { SimplePromptInterfaceTools };
|
|
13
17
|
export { promptbookStringToJson, validatePromptbookJson };
|
|
14
18
|
export { MockedEchoNaturalExecutionTools };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ExpectError } from '../errors/ExpectError';
|
|
2
|
-
import { NotFoundError } from '../errors/NotFoundError';
|
|
3
1
|
import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionToolsOptions';
|
|
4
2
|
import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
5
3
|
import type { NaturalExecutionTools } from '../execution/NaturalExecutionTools';
|
|
@@ -23,8 +21,7 @@ import type { string_char_emoji } from '../types/typeAliasEmoji';
|
|
|
23
21
|
import type { client_id, string_char, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_prompt, string_promptbook_url, string_promptbook_url_with_hashtemplate, string_script, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_version } from '../types/typeAliases';
|
|
24
22
|
import { FromtoItems } from '../utils/FromtoItems';
|
|
25
23
|
export { CommonExecutionToolsOptions, EXPECTATION_UNITS, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, ExpectationUnit, FromtoItems, ModelRequirements, ModelVariant, NaturalExecutionTools, Parameters, Prompt, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptTemplateJson, PromptTemplateParameterJson, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptLanguage, TaskProgress, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_prompt, string_promptbook_url, string_promptbook_url_with_hashtemplate, string_script, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_version, };
|
|
26
|
-
export { ExpectError, NotFoundError };
|
|
27
24
|
/**
|
|
28
|
-
* TODO: [🧠] Is this the best package to export custom errors from?
|
|
25
|
+
* TODO: [🧠][🆔] Is this the best package to export custom errors from?
|
|
29
26
|
* TODO: Delete type aliases (from ../types/typeAliases) that are not exported here
|
|
30
27
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseNumber } from '../conversion/utils/parseNumber';
|
|
1
2
|
import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
|
|
2
3
|
import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
|
|
3
4
|
import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
|
|
@@ -14,13 +15,15 @@ import { extractAllListItemsFromMarkdown } from '../utils/markdown/extractAllLis
|
|
|
14
15
|
import { extractOneBlockFromMarkdown } from '../utils/markdown/extractOneBlockFromMarkdown';
|
|
15
16
|
import { removeContentComments } from '../utils/markdown/removeContentComments';
|
|
16
17
|
import { removeMarkdownFormatting } from '../utils/markdown/removeMarkdownFormatting';
|
|
17
|
-
import { parseNumber } from '../utils/parseNumber';
|
|
18
18
|
import { removeEmojis } from '../utils/removeEmojis';
|
|
19
19
|
import { removeQuotes } from '../utils/removeQuotes';
|
|
20
20
|
import { trimCodeBlock } from '../utils/trimCodeBlock';
|
|
21
21
|
import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
|
|
22
22
|
import { unwrapResult } from '../utils/unwrapResult';
|
|
23
|
-
export { CountUtils, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, assertsExecutionSuccessful, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, executionReportJsonToString, extractAllBlocksFromMarkdown,
|
|
23
|
+
export { CountUtils, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, assertsExecutionSuccessful, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, executionReportJsonToString, extractAllBlocksFromMarkdown, // <- [🌻]
|
|
24
|
+
extractAllListItemsFromMarkdown, // <- [🌻]
|
|
25
|
+
extractOneBlockFromMarkdown, // <- [🌻]
|
|
26
|
+
isValidJsonString, parseNumber, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
|
|
24
27
|
/**
|
|
25
28
|
* TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
|
|
26
29
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PromptbookJson } from '
|
|
2
|
-
import { PromptbookString } from '
|
|
1
|
+
import { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
|
|
2
|
+
import { PromptbookString } from '../../types/PromptbookString';
|
|
3
3
|
/**
|
|
4
4
|
* Import the text file
|
|
5
5
|
*
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { string_javascript, string_javascript_name } from '
|
|
1
|
+
import { string_javascript, string_javascript_name } from '../../types/typeAliases';
|
|
2
2
|
/**
|
|
3
3
|
* Parses the given script and returns the list of all used variables that are not defined in the script
|
|
4
4
|
*
|
|
5
5
|
* @param script from which to extract the variables
|
|
6
6
|
* @returns the list of variable names
|
|
7
7
|
*
|
|
8
|
-
* @private within the
|
|
8
|
+
* @private within the promptbookStringToJson
|
|
9
9
|
*/
|
|
10
10
|
export declare function extractVariables(script: string_javascript): Array<string_javascript_name>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Command } from '../../types/Command';
|
|
2
|
+
import type { string_markdown_text } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Parses one line of ul/ol to command
|
|
5
|
+
*
|
|
6
|
+
* @private within the promptbookStringToJson
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseCommand(listItem: string_markdown_text): Command;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
|
|
3
|
+
*/
|
|
4
|
+
export declare class PromptbookLogicError extends Error {
|
|
5
|
+
readonly name = "PromptbookLogicError";
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
@@ -6,7 +6,7 @@ import { number_integer, number_positive } from '../types/typeAliases';
|
|
|
6
6
|
*/
|
|
7
7
|
export type UserInterfaceTools = {
|
|
8
8
|
/**
|
|
9
|
-
* Asks the user to answer a free-text (
|
|
9
|
+
* Asks the user to answer a free-text (multi-line) question
|
|
10
10
|
*
|
|
11
11
|
* @param options the question to ask
|
|
12
12
|
* @returns the answer from the user
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PromptbookJson } from '../_packages/types.index';
|
|
2
2
|
import { ExecutionTools } from './ExecutionTools';
|
|
3
3
|
import { PromptbookExecutor } from './PromptbookExecutor';
|
|
4
|
-
|
|
4
|
+
type CreatePromptbookExecutorSettings = {
|
|
5
5
|
/**
|
|
6
6
|
* When executor does not satisfy expectations it will be retried this amount of times
|
|
7
7
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Parameters } from '../../types/Parameters';
|
|
2
|
+
import { string_template } from '../../types/typeAliases';
|
|
3
3
|
/**
|
|
4
4
|
* Replaces parameters in template with values from parameters object
|
|
5
5
|
*
|
|
@@ -7,6 +7,6 @@ import { Parameters } from '../types/Parameters';
|
|
|
7
7
|
* @param parameters the object with parameters
|
|
8
8
|
* @returns the template with replaced parameters
|
|
9
9
|
*
|
|
10
|
-
* @private within the
|
|
10
|
+
* @private within the createPromptbookExecutor
|
|
11
11
|
*/
|
|
12
12
|
export declare function replaceParameters(template: string_template, parameters: Parameters): string;
|
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
import { CreatePromptbookExecutorSettings } from '../execution/createPromptbookExecutor';
|
|
2
1
|
import type { Prompt } from '../types/Prompt';
|
|
3
2
|
import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
|
|
4
|
-
import type { PromptbookString } from '../types/PromptbookString';
|
|
5
3
|
import type { string_promptbook_url } from '../types/typeAliases';
|
|
6
4
|
import { PromptbookLibrary } from './PromptbookLibrary';
|
|
7
5
|
/**
|
|
8
6
|
* Library of promptbooks that groups together promptbooks for an application.
|
|
9
|
-
* This implementation is a very thin wrapper around the Array /
|
|
7
|
+
* This implementation is a very thin wrapper around the Array / Map of promptbooks.
|
|
10
8
|
*
|
|
11
9
|
* @see https://github.com/webgptorg/promptbook#promptbook-library
|
|
12
10
|
*/
|
|
13
11
|
export declare class SimplePromptbookLibrary implements PromptbookLibrary {
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
* Constructs Promptbook from any sources
|
|
12
|
+
private library;
|
|
13
|
+
/**!!!
|
|
17
14
|
*
|
|
18
|
-
*
|
|
19
|
-
* Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
|
|
15
|
+
* @param promptbooks !!!
|
|
20
16
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @returns PromptbookLibrary
|
|
17
|
+
* Note: During the construction logic of all promptbooks are validated
|
|
18
|
+
* Note: It is not recommended to use this constructor directly, use `createPromptbookLibraryFromSources` *(or other variant)* instead
|
|
24
19
|
*/
|
|
25
|
-
|
|
26
|
-
private constructor();
|
|
20
|
+
constructor(...promptbooks: Array<PromptbookJson>);
|
|
27
21
|
/**
|
|
28
22
|
* Gets all promptbooks in the library
|
|
29
23
|
*/
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
|
|
2
|
+
import { PromptbookString } from '../../types/PromptbookString';
|
|
3
|
+
import { PromptbookLibrary } from '../PromptbookLibrary';
|
|
4
|
+
export declare function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory: Promise<Array<PromptbookJson | PromptbookString>> | (() => Promise<Array<PromptbookJson | PromptbookString>>)): PromptbookLibrary;
|
|
5
|
+
/***
|
|
6
|
+
* TODO: !!! Annotate all + all to README and samples
|
|
7
|
+
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PromptbookJson, PromptbookString } from '../../_packages/types.index';
|
|
2
|
+
import { SimplePromptbookLibrary } from '../SimplePromptbookLibrary';
|
|
3
|
+
export declare function createPromptbookLibraryFromSources(...promptbookSources: Array<PromptbookJson | PromptbookString>): SimplePromptbookLibrary;
|
|
4
|
+
/**
|
|
5
|
+
* Constructs Promptbook from any sources
|
|
6
|
+
*
|
|
7
|
+
* Note: During the construction syntax and logic of all sources are validated
|
|
8
|
+
* Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
|
|
9
|
+
*
|
|
10
|
+
* @param promptbookSources contents of .ptbk.md or .ptbk.json files
|
|
11
|
+
* @param settings settings for creating executor functions
|
|
12
|
+
* @returns PromptbookLibrary
|
|
13
|
+
*/
|
|
14
|
+
/***
|
|
15
|
+
* TODO: !!! Annotate all + all to README and samples
|
|
16
|
+
*/
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { string_promptbook_url } from '../../types/typeAliases';
|
|
2
|
+
import { PromptbookLibrary } from '../PromptbookLibrary';
|
|
3
|
+
export declare function createPromptbookSublibrary(library: PromptbookLibrary, predicate: (url: string_promptbook_url) => boolean): PromptbookLibrary;
|
|
4
|
+
/***
|
|
5
|
+
* TODO: !!! Annotate all + all to README and samples
|
|
6
|
+
*/
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|