@promptbook/markdown-utils 0.75.0-2 → 0.75.0-4
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 +27 -17
- package/esm/index.es.js +46 -45
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +10 -4
- package/esm/typings/src/_packages/types.index.d.ts +8 -6
- package/esm/typings/src/commands/EXPECT/ExpectCommand.d.ts +1 -1
- package/esm/typings/src/commands/SECTION/SectionCommand.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +0 -2
- package/esm/typings/src/config.d.ts +9 -2
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +2 -2
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.d.ts +3 -3
- package/esm/typings/src/conversion/utils/renameParameter.d.ts +2 -2
- package/esm/typings/src/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
- package/esm/typings/src/execution/ScriptExecutionTools.d.ts +1 -1
- package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +2 -2
- package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +3 -0
- package/esm/typings/src/formfactors/chatbot/ChatbotFormfactorDefinition.d.ts +32 -2
- package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +2 -2
- package/esm/typings/src/formfactors/index.d.ts +72 -10
- package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +2 -2
- package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +12 -2
- package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +12 -2
- package/esm/typings/src/pipeline/PipelineInterface/PipelineInterface.d.ts +5 -4
- package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/{TaskJsonCommon.d.ts → CommonTaskJson.d.ts} +13 -13
- package/esm/typings/src/pipeline/PipelineJson/DialogTaskJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/ParameterJson.d.ts +2 -0
- package/esm/typings/src/pipeline/PipelineJson/PersonaJson.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/PromptTaskJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/ScriptTaskJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/SimpleTaskJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/TaskJson.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineString.d.ts +1 -1
- package/esm/typings/src/prepare/isPipelinePrepared.d.ts +1 -1
- package/esm/typings/src/prepare/prepareTasks.d.ts +5 -5
- package/esm/typings/src/types/Prompt.d.ts +3 -3
- package/esm/typings/src/types/SectionType.d.ts +21 -0
- package/esm/typings/src/types/TaskProgress.d.ts +1 -1
- package/esm/typings/src/types/TaskType.d.ts +15 -0
- package/esm/typings/src/types/typeAliases.d.ts +1 -1
- package/esm/typings/src/utils/organization/TODO_remove_as.d.ts +6 -0
- package/esm/typings/src/utils/parameters/extractParameterNames.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +46 -45
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/commands/SECTION/SectionType.d.ts +0 -13
- /package/esm/typings/{promptbook-collection → books}/index.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ForeachJson } from '../../commands/FOREACH/ForeachJson';
|
|
2
2
|
import type { FormatCommand } from '../../commands/FORMAT/FormatCommand';
|
|
3
|
-
import type { SectionType } from '../../
|
|
3
|
+
import type { SectionType } from '../../types/SectionType';
|
|
4
4
|
import type { string_javascript } from '../../types/typeAliases';
|
|
5
5
|
import type { string_markdown } from '../../types/typeAliases';
|
|
6
6
|
import type { string_markdown_text } from '../../types/typeAliases';
|
|
@@ -13,32 +13,32 @@ import type { Expectations } from './Expectations';
|
|
|
13
13
|
/**
|
|
14
14
|
* Common properties of all tasks
|
|
15
15
|
*/
|
|
16
|
-
export type
|
|
16
|
+
export type CommonTaskJson = {
|
|
17
17
|
/**
|
|
18
|
-
* Name of the
|
|
18
|
+
* Name of the task
|
|
19
19
|
* - It must be unique across the pipeline
|
|
20
20
|
* - It should start uppercase and can contain letters and numbers
|
|
21
|
-
* - The pipelineUrl together with hash and name are used to identify the
|
|
21
|
+
* - The pipelineUrl together with hash and name are used to identify the task in the pipeline
|
|
22
22
|
*/
|
|
23
23
|
readonly name: string_name;
|
|
24
24
|
/**
|
|
25
|
-
* Title of the
|
|
25
|
+
* Title of the task
|
|
26
26
|
* It can use simple markdown formatting like **bold**, *italic*, [link](https://example.com), ... BUT not code blocks and structure
|
|
27
27
|
*/
|
|
28
28
|
readonly title: string;
|
|
29
29
|
/**
|
|
30
|
-
* Description of the
|
|
30
|
+
* Description of the task
|
|
31
31
|
* It can use multiple paragraphs of simple markdown formatting like **bold**, *italic*, [link](https://example.com), ... BUT not code blocks and structure
|
|
32
32
|
*/
|
|
33
33
|
readonly description?: string_markdown_text;
|
|
34
34
|
/**
|
|
35
|
-
* List of parameter names that are used in the
|
|
35
|
+
* List of parameter names that are used in the task and must be defined before the task is executed
|
|
36
36
|
*
|
|
37
37
|
* Note: Joker is one of the dependent parameters
|
|
38
38
|
*/
|
|
39
39
|
readonly dependentParameterNames: Array<string_parameter_name>;
|
|
40
40
|
/**
|
|
41
|
-
* If theese parameters meet the expectations requirements, they are used instead of executing this
|
|
41
|
+
* If theese parameters meet the expectations requirements, they are used instead of executing this task
|
|
42
42
|
*
|
|
43
43
|
* @see https://github.com/webgptorg/promptbook/discussions/66
|
|
44
44
|
*/
|
|
@@ -49,17 +49,17 @@ export type TaskJsonCommon = {
|
|
|
49
49
|
readonly foreach?: ForeachJson;
|
|
50
50
|
/**
|
|
51
51
|
* Type of the execution
|
|
52
|
-
* This determines if the
|
|
52
|
+
* This determines if the task is send to LLM, user or some scripting evaluation
|
|
53
53
|
*/
|
|
54
54
|
readonly taskType: SectionType;
|
|
55
55
|
/**
|
|
56
|
-
* Content of the
|
|
56
|
+
* Content of the task with {placeholders} for parameters
|
|
57
57
|
*
|
|
58
58
|
* @@@ content vs preparedContent
|
|
59
59
|
*/
|
|
60
60
|
readonly content: (string_prompt | string_javascript | string_markdown) & string_template;
|
|
61
61
|
/**
|
|
62
|
-
* @@@ Content of the
|
|
62
|
+
* @@@ Content of the task with {placeholders} for parameters
|
|
63
63
|
*
|
|
64
64
|
* @@@ content vs preparedContent
|
|
65
65
|
*
|
|
@@ -67,7 +67,7 @@ export type TaskJsonCommon = {
|
|
|
67
67
|
*/
|
|
68
68
|
readonly preparedContent?: (string_prompt | string_javascript | string_markdown) & string_template;
|
|
69
69
|
/**
|
|
70
|
-
* List of postprocessing steps that are executed after the
|
|
70
|
+
* List of postprocessing steps that are executed after the task
|
|
71
71
|
*
|
|
72
72
|
* @see https://github.com/webgptorg/promptbook/discussions/31
|
|
73
73
|
*/
|
|
@@ -90,7 +90,7 @@ export type TaskJsonCommon = {
|
|
|
90
90
|
*/
|
|
91
91
|
readonly format?: FormatCommand['format'];
|
|
92
92
|
/**
|
|
93
|
-
* Name of the parameter that is the result of the
|
|
93
|
+
* Name of the parameter that is the result of the task
|
|
94
94
|
*/
|
|
95
95
|
readonly resultingParameterName: string_name;
|
|
96
96
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CommonTaskJson } from './CommonTaskJson';
|
|
2
2
|
/**
|
|
3
3
|
* Task for prompt to user
|
|
4
4
|
*
|
|
5
5
|
* Note: [🚉] This is fully serializable as JSON
|
|
6
6
|
* @see https://github.com/webgptorg/promptbook/discussions/76
|
|
7
7
|
*/
|
|
8
|
-
export type DialogTaskJson =
|
|
8
|
+
export type DialogTaskJson = CommonTaskJson & {
|
|
9
9
|
readonly taskType: 'DIALOG_TASK';
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
@@ -90,6 +90,8 @@ export type CommonParameterJson = {
|
|
|
90
90
|
readonly exampleValues?: Array<string_parameter_value>;
|
|
91
91
|
};
|
|
92
92
|
/**
|
|
93
|
+
* TODO: [🧠][🛴][♈] Maybe add type + expectations into the intefrace, like "a person name"
|
|
94
|
+
* [🛴] @see https://github.com/webgptorg/promptbook/discussions/53
|
|
93
95
|
* TODO: [🧠] Should be here registered subparameters from foreach or not?
|
|
94
96
|
* TODO: [♈] Probbably move expectations from tasks to parameters
|
|
95
97
|
* TODO: [🍙] Make some standard order of json properties
|
|
@@ -11,7 +11,7 @@ import type { string_persona_description } from '../../types/typeAliases';
|
|
|
11
11
|
*/
|
|
12
12
|
export type PersonaJson = {
|
|
13
13
|
/**
|
|
14
|
-
* Name of the
|
|
14
|
+
* Name of the persona
|
|
15
15
|
* - It must be unique across the pipeline
|
|
16
16
|
* - It should start uppercase and can contain letters and numbers
|
|
17
17
|
*/
|
|
@@ -14,7 +14,7 @@ import type { PreparationJson } from './PreparationJson';
|
|
|
14
14
|
import type { TaskJson } from './TaskJson';
|
|
15
15
|
/**
|
|
16
16
|
* Promptbook is the **core concept of this package**.
|
|
17
|
-
* It represents a series of tasks chained together to form a pipeline / one big
|
|
17
|
+
* It represents a series of tasks chained together to form a pipeline / one big task with input and result parameters.
|
|
18
18
|
*
|
|
19
19
|
* Note: [🚉] This is fully serializable as JSON
|
|
20
20
|
*
|
|
@@ -28,7 +28,7 @@ export type PipelineJson = {
|
|
|
28
28
|
* Note: It must use HTTPs URL
|
|
29
29
|
* Tip: You can do versioning in the URL
|
|
30
30
|
* For example: https://promptbook.studio/webgpt/write-website-content-cs.book.md@1.0.0
|
|
31
|
-
* Warning: Do not hash part of the URL, hash part is used for identification of the
|
|
31
|
+
* Warning: Do not hash part of the URL, hash part is used for identification of the task in the pipeline
|
|
32
32
|
*/
|
|
33
33
|
readonly pipelineUrl?: string_pipeline_url;
|
|
34
34
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ModelRequirements } from '../../types/ModelRequirements';
|
|
2
2
|
import type { string_name } from '../../types/typeAliases';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CommonTaskJson } from './CommonTaskJson';
|
|
4
4
|
/**
|
|
5
5
|
* Task for prompt to LLM
|
|
6
6
|
*
|
|
7
7
|
* Note: [🚉] This is fully serializable as JSON
|
|
8
8
|
*/
|
|
9
|
-
export type PromptTaskJson =
|
|
9
|
+
export type PromptTaskJson = CommonTaskJson & {
|
|
10
10
|
readonly taskType: 'PROMPT_TASK';
|
|
11
11
|
/**
|
|
12
12
|
* Name of the persona who will be responding to this prompt
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ScriptLanguage } from '../../types/ScriptLanguage';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CommonTaskJson } from './CommonTaskJson';
|
|
3
3
|
/**
|
|
4
4
|
* Task for script execution
|
|
5
5
|
*
|
|
6
6
|
* Note: [🚉] This is fully serializable as JSON
|
|
7
7
|
* @see https://github.com/webgptorg/promptbook/discussions/77
|
|
8
8
|
*/
|
|
9
|
-
export type ScriptTaskJson =
|
|
9
|
+
export type ScriptTaskJson = CommonTaskJson & {
|
|
10
10
|
readonly taskType: 'SCRIPT_TASK';
|
|
11
11
|
/**
|
|
12
12
|
* Language of the script
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CommonTaskJson } from './CommonTaskJson';
|
|
2
2
|
/**
|
|
3
3
|
* Task for simple concatenation of strings
|
|
4
4
|
*
|
|
5
5
|
* Note: [🚉] This is fully serializable as JSON
|
|
6
6
|
* @see https://github.com/webgptorg/promptbook/discussions/17
|
|
7
7
|
*/
|
|
8
|
-
export type SimpleTaskJson =
|
|
8
|
+
export type SimpleTaskJson = CommonTaskJson & {
|
|
9
9
|
readonly taskType: 'SIMPLE_TASK';
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
@@ -4,7 +4,7 @@ import type { PromptTaskJson } from './PromptTaskJson';
|
|
|
4
4
|
import type { ScriptTaskJson } from './ScriptTaskJson';
|
|
5
5
|
import type { SimpleTaskJson } from './SimpleTaskJson';
|
|
6
6
|
/**
|
|
7
|
-
* Describes one (prompt)
|
|
7
|
+
* Describes one (prompt) task in the pipeline
|
|
8
8
|
*
|
|
9
9
|
* Note: [🚉] This is fully serializable as JSON
|
|
10
10
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Promptbook is the **core concept of this package**.
|
|
3
|
-
* It represents a series of tasks chained together to form a pipeline / one big
|
|
3
|
+
* It represents a series of tasks chained together to form a pipeline / one big task with input and result parameters.
|
|
4
4
|
*
|
|
5
5
|
* @see @@@ https://github.com/webgptorg/promptbook#promptbook
|
|
6
6
|
*/
|
|
@@ -10,7 +10,7 @@ export declare function isPipelinePrepared(pipeline: PipelineJson): boolean;
|
|
|
10
10
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
11
11
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
12
12
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
13
|
-
* - [🏍] ? Is context in each
|
|
13
|
+
* - [🏍] ? Is context in each task
|
|
14
14
|
* - [♨] Are examples prepared
|
|
15
15
|
* - [♨] Are tasks prepared
|
|
16
16
|
*/
|
|
@@ -2,13 +2,13 @@ import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
|
2
2
|
import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
|
|
3
3
|
import type { TaskJson } from '../pipeline/PipelineJson/TaskJson';
|
|
4
4
|
import type { PrepareAndScrapeOptions } from './PrepareAndScrapeOptions';
|
|
5
|
-
type
|
|
5
|
+
type PrepareTaskInput = Pick<PipelineJson, 'tasks' | 'parameters'> & {
|
|
6
6
|
/**
|
|
7
7
|
* @@@
|
|
8
8
|
*/
|
|
9
9
|
readonly knowledgePiecesCount: number;
|
|
10
10
|
};
|
|
11
|
-
type
|
|
11
|
+
type PreparedTasks = {
|
|
12
12
|
/**
|
|
13
13
|
* @@@ Sequence of tasks that are chained together to form a pipeline
|
|
14
14
|
*/
|
|
@@ -19,11 +19,11 @@ type PreparedTemplates = {
|
|
|
19
19
|
*
|
|
20
20
|
* @public exported from `@promptbook/core`
|
|
21
21
|
*/
|
|
22
|
-
export declare function prepareTasks(pipeline:
|
|
22
|
+
export declare function prepareTasks(pipeline: PrepareTaskInput, tools: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options: PrepareAndScrapeOptions): Promise<PreparedTasks>;
|
|
23
23
|
export {};
|
|
24
24
|
/**
|
|
25
|
-
* TODO: [🧠] Add context to each
|
|
26
|
-
* TODO: [🧠] What is better name `
|
|
25
|
+
* TODO: [🧠] Add context to each task (if missing)
|
|
26
|
+
* TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
|
|
27
27
|
* TODO: [♨][main] !!! Prepare index the examples and maybe tasks
|
|
28
28
|
* TODO: Write tests for `preparePipeline`
|
|
29
29
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
@@ -5,7 +5,7 @@ import type { CompletionModelRequirements } from './ModelRequirements';
|
|
|
5
5
|
import type { EmbeddingModelRequirements } from './ModelRequirements';
|
|
6
6
|
import type { ModelRequirements } from './ModelRequirements';
|
|
7
7
|
import type { Parameters } from './typeAliases';
|
|
8
|
-
import type {
|
|
8
|
+
import type { string_pipeline_url_with_task_hash } from './typeAliases';
|
|
9
9
|
import type { string_postprocessing_function_name } from './typeAliases';
|
|
10
10
|
import type { string_prompt } from './typeAliases';
|
|
11
11
|
import type { string_template } from './typeAliases';
|
|
@@ -93,11 +93,11 @@ export type CommonPrompt = {
|
|
|
93
93
|
*/
|
|
94
94
|
readonly format?: FormatCommand['format'];
|
|
95
95
|
/**
|
|
96
|
-
* Unique identifier of the pipeline with specific
|
|
96
|
+
* Unique identifier of the pipeline with specific task name as hash
|
|
97
97
|
*
|
|
98
98
|
* @example https://promptbook.studio/webgpt/write-website-content-cs.book.md#keywords
|
|
99
99
|
*/
|
|
100
|
-
readonly pipelineUrl?:
|
|
100
|
+
readonly pipelineUrl?: string_pipeline_url_with_task_hash;
|
|
101
101
|
/**
|
|
102
102
|
* Parameters used in the `content`
|
|
103
103
|
*/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TupleToUnion } from 'type-fest';
|
|
2
|
+
/**
|
|
3
|
+
* Type of the section
|
|
4
|
+
*/
|
|
5
|
+
export type SectionType = TupleToUnion<typeof SectionTypes>;
|
|
6
|
+
/**
|
|
7
|
+
* All available sections which are not tasks
|
|
8
|
+
*
|
|
9
|
+
* @public exported from `@promptbook/core`
|
|
10
|
+
*/
|
|
11
|
+
export declare const NonTaskSectionTypes: readonly ["EXAMPLE", "KNOWLEDGE", "INSTRUMENT", "ACTION"];
|
|
12
|
+
/**
|
|
13
|
+
* All available section types
|
|
14
|
+
*
|
|
15
|
+
* There is is distinction between task types and section types
|
|
16
|
+
* - Every section in markdown has its SectionType
|
|
17
|
+
* - Some sections are tasks but other can be non-task sections
|
|
18
|
+
*
|
|
19
|
+
* @public exported from `@promptbook/core`
|
|
20
|
+
*/
|
|
21
|
+
export declare const SectionTypes: readonly [...("PROMPT_TASK" | "SIMPLE_TASK" | "SCRIPT_TASK" | "DIALOG_TASK")[], "EXAMPLE", "KNOWLEDGE", "INSTRUMENT", "ACTION"];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TupleToUnion } from 'type-fest';
|
|
2
|
+
/**
|
|
3
|
+
* Type of the task
|
|
4
|
+
*/
|
|
5
|
+
export type TaskType = TupleToUnion<typeof TaskTypes>;
|
|
6
|
+
/**
|
|
7
|
+
* All available task types
|
|
8
|
+
*
|
|
9
|
+
* There is is distinction between task types and section types
|
|
10
|
+
* - Every section in markdown has its SectionType
|
|
11
|
+
* - Some sections are tasks but other can be non-task sections
|
|
12
|
+
*
|
|
13
|
+
* @public exported from `@promptbook/core`
|
|
14
|
+
*/
|
|
15
|
+
export declare const TaskTypes: readonly ["PROMPT", "SIMPLE", "SCRIPT", "DIALOG"];
|
|
@@ -306,7 +306,7 @@ export type string_pipeline_url = string;
|
|
|
306
306
|
*
|
|
307
307
|
* For example `"https://promptbook.studio/webgpt/write-website-content-cs.book.md#keywords"`
|
|
308
308
|
*/
|
|
309
|
-
export type
|
|
309
|
+
export type string_pipeline_url_with_task_hash = string;
|
|
310
310
|
/**
|
|
311
311
|
* Semantic helper
|
|
312
312
|
*
|
|
@@ -3,7 +3,7 @@ import type { string_template } from '../../types/typeAliases';
|
|
|
3
3
|
/**
|
|
4
4
|
* Parses the task and returns the list of all parameter names
|
|
5
5
|
*
|
|
6
|
-
* @param template the
|
|
6
|
+
* @param template the string template with parameters in {curly} braces
|
|
7
7
|
* @returns the list of parameter names
|
|
8
8
|
* @public exported from `@promptbook/utils`
|
|
9
9
|
*/
|
package/package.json
CHANGED