@promptbook/markdown-utils 0.77.1 → 0.78.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/index.es.js +858 -815
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +10 -0
- package/esm/typings/src/_packages/types.index.d.ts +4 -0
- package/esm/typings/src/_packages/utils.index.d.ts +4 -8
- package/esm/typings/src/commands/_common/types/CommandType.d.ts +17 -0
- package/esm/typings/src/config.d.ts +14 -0
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.d.ts +1 -1
- package/esm/typings/src/conversion/utils/{extractVariables.d.ts → extractVariablesFromScript.d.ts} +2 -2
- package/esm/typings/src/conversion/utils/removePipelineCommand.d.ts +22 -0
- package/esm/typings/src/conversion/utils/{renameParameter.d.ts → renamePipelineParameter.d.ts} +3 -3
- package/esm/typings/src/errors/utils/getErrorReportUrl.d.ts +6 -0
- package/esm/typings/src/execution/execution-report/ExecutionReportString.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineString.d.ts +1 -1
- package/esm/typings/src/utils/normalization/titleToName.test.d.ts +1 -0
- package/package.json +1 -1
- package/umd/index.umd.js +861 -818
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/conversion/utils/{extractVariables.test.d.ts → extractVariablesFromScript.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/utils/{renameParameter.test.d.ts → removePipelineCommand.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/utils/{titleToName.test.d.ts → renamePipelineParameter.test.d.ts} +0 -0
- /package/esm/typings/src/{conversion/utils → utils/normalization}/titleToName.d.ts +0 -0
|
@@ -5,6 +5,8 @@ import { createCollectionFromPromise } from '../collection/constructors/createCo
|
|
|
5
5
|
import { createCollectionFromUrl } from '../collection/constructors/createCollectionFromUrl';
|
|
6
6
|
import { createSubcollection } from '../collection/constructors/createSubcollection';
|
|
7
7
|
import { NAME } from '../config';
|
|
8
|
+
import { ADMIN_EMAIL } from '../config';
|
|
9
|
+
import { ADMIN_GITHUB_NAME } from '../config';
|
|
8
10
|
import { CLAIM } from '../config';
|
|
9
11
|
import { LOGO_LIGHT_SRC } from '../config';
|
|
10
12
|
import { LOGO_DARK_SRC } from '../config';
|
|
@@ -30,6 +32,9 @@ import { pipelineJsonToString } from '../conversion/pipelineJsonToString';
|
|
|
30
32
|
import { pipelineStringToJson } from '../conversion/pipelineStringToJson';
|
|
31
33
|
import { pipelineStringToJsonSync } from '../conversion/pipelineStringToJsonSync';
|
|
32
34
|
import { prettifyPipelineString } from '../conversion/prettify/prettifyPipelineString';
|
|
35
|
+
import { extractParameterNamesFromTask } from '../conversion/utils/extractParameterNamesFromTask';
|
|
36
|
+
import { removePipelineCommand } from '../conversion/utils/removePipelineCommand';
|
|
37
|
+
import { renamePipelineParameter } from '../conversion/utils/renamePipelineParameter';
|
|
33
38
|
import { stringifyPipelineJson } from '../conversion/utils/stringifyPipelineJson';
|
|
34
39
|
import { validatePipeline } from '../conversion/validation/validatePipeline';
|
|
35
40
|
import { CallbackInterfaceTools } from '../dialogs/callback/CallbackInterfaceTools';
|
|
@@ -120,6 +125,8 @@ export { createCollectionFromPromise };
|
|
|
120
125
|
export { createCollectionFromUrl };
|
|
121
126
|
export { createSubcollection };
|
|
122
127
|
export { NAME };
|
|
128
|
+
export { ADMIN_EMAIL };
|
|
129
|
+
export { ADMIN_GITHUB_NAME };
|
|
123
130
|
export { CLAIM };
|
|
124
131
|
export { LOGO_LIGHT_SRC };
|
|
125
132
|
export { LOGO_DARK_SRC };
|
|
@@ -145,6 +152,9 @@ export { pipelineJsonToString };
|
|
|
145
152
|
export { pipelineStringToJson };
|
|
146
153
|
export { pipelineStringToJsonSync };
|
|
147
154
|
export { prettifyPipelineString };
|
|
155
|
+
export { extractParameterNamesFromTask };
|
|
156
|
+
export { removePipelineCommand };
|
|
157
|
+
export { renamePipelineParameter };
|
|
148
158
|
export { stringifyPipelineJson };
|
|
149
159
|
export { validatePipeline };
|
|
150
160
|
export { CallbackInterfaceTools };
|
|
@@ -5,6 +5,8 @@ import type { PipelineBothCommandParser } from '../commands/_common/types/Comman
|
|
|
5
5
|
import type { PipelineHeadCommandParser } from '../commands/_common/types/CommandParser';
|
|
6
6
|
import type { PipelineTaskCommandParser } from '../commands/_common/types/CommandParser';
|
|
7
7
|
import type { CommandParserInput } from '../commands/_common/types/CommandParser';
|
|
8
|
+
import type { CommandType } from '../commands/_common/types/CommandType';
|
|
9
|
+
import type { CommandTypeOrAlias } from '../commands/_common/types/CommandType';
|
|
8
10
|
import type { CommandUsagePlace } from '../commands/_common/types/CommandUsagePlaces';
|
|
9
11
|
import type { ExpectCommand } from '../commands/EXPECT/ExpectCommand';
|
|
10
12
|
import type { ForeachJson } from '../commands/FOREACH/ForeachJson';
|
|
@@ -263,6 +265,8 @@ export type { PipelineBothCommandParser };
|
|
|
263
265
|
export type { PipelineHeadCommandParser };
|
|
264
266
|
export type { PipelineTaskCommandParser };
|
|
265
267
|
export type { CommandParserInput };
|
|
268
|
+
export type { CommandType };
|
|
269
|
+
export type { CommandTypeOrAlias };
|
|
266
270
|
export type { CommandUsagePlace };
|
|
267
271
|
export type { ExpectCommand };
|
|
268
272
|
export type { ForeachJson };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
2
2
|
import { renderPromptbookMermaid } from '../conversion/prettify/renderPipelineMermaidOptions';
|
|
3
|
-
import {
|
|
4
|
-
import { extractVariables } from '../conversion/utils/extractVariables';
|
|
5
|
-
import { renameParameter } from '../conversion/utils/renameParameter';
|
|
6
|
-
import { titleToName } from '../conversion/utils/titleToName';
|
|
3
|
+
import { extractVariablesFromScript } from '../conversion/utils/extractVariablesFromScript';
|
|
7
4
|
import { deserializeError } from '../errors/utils/deserializeError';
|
|
8
5
|
import { serializeError } from '../errors/utils/serializeError';
|
|
9
6
|
import { forEachAsync } from '../execution/utils/forEachAsync';
|
|
@@ -45,6 +42,7 @@ import { parseKeywords } from '../utils/normalization/parseKeywords';
|
|
|
45
42
|
import { parseKeywordsFromString } from '../utils/normalization/parseKeywordsFromString';
|
|
46
43
|
import { removeDiacritics } from '../utils/normalization/removeDiacritics';
|
|
47
44
|
import { searchKeywords } from '../utils/normalization/searchKeywords';
|
|
45
|
+
import { titleToName } from '../utils/normalization/titleToName';
|
|
48
46
|
import { spaceTrim } from '../utils/organization/spaceTrim';
|
|
49
47
|
import { extractParameterNames } from '../utils/parameters/extractParameterNames';
|
|
50
48
|
import { replaceParameters } from '../utils/parameters/replaceParameters';
|
|
@@ -75,10 +73,7 @@ import { isValidUrl } from '../utils/validators/url/isValidUrl';
|
|
|
75
73
|
import { isValidUuid } from '../utils/validators/uuid/isValidUuid';
|
|
76
74
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
77
75
|
export { renderPromptbookMermaid };
|
|
78
|
-
export {
|
|
79
|
-
export { extractVariables };
|
|
80
|
-
export { renameParameter };
|
|
81
|
-
export { titleToName };
|
|
76
|
+
export { extractVariablesFromScript };
|
|
82
77
|
export { deserializeError };
|
|
83
78
|
export { serializeError };
|
|
84
79
|
export { forEachAsync };
|
|
@@ -120,6 +115,7 @@ export { parseKeywords };
|
|
|
120
115
|
export { parseKeywordsFromString };
|
|
121
116
|
export { removeDiacritics };
|
|
122
117
|
export { searchKeywords };
|
|
118
|
+
export { titleToName };
|
|
123
119
|
export { spaceTrim };
|
|
124
120
|
export { extractParameterNames };
|
|
125
121
|
export { replaceParameters };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Command } from './Command';
|
|
2
|
+
/**
|
|
3
|
+
* Command is one piece of the book file section which adds some logic to the task or the whole pipeline.
|
|
4
|
+
* It is parsed from the markdown from ul/ol items - one command per one item.
|
|
5
|
+
*
|
|
6
|
+
* This is a type of the command like "KNOWLEDGE" or "PERSONA"
|
|
7
|
+
*/
|
|
8
|
+
export type CommandType = Command['type'];
|
|
9
|
+
/**
|
|
10
|
+
* Command is one piece of the book file section which adds some logic to the task or the whole pipeline.
|
|
11
|
+
* It is parsed from the markdown from ul/ol items - one command per one item.
|
|
12
|
+
*
|
|
13
|
+
* This is a type of the command like "KNOWLEDGE" or "PERSONA"
|
|
14
|
+
*
|
|
15
|
+
export type CommandTypeOrAlias = Command['type'] | Command['aliasNames'] | Command['deprecatedNames'];
|
|
16
|
+
// <- TODO: [🧘] Implement
|
|
17
|
+
*/
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { CsvSettings } from './formats/csv/CsvSettings';
|
|
2
2
|
import type { IntermediateFilesStrategy } from './types/IntermediateFilesStrategy';
|
|
3
|
+
import type { string_email } from './types/typeAliases';
|
|
4
|
+
import type { string_name } from './types/typeAliases';
|
|
3
5
|
import type { string_url_image } from './types/typeAliases';
|
|
4
6
|
/**
|
|
5
7
|
* Warning message for the generated sections and files files
|
|
@@ -15,6 +17,18 @@ export declare const GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has be
|
|
|
15
17
|
* @public exported from `@promptbook/core`
|
|
16
18
|
*/
|
|
17
19
|
export declare const NAME = "Promptbook";
|
|
20
|
+
/**
|
|
21
|
+
* Email of the responsible person
|
|
22
|
+
*
|
|
23
|
+
* @public exported from `@promptbook/core`
|
|
24
|
+
*/
|
|
25
|
+
export declare const ADMIN_EMAIL: string_email;
|
|
26
|
+
/**
|
|
27
|
+
* Name of the responsible person for the Promptbook on GitHub
|
|
28
|
+
*
|
|
29
|
+
* @public exported from `@promptbook/core`
|
|
30
|
+
*/
|
|
31
|
+
export declare const ADMIN_GITHUB_NAME: string_name;
|
|
18
32
|
/**
|
|
19
33
|
* Claim for the Promptbook
|
|
20
34
|
*
|
|
@@ -7,7 +7,7 @@ import type { string_parameter_name } from '../../types/typeAliases';
|
|
|
7
7
|
* @param task the task with used parameters
|
|
8
8
|
* @returns the set of parameter names
|
|
9
9
|
* @throws {ParseError} if the script is invalid
|
|
10
|
-
* @public exported from `@promptbook/
|
|
10
|
+
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
11
11
|
*/
|
|
12
12
|
export declare function extractParameterNamesFromTask(task: ReadonlyDeep<Pick<TaskJson, 'title' | 'description' | 'taskType' | 'content' | 'preparedContent' | 'jokerParameterNames' | 'foreach'>>): Set<string_parameter_name>;
|
|
13
13
|
/**
|
package/esm/typings/src/conversion/utils/{extractVariables.d.ts → extractVariablesFromScript.d.ts}
RENAMED
|
@@ -6,9 +6,9 @@ import type { string_javascript_name } from '../../types/typeAliases';
|
|
|
6
6
|
* @param script from which to extract the variables
|
|
7
7
|
* @returns the list of variable names
|
|
8
8
|
* @throws {ParseError} if the script is invalid
|
|
9
|
-
* @public exported from `@promptbook/utils`
|
|
9
|
+
* @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
|
|
10
10
|
*/
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function extractVariablesFromScript(script: string_javascript): Set<string_javascript_name>;
|
|
12
12
|
/**
|
|
13
13
|
* TODO: [🔣] Support for multiple languages - python, java,...
|
|
14
14
|
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CommandType } from '../../commands/_common/types/CommandType';
|
|
2
|
+
import type { PipelineString } from '../../pipeline/PipelineString';
|
|
3
|
+
/**
|
|
4
|
+
* Options for `removePipelineCommand`
|
|
5
|
+
*/
|
|
6
|
+
type RemovePipelineCommandOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* The command you want to remove
|
|
9
|
+
*/
|
|
10
|
+
command: CommandType;
|
|
11
|
+
/**
|
|
12
|
+
* Pipeline you want to remove command from
|
|
13
|
+
*/
|
|
14
|
+
pipeline: PipelineString;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Function `removePipelineCommand` will remove one command from pipeline string
|
|
18
|
+
*
|
|
19
|
+
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
20
|
+
*/
|
|
21
|
+
export declare function removePipelineCommand(options: RemovePipelineCommandOptions): PipelineString;
|
|
22
|
+
export {};
|
package/esm/typings/src/conversion/utils/{renameParameter.d.ts → renamePipelineParameter.d.ts}
RENAMED
|
@@ -16,11 +16,11 @@ type RenameParameterOptions = {
|
|
|
16
16
|
readonly newParameterName: string_name;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
* Function `
|
|
19
|
+
* Function `renamePipelineParameter` will find all usable parameters for given task
|
|
20
20
|
* In other words, it will find all parameters that are not used in the task itseld and all its dependencies
|
|
21
21
|
*
|
|
22
22
|
* @throws {PipelineLogicError} If the new parameter name is already used in the pipeline
|
|
23
|
-
* @public exported from `@promptbook/
|
|
23
|
+
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
24
24
|
*/
|
|
25
|
-
export declare function
|
|
25
|
+
export declare function renamePipelineParameter(options: RenameParameterOptions): PipelineJson;
|
|
26
26
|
export {};
|
|
@@ -24,7 +24,7 @@ export declare const OPENAI_MODELS: ReadonlyArray<AvailableModel & {
|
|
|
24
24
|
* @see https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4
|
|
25
25
|
* @see https://openai.com/api/pricing/
|
|
26
26
|
* @see /other/playground/playground.ts
|
|
27
|
-
* TODO: [🍓] Make better
|
|
27
|
+
* TODO: [🍓][💩] Make better
|
|
28
28
|
* TODO: Change model titles to human eg: "gpt-4-turbo-2024-04-09" -> "GPT-4 Turbo (2024-04-09)"
|
|
29
29
|
* TODO: [🚸] Not all models are compatible with JSON mode, add this information here and use it
|
|
30
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -8,5 +8,5 @@ export type PipelineString = string & {
|
|
|
8
8
|
readonly _type: 'Promptbook';
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
* TODO:
|
|
11
|
+
* TODO: [💩] Better validation (validatePipelineString) or remove branded type and make it just string
|
|
12
12
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED