@promptbook/remote-server 0.67.9 → 0.68.0-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/README.md +2 -2
- package/esm/index.es.js +11 -8
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +7 -16
- package/esm/typings/src/_packages/core.index.d.ts +2 -2
- package/esm/typings/src/_packages/types.index.d.ts +20 -24
- package/esm/typings/src/_packages/utils.index.d.ts +2 -2
- package/esm/typings/src/commands/BLOCK/BlockTypes.d.ts +1 -1
- package/esm/typings/src/commands/BLOCK/blockCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/EXPECT/ExpectCommand.d.ts +14 -6
- package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +9 -0
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +14 -0
- package/esm/typings/src/commands/{EXPECT/ExpectFormatCommand.d.ts → FORMAT/FormatCommand.d.ts} +2 -2
- package/esm/typings/src/commands/FORMAT/formatCommand.test.d.ts +1 -0
- package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/URL/urlCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +6 -4
- package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +137 -30
- package/esm/typings/src/commands/index.d.ts +1 -1
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +1 -1
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -2
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +2 -2
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +14 -0
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.test.d.ts +1 -0
- package/esm/typings/src/conversion/utils/extractVariables.d.ts +1 -1
- package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
- package/esm/typings/src/errors/{ParsingError.d.ts → ParseError.d.ts} +5 -2
- package/esm/typings/src/errors/index.d.ts +2 -2
- package/esm/typings/src/execution/CommonExecutionToolsOptions.d.ts +5 -0
- package/esm/typings/src/execution/PromptResult.d.ts +2 -0
- package/esm/typings/src/execution/PromptResultUsage.d.ts +1 -1
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +1 -1
- package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +1 -1
- package/esm/typings/src/postprocessing/utils/extractBlock.d.ts +2 -2
- package/esm/typings/src/postprocessing/utils/extractJsonBlock.d.ts +3 -3
- package/esm/typings/src/prepare/prepareTemplates.d.ts +3 -4
- package/esm/typings/src/prepare/unpreparePipeline.d.ts +1 -1
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -1
- package/esm/typings/src/storage/utils/PrefixStorage.d.ts +1 -1
- package/esm/typings/src/types/ModelRequirements.d.ts +2 -0
- package/esm/typings/src/types/PipelineJson/DialogTemplateJson.d.ts +13 -0
- package/esm/typings/src/types/PipelineJson/Expectations.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/{PromptTemplateParameterJson.d.ts → ParameterJson.d.ts} +2 -2
- package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +10 -5
- package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +20 -9
- package/esm/typings/src/types/PipelineJson/{ScriptJson.d.ts → ScriptTemplateJson.d.ts} +4 -4
- package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +3 -3
- package/esm/typings/src/types/PipelineJson/TemplateJson.d.ts +11 -0
- package/esm/typings/src/types/PipelineJson/{PromptTemplateJsonCommon.d.ts → TemplateJsonCommon.d.ts} +3 -4
- package/esm/typings/src/types/Prompt.d.ts +4 -2
- package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +1 -0
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
- package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
- package/esm/typings/src/utils/organization/___and___.d.ts +7 -0
- package/esm/typings/src/utils/organization/{___.d.ts → ___or___.d.ts} +1 -1
- package/esm/typings/src/utils/parseNumber.d.ts +1 -1
- package/esm/typings/src/utils/serialization/clonePipeline.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +11 -8
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/commands/EXPECT/ExpectAmountCommand.d.ts +0 -17
- package/esm/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts +0 -14
- package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +0 -27
- package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +0 -14
- /package/esm/typings/src/{conversion/utils/extractParameterNamesFromPromptTemplate.test.d.ts → commands/FOREACH/foreachCommand.test.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PipelineHeadCommandParser } from '../_common/types/CommandParser';
|
|
2
2
|
import type { KnowledgeCommand } from './KnowledgeCommand';
|
|
3
3
|
/**
|
|
4
4
|
* Parses the knowledge command
|
|
@@ -6,4 +6,4 @@ import type { KnowledgeCommand } from './KnowledgeCommand';
|
|
|
6
6
|
* @see ./KNOWLEDGE-README.md for more details
|
|
7
7
|
* @private within the commands folder
|
|
8
8
|
*/
|
|
9
|
-
export declare const knowledgeCommandParser:
|
|
9
|
+
export declare const knowledgeCommandParser: PipelineHeadCommandParser<KnowledgeCommand>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PipelineBothCommandParser } from '../_common/types/CommandParser';
|
|
2
2
|
import type { ModelCommand } from './ModelCommand';
|
|
3
3
|
/**
|
|
4
4
|
* Parses the model command
|
|
@@ -6,4 +6,4 @@ import type { ModelCommand } from './ModelCommand';
|
|
|
6
6
|
* @see ./MODEL-README.md for more details
|
|
7
7
|
* @private within the commands folder
|
|
8
8
|
*/
|
|
9
|
-
export declare const modelCommandParser:
|
|
9
|
+
export declare const modelCommandParser: PipelineBothCommandParser<ModelCommand>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PipelineBothCommandParser } from '../_common/types/CommandParser';
|
|
2
2
|
import type { ParameterCommand } from './ParameterCommand';
|
|
3
3
|
/**
|
|
4
4
|
* Parses the parameter command
|
|
@@ -6,4 +6,4 @@ import type { ParameterCommand } from './ParameterCommand';
|
|
|
6
6
|
* @see ./PARAMETER-README.md for more details
|
|
7
7
|
* @private within the commands folder
|
|
8
8
|
*/
|
|
9
|
-
export declare const parameterCommandParser:
|
|
9
|
+
export declare const parameterCommandParser: PipelineBothCommandParser<ParameterCommand>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PipelineBothCommandParser } from '../_common/types/CommandParser';
|
|
2
2
|
import type { PersonaCommand } from './PersonaCommand';
|
|
3
3
|
/**
|
|
4
4
|
* Parses the persona command
|
|
@@ -6,4 +6,4 @@ import type { PersonaCommand } from './PersonaCommand';
|
|
|
6
6
|
* @see ./PERSONA-README.md for more details
|
|
7
7
|
* @private within the commands folder
|
|
8
8
|
*/
|
|
9
|
-
export declare const personaCommandParser:
|
|
9
|
+
export declare const personaCommandParser: PipelineBothCommandParser<PersonaCommand>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PipelineTemplateCommandParser } from '../_common/types/CommandParser';
|
|
2
2
|
import type { PostprocessCommand } from './PostprocessCommand';
|
|
3
3
|
/**
|
|
4
4
|
* Parses the postprocess command
|
|
@@ -6,4 +6,4 @@ import type { PostprocessCommand } from './PostprocessCommand';
|
|
|
6
6
|
* @see ./POSTPROCESS-README.md for more details
|
|
7
7
|
* @private within the commands folder
|
|
8
8
|
*/
|
|
9
|
-
export declare const postprocessCommandParser:
|
|
9
|
+
export declare const postprocessCommandParser: PipelineTemplateCommandParser<PostprocessCommand>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PipelineHeadCommandParser } from '../_common/types/CommandParser';
|
|
2
2
|
import type { PromptbookVersionCommand } from './PromptbookVersionCommand';
|
|
3
3
|
/**
|
|
4
4
|
* Parses the PROMPTBOOK_VERSION command
|
|
@@ -6,4 +6,4 @@ import type { PromptbookVersionCommand } from './PromptbookVersionCommand';
|
|
|
6
6
|
* @see ./PROMPTBOOK_VERSION-README.md for more details
|
|
7
7
|
* @private within the commands folder
|
|
8
8
|
*/
|
|
9
|
-
export declare const promptbookVersionCommandParser:
|
|
9
|
+
export declare const promptbookVersionCommandParser: PipelineHeadCommandParser<PromptbookVersionCommand>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PipelineHeadCommandParser } from '../_common/types/CommandParser';
|
|
2
2
|
import type { UrlCommand } from './UrlCommand';
|
|
3
3
|
/**
|
|
4
4
|
* Parses the url command
|
|
@@ -6,4 +6,4 @@ import type { UrlCommand } from './UrlCommand';
|
|
|
6
6
|
* @see ./URL-README.md for more details
|
|
7
7
|
* @private within the commands folder
|
|
8
8
|
*/
|
|
9
|
-
export declare const urlCommandParser:
|
|
9
|
+
export declare const urlCommandParser: PipelineHeadCommandParser<UrlCommand>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PipelineHeadCommandParser } from '../_common/types/CommandParser';
|
|
2
2
|
import type { ActionCommand } from './ActionCommand';
|
|
3
3
|
/**
|
|
4
4
|
* Parses the action command
|
|
@@ -6,4 +6,4 @@ import type { ActionCommand } from './ActionCommand';
|
|
|
6
6
|
* @see ./ACTION-README.md for more details
|
|
7
7
|
* @private within the commands folder
|
|
8
8
|
*/
|
|
9
|
-
export declare const actionCommandParser:
|
|
9
|
+
export declare const actionCommandParser: PipelineHeadCommandParser<ActionCommand>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PipelineHeadCommandParser } from '../_common/types/CommandParser';
|
|
2
2
|
import type { InstrumentCommand } from './InstrumentCommand';
|
|
3
3
|
/**
|
|
4
4
|
* Parses the instrument command
|
|
@@ -6,4 +6,4 @@ import type { InstrumentCommand } from './InstrumentCommand';
|
|
|
6
6
|
* @see ./INSTRUMENT-README.md for more details
|
|
7
7
|
* @private within the commands folder
|
|
8
8
|
*/
|
|
9
|
-
export declare const instrumentCommandParser:
|
|
9
|
+
export declare const instrumentCommandParser: PipelineHeadCommandParser<InstrumentCommand>;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PipelineBothCommandParser } from '../_common/types/CommandParser';
|
|
2
2
|
import type { BoilerplateCommand } from './BoilerplateCommand';
|
|
3
3
|
/**
|
|
4
4
|
* Parses the boilerplate command
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.ptbk.md` file
|
|
7
|
+
*
|
|
8
|
+
* @see ./BOILERPLATE-README.md for more details <- TODO: @@@ Write theese README files OR remove this link + add annotation here (to all commands)
|
|
7
9
|
* @private within the commands folder
|
|
8
10
|
*/
|
|
9
|
-
export declare const boilerplateCommandParser:
|
|
11
|
+
export declare const boilerplateCommandParser: PipelineBothCommandParser<BoilerplateCommand>;
|
|
10
12
|
/**
|
|
11
|
-
* TODO:
|
|
13
|
+
* TODO: !!!!!! Make .ptbk.md file with examples of the BOILERPLATE command and fail
|
|
12
14
|
*/
|
|
@@ -5,7 +5,7 @@ import type { CommandUsagePlace } from './types/CommandUsagePlaces';
|
|
|
5
5
|
* Parses one line of ul/ol to command
|
|
6
6
|
*
|
|
7
7
|
* @returns parsed command object
|
|
8
|
-
* @throws {
|
|
8
|
+
* @throws {ParseError} if the command is invalid
|
|
9
9
|
*
|
|
10
10
|
* @private within the pipelineStringToJson
|
|
11
11
|
*/
|
|
@@ -1,64 +1,171 @@
|
|
|
1
1
|
import type { WritableDeep } from 'type-fest';
|
|
2
|
-
import type { PromptTemplateJson } from '../../../types/PipelineJson/PromptTemplateJson';
|
|
3
2
|
import type { PipelineJson } from '../../../types/PipelineJson/PipelineJson';
|
|
3
|
+
import type { TemplateJson } from '../../../types/PipelineJson/TemplateJson';
|
|
4
4
|
import type { string_markdown_text } from '../../../types/typeAliases';
|
|
5
5
|
import type { string_name } from '../../../types/typeAliases';
|
|
6
6
|
import type { string_promptbook_documentation_url } from '../../../types/typeAliases';
|
|
7
7
|
import type { string_SCREAMING_CASE } from '../../../utils/normalization/normalizeTo_SCREAMING_CASE';
|
|
8
|
+
import type { ___and___ } from '../../../utils/organization/___and___';
|
|
8
9
|
import type { CommandUsagePlace } from './CommandUsagePlaces';
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* @@@
|
|
12
|
+
*
|
|
13
|
+
* @private just abstract helper for command parsers
|
|
14
|
+
*/
|
|
15
|
+
export type CommandBase = {
|
|
10
16
|
type: string_name & string_SCREAMING_CASE;
|
|
11
|
-
}
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* @@@
|
|
20
|
+
*/
|
|
21
|
+
export type CommandParser<TCommand extends CommandBase> = PipelineHeadCommandParser<TCommand> | PipelineTemplateCommandParser<TCommand> | PipelineBothCommandParser<TCommand>;
|
|
22
|
+
/**
|
|
23
|
+
* @@@
|
|
24
|
+
*
|
|
25
|
+
* @private just abstract the common properties of the command parsers
|
|
26
|
+
*/
|
|
27
|
+
export type CommonCommandParser<TCommand extends CommandBase> = {
|
|
28
|
+
/**
|
|
29
|
+
* @@@
|
|
30
|
+
*/
|
|
12
31
|
readonly name: string_name & string_SCREAMING_CASE;
|
|
32
|
+
/**
|
|
33
|
+
* @@@
|
|
34
|
+
*/
|
|
35
|
+
readonly isUsedInPipelineHead: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* @@@
|
|
38
|
+
*/
|
|
39
|
+
readonly isUsedInPipelineTemplate: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @@@
|
|
42
|
+
*/
|
|
13
43
|
readonly aliasNames?: Array<string_name & string_SCREAMING_CASE>;
|
|
44
|
+
/**
|
|
45
|
+
* @@@
|
|
46
|
+
*/
|
|
14
47
|
readonly deprecatedNames?: Array<string_name & string_SCREAMING_CASE>;
|
|
15
|
-
|
|
48
|
+
/**
|
|
49
|
+
* @@@
|
|
50
|
+
*/
|
|
16
51
|
readonly description: string_markdown_text;
|
|
52
|
+
/**
|
|
53
|
+
* @@@
|
|
54
|
+
*/
|
|
17
55
|
readonly documentationUrl: string_promptbook_documentation_url;
|
|
56
|
+
/**
|
|
57
|
+
* @@@
|
|
58
|
+
*/
|
|
18
59
|
readonly examples: Array<string_markdown_text>;
|
|
19
60
|
/**
|
|
20
|
-
* @throws {
|
|
61
|
+
* @throws {ParseError} if the parsing fails
|
|
21
62
|
*/
|
|
22
63
|
parse(input: CommandParserInput): TCommand;
|
|
23
64
|
/**
|
|
24
|
-
*
|
|
65
|
+
* Converts the command back to string
|
|
66
|
+
*
|
|
67
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
25
68
|
*/
|
|
26
|
-
|
|
69
|
+
stringify(command: TCommand): string_markdown_text;
|
|
27
70
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
71
|
+
/**
|
|
72
|
+
* @@@
|
|
73
|
+
*/
|
|
74
|
+
export type PipelineBothCommandParser<TCommand extends CommandBase> = ___and___ & Omit<PipelineHeadCommandParser<TCommand>, 'isUsedInPipelineTemplate'> & Omit<PipelineTemplateCommandParser<TCommand>, 'isUsedInPipelineHead'>;
|
|
75
|
+
/**
|
|
76
|
+
* @@@
|
|
77
|
+
*/
|
|
78
|
+
export type PipelineHeadCommandParser<TCommand extends CommandBase> = CommonCommandParser<TCommand> & {
|
|
79
|
+
/**
|
|
80
|
+
* @@@
|
|
81
|
+
*/
|
|
82
|
+
readonly isUsedInPipelineHead: true;
|
|
83
|
+
/**
|
|
84
|
+
* @@@
|
|
85
|
+
*/
|
|
86
|
+
readonly isUsedInPipelineTemplate: false;
|
|
87
|
+
/**
|
|
88
|
+
* Apply the command to the `pipelineJson`
|
|
89
|
+
*
|
|
90
|
+
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
91
|
+
*/
|
|
92
|
+
$applyToPipelineJson(command: TCommand, $pipelineJson: $PipelineJson): void;
|
|
93
|
+
/**
|
|
94
|
+
* Reads the command from the `PipelineJson`
|
|
95
|
+
*
|
|
96
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
97
|
+
*/
|
|
98
|
+
takeFromPipelineJson(pipelineJson: PipelineJson): Array<TCommand>;
|
|
34
99
|
};
|
|
35
100
|
/**
|
|
36
|
-
* @@@
|
|
101
|
+
* @@@
|
|
37
102
|
*/
|
|
38
|
-
export type
|
|
103
|
+
export type PipelineTemplateCommandParser<TCommand extends CommandBase> = CommonCommandParser<TCommand> & {
|
|
39
104
|
/**
|
|
40
|
-
* @@@
|
|
105
|
+
* @@@
|
|
41
106
|
*/
|
|
42
|
-
readonly
|
|
107
|
+
readonly isUsedInPipelineHead: false;
|
|
43
108
|
/**
|
|
44
109
|
* @@@
|
|
110
|
+
*/
|
|
111
|
+
readonly isUsedInPipelineTemplate: true;
|
|
112
|
+
/**
|
|
113
|
+
* Apply the command to the `pipelineJson`
|
|
45
114
|
*
|
|
46
|
-
*
|
|
115
|
+
* Note: `$` is used to indicate that this function mutates given `templateJson` and/or `pipelineJson`
|
|
116
|
+
*/
|
|
117
|
+
$applyToTemplateJson(command: TCommand, $templateJson: $TemplateJson, $pipelineJson: $PipelineJson): void;
|
|
118
|
+
/**
|
|
119
|
+
* Reads the command from the `TemplateJson`
|
|
47
120
|
*
|
|
48
|
-
*
|
|
49
|
-
* - `PIPELINE_HEAD` it is `null`
|
|
50
|
-
* - `PIPELINE_TEMPLATE` it is the prompt template
|
|
121
|
+
* Note: This is used in `pipelineJsonToString` utility
|
|
51
122
|
*/
|
|
52
|
-
|
|
123
|
+
takeFromTemplateJson($templateJson: $TemplateJson): Array<TCommand>;
|
|
53
124
|
};
|
|
54
125
|
/**
|
|
55
|
-
*
|
|
56
|
-
* TODO: [🍧][♓️] Add order here
|
|
57
|
-
* TODO: [🧠] Maybe put flag if it is for whole `.ptbk.md` file of just one section
|
|
58
|
-
* TODO: [🍧] All commands must implement `applyToPipelineJson` method
|
|
59
|
-
* which will apply parsed command to the pipeline JSON
|
|
60
|
-
* it will be called from `pipelineStringToJsonSync`
|
|
61
|
-
* and replace hardcoded switch statement and [💐]
|
|
62
|
-
* and throw ParsingError
|
|
126
|
+
* @@@
|
|
63
127
|
*
|
|
128
|
+
* Note: `$` is used to indicate that purpose of this type is to mutate the given object
|
|
129
|
+
*
|
|
130
|
+
* @private internal helper for command parsers
|
|
131
|
+
*/
|
|
132
|
+
export type $TemplateJson = {
|
|
133
|
+
isBlockTypeSet: boolean;
|
|
134
|
+
isTemplateBlock: boolean;
|
|
135
|
+
} & Partial<WritableDeep<TemplateJson>>;
|
|
136
|
+
/**
|
|
137
|
+
* @@@
|
|
138
|
+
*
|
|
139
|
+
* Note: `$` is used to indicate that purpose of this type is to mutate the given object
|
|
140
|
+
*
|
|
141
|
+
* @private internal helper for command parsers
|
|
142
|
+
*/
|
|
143
|
+
export type $PipelineJson = WritableDeep<PipelineJson>;
|
|
144
|
+
/**
|
|
145
|
+
* @@@
|
|
146
|
+
*/
|
|
147
|
+
export type CommandParserInput = {
|
|
148
|
+
/**
|
|
149
|
+
* @@@
|
|
150
|
+
*/
|
|
151
|
+
readonly usagePlace: CommandUsagePlace;
|
|
152
|
+
/**
|
|
153
|
+
* @@@
|
|
154
|
+
*/
|
|
155
|
+
readonly raw: string_markdown_text;
|
|
156
|
+
/**
|
|
157
|
+
* @@@
|
|
158
|
+
*/
|
|
159
|
+
readonly rawArgs: string_markdown_text;
|
|
160
|
+
/**
|
|
161
|
+
* @@@
|
|
162
|
+
*/
|
|
163
|
+
readonly normalized: string_name & string_SCREAMING_CASE;
|
|
164
|
+
/**
|
|
165
|
+
* @@@
|
|
166
|
+
*/
|
|
167
|
+
readonly args: Array<string_name & string_SCREAMING_CASE>;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* TODO: [♓️] Add order here
|
|
64
171
|
*/
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @private internal index of `parseCommand`
|
|
5
5
|
*/
|
|
6
|
-
export declare const COMMANDS: readonly [import("./_common/types/CommandParser").
|
|
6
|
+
export declare const COMMANDS: readonly [import("./_common/types/CommandParser").PipelineTemplateCommandParser<import("./BLOCK/BlockCommand").BlockCommand>, import("./_common/types/CommandParser").PipelineTemplateCommandParser<import("./EXPECT/ExpectCommand").ExpectCommand>, import("./_common/types/CommandParser").PipelineTemplateCommandParser<import("./FORMAT/FormatCommand").FormatCommand>, import("./_common/types/CommandParser").PipelineTemplateCommandParser<import("./JOKER/JokerCommand").JokerCommand>, import("./_common/types/CommandParser").PipelineBothCommandParser<import("./MODEL/ModelCommand").ModelCommand>, import("./_common/types/CommandParser").PipelineBothCommandParser<import("./PARAMETER/ParameterCommand").ParameterCommand>, import("./_common/types/CommandParser").PipelineTemplateCommandParser<import("./POSTPROCESS/PostprocessCommand").PostprocessCommand>, import("./_common/types/CommandParser").PipelineHeadCommandParser<import("./PROMPTBOOK_VERSION/PromptbookVersionCommand").PromptbookVersionCommand>, import("./_common/types/CommandParser").PipelineHeadCommandParser<import("./URL/UrlCommand").UrlCommand>, import("./_common/types/CommandParser").PipelineHeadCommandParser<import("./KNOWLEDGE/KnowledgeCommand").KnowledgeCommand>, import("./_common/types/CommandParser").PipelineHeadCommandParser<import("./X_ACTION/ActionCommand").ActionCommand>, import("./_common/types/CommandParser").PipelineHeadCommandParser<import("./X_INSTRUMENT/InstrumentCommand").InstrumentCommand>, import("./_common/types/CommandParser").PipelineBothCommandParser<import("./PERSONA/PersonaCommand").PersonaCommand>, import("./_common/types/CommandParser").PipelineTemplateCommandParser<import("./FOREACH/ForeachCommand").ForeachCommand>, import("./_common/types/CommandParser").PipelineBothCommandParser<import("./_BOILERPLATE/BoilerplateCommand").BoilerplateCommand>];
|
|
@@ -9,7 +9,7 @@ import type { PipelineString } from '../types/PipelineString';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function pipelineJsonToString(pipelineJson: PipelineJson): PipelineString;
|
|
11
11
|
/**
|
|
12
|
-
* TODO:
|
|
12
|
+
* TODO: !!!!!! Implement new features and commands into `templateParameterJsonToString`
|
|
13
13
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
14
14
|
* TODO: [🏛] Maybe make some markdown builder
|
|
15
15
|
* TODO: [🏛] Escape all
|
|
@@ -28,7 +28,7 @@ export type PipelineStringToJsonOptions = {
|
|
|
28
28
|
* @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
|
|
29
29
|
* @param options - Options and tools for the compilation
|
|
30
30
|
* @returns {Promptbook} compiled in JSON format (.ptbk.json)
|
|
31
|
-
* @throws {
|
|
31
|
+
* @throws {ParseError} if the promptbook string is not valid
|
|
32
32
|
* @public exported from `@promptbook/core`
|
|
33
33
|
*/
|
|
34
34
|
export declare function pipelineStringToJson(pipelineString: PipelineString, options?: PipelineStringToJsonOptions): Promise<PipelineJson>;
|
|
@@ -13,7 +13,7 @@ import type { PipelineString } from '../types/PipelineString';
|
|
|
13
13
|
*
|
|
14
14
|
* @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
|
|
15
15
|
* @returns {Promptbook} compiled in JSON format (.ptbk.json)
|
|
16
|
-
* @throws {
|
|
16
|
+
* @throws {ParseError} if the promptbook string is not valid
|
|
17
17
|
* @public exported from `@promptbook/core`
|
|
18
18
|
*/
|
|
19
19
|
export declare function pipelineStringToJsonSync(pipelineString: PipelineString): PipelineJson;
|
|
@@ -25,5 +25,5 @@ export declare function pipelineStringToJsonSync(pipelineString: PipelineString)
|
|
|
25
25
|
* TODO: [🥞] Not optimal parsing because `splitMarkdownIntoSections` is executed twice with same string, once through `flattenMarkdown` and second directly here
|
|
26
26
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
27
27
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
28
|
-
* TODO: [🍙] Make some
|
|
28
|
+
* TODO: [🍙] Make some standard order of json properties
|
|
29
29
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TemplateJson } from '../../types/PipelineJson/TemplateJson';
|
|
3
3
|
import type { string_href } from '../../types/typeAliases';
|
|
4
4
|
/**
|
|
5
5
|
* Addtional options for rendering Mermaid graph
|
|
@@ -8,7 +8,7 @@ export type renderPipelineMermaidOptions = {
|
|
|
8
8
|
/**
|
|
9
9
|
* Callback for creating from prompt template graph node
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
linkTemplate?(template: TemplateJson): {
|
|
12
12
|
href: string_href;
|
|
13
13
|
title: string;
|
|
14
14
|
} | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TemplateJson } from '../../types/PipelineJson/TemplateJson';
|
|
2
|
+
import type { string_parameter_name } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Parses the prompt template and returns the set of all used parameters
|
|
5
|
+
*
|
|
6
|
+
* @param template the template with used parameters
|
|
7
|
+
* @returns the set of parameter names
|
|
8
|
+
* @throws {ParseError} if the script is invalid
|
|
9
|
+
* @public exported from `@promptbook/utils`
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractParameterNamesFromTemplate(template: Pick<TemplateJson, 'title' | 'description' | 'blockType' | 'content' | 'preparedContent' | 'jokerParameterNames'>): Set<string_parameter_name>;
|
|
12
|
+
/**
|
|
13
|
+
* TODO: [🔣] If script require contentLanguage
|
|
14
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,7 +5,7 @@ import type { string_javascript_name } from '../../types/typeAliases';
|
|
|
5
5
|
*
|
|
6
6
|
* @param script from which to extract the variables
|
|
7
7
|
* @returns the list of variable names
|
|
8
|
-
* @throws {
|
|
8
|
+
* @throws {ParseError} if the script is invalid
|
|
9
9
|
* @public exported from `@promptbook/utils`
|
|
10
10
|
*/
|
|
11
11
|
export declare function extractVariables(script: string_javascript): Set<string_javascript_name>;
|
|
@@ -12,5 +12,5 @@ export declare function stringifyPipelineJson<TType>(pipeline: TType): string_js
|
|
|
12
12
|
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/samples/mixed-knowledge.ptbk.md
|
|
13
13
|
* TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
|
|
14
14
|
* TODO: [🧠] Maybe more elegant solution than replacing via regex
|
|
15
|
-
* TODO: [🍙] Make some
|
|
15
|
+
* TODO: [🍙] Make some standard order of json properties
|
|
16
16
|
*/
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @public exported from `@promptbook/core`
|
|
5
5
|
*/
|
|
6
|
-
export declare class
|
|
7
|
-
readonly name = "
|
|
6
|
+
export declare class ParseError extends Error {
|
|
7
|
+
readonly name = "ParseError";
|
|
8
8
|
constructor(message: string);
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* TODO: Maybe split `ParseError` and `ApplyError`
|
|
12
|
+
*/
|
|
@@ -4,7 +4,7 @@ import { ExpectError } from './ExpectError';
|
|
|
4
4
|
import { LimitReachedError } from './LimitReachedError';
|
|
5
5
|
import { NotFoundError } from './NotFoundError';
|
|
6
6
|
import { NotYetImplementedError } from './NotYetImplementedError';
|
|
7
|
-
import {
|
|
7
|
+
import { ParseError } from './ParseError';
|
|
8
8
|
import { PipelineExecutionError } from './PipelineExecutionError';
|
|
9
9
|
import { PipelineLogicError } from './PipelineLogicError';
|
|
10
10
|
import { PipelineUrlError } from './PipelineUrlError';
|
|
@@ -21,7 +21,7 @@ export declare const ERRORS: {
|
|
|
21
21
|
readonly LimitReachedError: typeof LimitReachedError;
|
|
22
22
|
readonly NotFoundError: typeof NotFoundError;
|
|
23
23
|
readonly NotYetImplementedError: typeof NotYetImplementedError;
|
|
24
|
-
readonly
|
|
24
|
+
readonly ParseError: typeof ParseError;
|
|
25
25
|
readonly PipelineExecutionError: typeof PipelineExecutionError;
|
|
26
26
|
readonly PipelineLogicError: typeof PipelineLogicError;
|
|
27
27
|
readonly PipelineUrlError: typeof PipelineUrlError;
|
|
@@ -39,6 +39,8 @@ export type EmbeddingPromptResult = Omit<CommonPromptResult, 'content'> & {
|
|
|
39
39
|
* Common properties for all prompt results
|
|
40
40
|
*
|
|
41
41
|
* Note: [🚉] This is fully serializable as JSON
|
|
42
|
+
*
|
|
43
|
+
* @private just abstract the common properties of the prompt results
|
|
42
44
|
*/
|
|
43
45
|
export type CommonPromptResult = {
|
|
44
46
|
/**
|
|
@@ -29,5 +29,5 @@ export type PromptResultUsage = {
|
|
|
29
29
|
*/
|
|
30
30
|
export type PromptResultUsageCounts = Record<`${KebabCase<'TOKENS' | ExpectationUnit>}Count`, UncertainNumber>;
|
|
31
31
|
/**
|
|
32
|
-
* TODO: [🍙] Make some
|
|
32
|
+
* TODO: [🍙] Make some standard order of json properties
|
|
33
33
|
*/
|
|
@@ -63,7 +63,7 @@ export {};
|
|
|
63
63
|
* TODO: [🧠][🌳] Use here `countTotalUsage` and put preparation and prepared pipiline to report
|
|
64
64
|
* TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
|
|
65
65
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
66
|
-
* TODO: [🧠] When not meet expectations in
|
|
66
|
+
* TODO: [🧠] When not meet expectations in DIALOG_TEMPLATE, make some way to tell the user
|
|
67
67
|
* TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
|
|
68
68
|
* Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
|
|
69
69
|
* TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
|
|
@@ -13,7 +13,7 @@ export declare class SimplePromptInterfaceTools implements UserInterfaceTools {
|
|
|
13
13
|
private readonly options;
|
|
14
14
|
constructor(options?: CommonExecutionToolsOptions);
|
|
15
15
|
/**
|
|
16
|
-
* Trigger window.
|
|
16
|
+
* Trigger window.DIALOG BLOCK
|
|
17
17
|
*/
|
|
18
18
|
promptDialog(options: UserInterfaceToolsPromptDialogOptions): Promise<string>;
|
|
19
19
|
}
|
|
@@ -39,7 +39,7 @@ export declare class OpenAiExecutionTools implements LlmExecutionTools {
|
|
|
39
39
|
/**
|
|
40
40
|
* Calls OpenAI API to use a chat model.
|
|
41
41
|
*/
|
|
42
|
-
callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | '
|
|
42
|
+
callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
|
|
43
43
|
/**
|
|
44
44
|
* Calls OpenAI API to use a complete model.
|
|
45
45
|
*/
|
|
@@ -2,7 +2,7 @@ import type { string_markdown } from '../../types/typeAliases';
|
|
|
2
2
|
/**
|
|
3
3
|
* Extracts code block from markdown.
|
|
4
4
|
*
|
|
5
|
-
* - When there are multiple or no code blocks the function throws a `
|
|
5
|
+
* - When there are multiple or no code blocks the function throws a `ParseError`
|
|
6
6
|
*
|
|
7
7
|
* Note: There are multiple simmilar function:
|
|
8
8
|
* - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
|
|
@@ -11,6 +11,6 @@ import type { string_markdown } from '../../types/typeAliases';
|
|
|
11
11
|
* - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
|
|
12
12
|
*
|
|
13
13
|
* @public exported from `@promptbook/markdown-utils`
|
|
14
|
-
* @throws {
|
|
14
|
+
* @throws {ParseError} if there is not exactly one code block in the markdown
|
|
15
15
|
*/
|
|
16
16
|
export declare function extractBlock(markdown: string_markdown): string;
|
|
@@ -5,8 +5,8 @@ import type { really_unknown } from '../../utils/organization/really_unknown';
|
|
|
5
5
|
* Extracts extracts exactly one valid JSON code block
|
|
6
6
|
*
|
|
7
7
|
* - When given string is a valid JSON as it is, it just returns it
|
|
8
|
-
* - When there is no JSON code block the function throws a `
|
|
9
|
-
* - When there are multiple JSON code blocks the function throws a `
|
|
8
|
+
* - When there is no JSON code block the function throws a `ParseError`
|
|
9
|
+
* - When there are multiple JSON code blocks the function throws a `ParseError`
|
|
10
10
|
*
|
|
11
11
|
* Note: It is not important if marked as ```json BUT if it is VALID JSON
|
|
12
12
|
* Note: There are multiple simmilar function:
|
|
@@ -16,7 +16,7 @@ import type { really_unknown } from '../../utils/organization/really_unknown';
|
|
|
16
16
|
* - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
|
|
17
17
|
*
|
|
18
18
|
* @public exported from `@promptbook/markdown-utils`
|
|
19
|
-
* @throws {
|
|
19
|
+
* @throws {ParseError} if there is no valid JSON block in the markdown
|
|
20
20
|
*/
|
|
21
21
|
export declare function extractJsonBlock(markdown: string_markdown): string_json<really_unknown>;
|
|
22
22
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TemplateJson } from '../types/PipelineJson/TemplateJson';
|
|
3
3
|
import type { PrepareOptions } from './PrepareOptions';
|
|
4
|
-
type PrepareTemplateInput = Pick<PipelineJson, '
|
|
4
|
+
type PrepareTemplateInput = Pick<PipelineJson, 'templates' | 'parameters'> & {
|
|
5
5
|
/**
|
|
6
6
|
* @@@
|
|
7
7
|
*/
|
|
@@ -11,7 +11,7 @@ type PreparedTemplates = {
|
|
|
11
11
|
/**
|
|
12
12
|
* @@@ Sequence of prompt templates that are chained together to form a pipeline
|
|
13
13
|
*/
|
|
14
|
-
readonly
|
|
14
|
+
readonly templatesPrepared: Array<TemplateJson>;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* @@@
|
|
@@ -28,5 +28,4 @@ export {};
|
|
|
28
28
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
29
29
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
30
30
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
31
|
-
* TODO: [🧠][🥜]
|
|
32
31
|
*/
|
|
@@ -8,5 +8,5 @@ export declare function unpreparePipeline(pipeline: PipelineJson): PipelineJson;
|
|
|
8
8
|
/**
|
|
9
9
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
10
10
|
* TODO: Write tests for `preparePipeline`
|
|
11
|
-
* TODO: [🍙] Make some
|
|
11
|
+
* TODO: [🍙] Make some standard order of json properties
|
|
12
12
|
*/
|