@promptbook/markdown-utils 0.79.0 → 0.80.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.
Files changed (40) hide show
  1. package/README.md +4 -0
  2. package/esm/index.es.js +401 -324
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/books/index.d.ts +6 -6
  5. package/esm/typings/src/_packages/core.index.d.ts +8 -6
  6. package/esm/typings/src/_packages/types.index.d.ts +6 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  8. package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +32 -0
  9. package/esm/typings/src/commands/_common/getParserForCommand.d.ts +1 -1
  10. package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
  11. package/esm/typings/src/commands/_common/stringifyCommand.d.ts +1 -1
  12. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +3 -0
  13. package/esm/typings/src/config.d.ts +0 -25
  14. package/esm/typings/src/constants.d.ts +35 -0
  15. package/esm/typings/src/conversion/{pipelineStringToJson.d.ts → compilePipeline.d.ts} +3 -3
  16. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
  17. package/esm/typings/src/conversion/{pipelineStringToJsonSync.d.ts → precompilePipeline.d.ts} +4 -3
  18. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +20 -0
  19. package/esm/typings/src/high-level-abstractions/implicit-formfactor/ImplicitFormfactorHla.d.ts +10 -0
  20. package/esm/typings/src/high-level-abstractions/index.d.ts +44 -0
  21. package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +10 -0
  22. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
  23. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  24. package/esm/typings/src/prepare/prepareTasks.d.ts +1 -0
  25. package/esm/typings/src/prepare/unpreparePipeline.d.ts +1 -0
  26. package/esm/typings/src/types/typeAliases.d.ts +1 -1
  27. package/esm/typings/src/utils/normalization/orderJson.d.ts +21 -0
  28. package/esm/typings/src/utils/normalization/orderJson.test.d.ts +4 -0
  29. package/esm/typings/src/utils/organization/keepTypeImported.d.ts +9 -0
  30. package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
  31. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +20 -2
  32. package/esm/typings/src/utils/serialization/deepClone.test.d.ts +1 -0
  33. package/esm/typings/src/utils/serialization/exportJson.d.ts +29 -0
  34. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +2 -1
  35. package/package.json +1 -1
  36. package/umd/index.umd.js +401 -324
  37. package/umd/index.umd.js.map +1 -1
  38. package/esm/typings/src/utils/serialization/$asDeeplyFrozenSerializableJson.d.ts +0 -17
  39. /package/esm/typings/src/conversion/{pipelineStringToJson.test.d.ts → compilePipeline.test.d.ts} +0 -0
  40. /package/esm/typings/src/conversion/{pipelineStringToJsonSync.test.d.ts → precompilePipeline.test.d.ts} +0 -0
@@ -16,10 +16,10 @@ declare const _default: ({
16
16
  resultingParameterName: string;
17
17
  dependentParameterNames: string[];
18
18
  }[];
19
- knowledgeSources: never[];
20
- knowledgePieces: never[];
21
19
  personas: never[];
22
20
  preparations: never[];
21
+ knowledgeSources: never[];
22
+ knowledgePieces: never[];
23
23
  sourceFile: string;
24
24
  } | {
25
25
  title: string;
@@ -45,10 +45,10 @@ declare const _default: ({
45
45
  };
46
46
  dependentParameterNames: string[];
47
47
  }[];
48
- knowledgeSources: never[];
49
- knowledgePieces: never[];
50
48
  personas: never[];
51
49
  preparations: never[];
50
+ knowledgeSources: never[];
51
+ knowledgePieces: never[];
52
52
  sourceFile: string;
53
53
  } | {
54
54
  title: string;
@@ -69,10 +69,10 @@ declare const _default: ({
69
69
  format: string;
70
70
  dependentParameterNames: string[];
71
71
  }[];
72
- knowledgeSources: never[];
73
- knowledgePieces: never[];
74
72
  personas: never[];
75
73
  preparations: never[];
74
+ knowledgeSources: never[];
75
+ knowledgePieces: never[];
76
76
  sourceFile: string;
77
77
  })[];
78
78
  export default _default;
@@ -21,16 +21,17 @@ import { DEFAULT_BOOKS_DIRNAME } from '../config';
21
21
  import { DEFAULT_EXECUTIONS_CACHE_DIRNAME } from '../config';
22
22
  import { DEFAULT_SCRAPE_CACHE_DIRNAME } from '../config';
23
23
  import { DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME } from '../config';
24
- import { RESERVED_PARAMETER_NAMES } from '../config';
25
24
  import { DEFAULT_REMOTE_URL } from '../config';
26
25
  import { DEFAULT_REMOTE_URL_PATH } from '../config';
27
26
  import { DEFAULT_CSV_SETTINGS } from '../config';
28
27
  import { DEFAULT_IS_VERBOSE } from '../config';
29
28
  import { SET_IS_VERBOSE } from '../config';
30
29
  import { DEFAULT_IS_AUTO_INSTALLED } from '../config';
30
+ import { ORDER_OF_PIPELINE_JSON } from '../constants';
31
+ import { RESERVED_PARAMETER_NAMES } from '../constants';
32
+ import { compilePipeline } from '../conversion/compilePipeline';
31
33
  import { pipelineJsonToString } from '../conversion/pipelineJsonToString';
32
- import { pipelineStringToJson } from '../conversion/pipelineStringToJson';
33
- import { pipelineStringToJsonSync } from '../conversion/pipelineStringToJsonSync';
34
+ import { precompilePipeline } from '../conversion/precompilePipeline';
34
35
  import { prettifyPipelineString } from '../conversion/prettify/prettifyPipelineString';
35
36
  import { extractParameterNamesFromTask } from '../conversion/utils/extractParameterNamesFromTask';
36
37
  import { removePipelineCommand } from '../conversion/utils/removePipelineCommand';
@@ -141,16 +142,17 @@ export { DEFAULT_BOOKS_DIRNAME };
141
142
  export { DEFAULT_EXECUTIONS_CACHE_DIRNAME };
142
143
  export { DEFAULT_SCRAPE_CACHE_DIRNAME };
143
144
  export { DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME };
144
- export { RESERVED_PARAMETER_NAMES };
145
145
  export { DEFAULT_REMOTE_URL };
146
146
  export { DEFAULT_REMOTE_URL_PATH };
147
147
  export { DEFAULT_CSV_SETTINGS };
148
148
  export { DEFAULT_IS_VERBOSE };
149
149
  export { SET_IS_VERBOSE };
150
150
  export { DEFAULT_IS_AUTO_INSTALLED };
151
+ export { ORDER_OF_PIPELINE_JSON };
152
+ export { RESERVED_PARAMETER_NAMES };
153
+ export { compilePipeline };
151
154
  export { pipelineJsonToString };
152
- export { pipelineStringToJson };
153
- export { pipelineStringToJsonSync };
155
+ export { precompilePipeline };
154
156
  export { prettifyPipelineString };
155
157
  export { extractParameterNamesFromTask };
156
158
  export { removePipelineCommand };
@@ -253,9 +253,12 @@ import type { string_camelCase } from '../utils/normalization/normalizeTo_camelC
253
253
  import type { string_PascalCase } from '../utils/normalization/normalizeTo_PascalCase';
254
254
  import type { string_SCREAMING_CASE } from '../utils/normalization/normalizeTo_SCREAMING_CASE';
255
255
  import type { string_snake_case } from '../utils/normalization/normalizeTo_snake_case';
256
+ import type { OrderJsonOptions } from '../utils/normalization/orderJson';
256
257
  import type { empty_object } from '../utils/organization/empty_object';
257
258
  import type { really_any } from '../utils/organization/really_any';
258
259
  import type { TODO_any } from '../utils/organization/TODO_any';
260
+ import type { CheckSerializableAsJsonOptions } from '../utils/serialization/checkSerializableAsJson';
261
+ import type { ExportJsonOptions } from '../utils/serialization/exportJson';
259
262
  import type { string_promptbook_version } from '../version';
260
263
  export type { PipelineCollection };
261
264
  export type { Command };
@@ -512,7 +515,10 @@ export type { string_camelCase };
512
515
  export type { string_PascalCase };
513
516
  export type { string_SCREAMING_CASE };
514
517
  export type { string_snake_case };
518
+ export type { OrderJsonOptions };
515
519
  export type { empty_object };
516
520
  export type { really_any };
517
521
  export type { TODO_any };
522
+ export type { CheckSerializableAsJsonOptions };
523
+ export type { ExportJsonOptions };
518
524
  export type { string_promptbook_version };
@@ -38,6 +38,7 @@ import type { string_SCREAMING_CASE } from '../utils/normalization/normalizeTo_S
38
38
  import { normalizeTo_SCREAMING_CASE } from '../utils/normalization/normalizeTo_SCREAMING_CASE';
39
39
  import { normalizeTo_snake_case } from '../utils/normalization/normalizeTo_snake_case';
40
40
  import { normalizeWhitespaces } from '../utils/normalization/normalizeWhitespaces';
41
+ import { orderJson } from '../utils/normalization/orderJson';
41
42
  import { parseKeywords } from '../utils/normalization/parseKeywords';
42
43
  import { parseKeywordsFromString } from '../utils/normalization/parseKeywordsFromString';
43
44
  import { removeDiacritics } from '../utils/normalization/removeDiacritics';
@@ -54,6 +55,7 @@ import { $deepFreeze } from '../utils/serialization/$deepFreeze';
54
55
  import { checkSerializableAsJson } from '../utils/serialization/checkSerializableAsJson';
55
56
  import { clonePipeline } from '../utils/serialization/clonePipeline';
56
57
  import { deepClone } from '../utils/serialization/deepClone';
58
+ import { exportJson } from '../utils/serialization/exportJson';
57
59
  import { isSerializableAsJson } from '../utils/serialization/isSerializableAsJson';
58
60
  import { difference } from '../utils/sets/difference';
59
61
  import { intersection } from '../utils/sets/intersection';
@@ -111,6 +113,7 @@ export type { string_SCREAMING_CASE };
111
113
  export { normalizeTo_SCREAMING_CASE };
112
114
  export { normalizeTo_snake_case };
113
115
  export { normalizeWhitespaces };
116
+ export { orderJson };
114
117
  export { parseKeywords };
115
118
  export { parseKeywordsFromString };
116
119
  export { removeDiacritics };
@@ -127,6 +130,7 @@ export { $deepFreeze };
127
130
  export { checkSerializableAsJson };
128
131
  export { clonePipeline };
129
132
  export { deepClone };
133
+ export { exportJson };
130
134
  export { isSerializableAsJson };
131
135
  export { difference };
132
136
  export { intersection };
@@ -0,0 +1,32 @@
1
+ import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
2
+ import type { PipelineExecutor } from '../../execution/PipelineExecutor';
3
+ /**
4
+ * Options for running the interactive chatbot
5
+ */
6
+ type RunInteractiveChatbotOptions = {
7
+ /**
8
+ * Prepared pipeline to run
9
+ */
10
+ pipeline: PipelineJson;
11
+ /**
12
+ * Prepared pipeline executor
13
+ */
14
+ pipelineExecutor: PipelineExecutor;
15
+ /**
16
+ * Whether to show verbose output
17
+ */
18
+ isVerbose: boolean;
19
+ };
20
+ /**
21
+ * Run the interactive chatbot in CLI
22
+ *
23
+ * @returns Never-ending promise or process exit
24
+ * @private internal function of `promptbookCli` and `initializeRunCommand`
25
+ */
26
+ export declare function runInteractiveChatbot(options: RunInteractiveChatbotOptions): Promise<void | never>;
27
+ export {};
28
+ /**
29
+ * TODO: Saving reports from the chatbot conversation
30
+ * TODO: [⛲️] This is the right place to start implementing INK
31
+ * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
32
+ */
@@ -6,6 +6,6 @@ import type { CommandParser } from './types/CommandParser';
6
6
  * @returns the parser for the command
7
7
  * @throws {UnexpectedError} if the parser is not found
8
8
  *
9
- * @private within the pipelineStringToJson
9
+ * @private within the compilePipeline
10
10
  */
11
11
  export declare function getParserForCommand<TCommand extends Command>(command: TCommand): CommandParser<TCommand>;
@@ -7,6 +7,6 @@ import type { CommandUsagePlace } from './types/CommandUsagePlaces';
7
7
  * @returns parsed command object
8
8
  * @throws {ParseError} if the command is invalid
9
9
  *
10
- * @private within the pipelineStringToJson
10
+ * @private within the compilePipeline
11
11
  */
12
12
  export declare function parseCommand(raw: string_markdown_text, usagePlace: CommandUsagePlace): Command;
@@ -6,6 +6,6 @@ import type { Command } from './types/Command';
6
6
  * @returns stringified command
7
7
  * @throws {UnexpectedError} if the command is invalid
8
8
  *
9
- * @private within the pipelineStringToJson
9
+ * @private within the compilePipeline
10
10
  */
11
11
  export declare function stringifyCommand(command: Command): string_markdown_text;
@@ -65,6 +65,7 @@ export type CommonCommandParser<TCommand extends CommandBase> = {
65
65
  * Converts the command back to string
66
66
  *
67
67
  * Note: This is used in `pipelineJsonToString` utility
68
+ * @deprecated TODO: [🥍][🧠] Backup original files in `PipelineJson` same as in Promptbook.studio
68
69
  */
69
70
  stringify(command: TCommand): string_markdown_text;
70
71
  };
@@ -94,6 +95,7 @@ export type PipelineHeadCommandParser<TCommand extends CommandBase> = CommonComm
94
95
  * Reads the command from the `PipelineJson`
95
96
  *
96
97
  * Note: This is used in `pipelineJsonToString` utility
98
+ * @deprecated TODO: [🥍][🧠] Backup original files in `PipelineJson` same as in Promptbook.studio
97
99
  */
98
100
  takeFromPipelineJson(pipelineJson: PipelineJson): ReadonlyArray<TCommand>;
99
101
  };
@@ -183,4 +185,5 @@ export type CommandParserInput = {
183
185
  };
184
186
  /**
185
187
  * TODO: [♓️] Add order here
188
+ * TODO: [🧠][🍱] Maybe make some common abstraction between `HighLevelAbstraction` and `CommandParser`
186
189
  */
@@ -162,30 +162,6 @@ export declare const DEFAULT_SCRAPE_CACHE_DIRNAME = "./.promptbook/scrape-cache"
162
162
  * @public exported from `@promptbook/core`
163
163
  */
164
164
  export declare const DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = "index";
165
- /**
166
- * Nonce which is used for replacing things in strings
167
- *
168
- * @private within the repository
169
- */
170
- export declare const REPLACING_NONCE = "u$k42k%!V2zo34w7Fu#@QUHYPW";
171
- /**
172
- * The names of the parameters that are reserved for special purposes
173
- *
174
- * @public exported from `@promptbook/core`
175
- */
176
- export declare const RESERVED_PARAMETER_NAMES: readonly ["content", "context", "knowledge", "examples", "modelName", "currentDate"];
177
- /**
178
- * @@@
179
- *
180
- * @private within the repository
181
- */
182
- export declare const RESERVED_PARAMETER_MISSING_VALUE: string;
183
- /**
184
- * @@@
185
- *
186
- * @private within the repository
187
- */
188
- export declare const RESERVED_PARAMETER_RESTRICTED: string;
189
165
  /**
190
166
  * The thresholds for the relative time in the `moment` NPM package.
191
167
  *
@@ -246,7 +222,6 @@ export declare const IS_PIPELINE_LOGIC_VALIDATED: boolean;
246
222
  */
247
223
  export declare const IS_COST_PREVENTED: boolean;
248
224
  /**
249
- * TODO: Extract `constants.ts` from `config.ts`
250
225
  * Note: [💞] Ignore a discrepancy between file name and entity name
251
226
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
252
227
  */
@@ -0,0 +1,35 @@
1
+ import type { PipelineJson } from './pipeline/PipelineJson/PipelineJson';
2
+ import type { ExportJsonOptions } from './utils/serialization/exportJson';
3
+ /**
4
+ * Order of keys in the pipeline JSON
5
+ *
6
+ * @public exported from `@promptbook/core`
7
+ */
8
+ export declare const ORDER_OF_PIPELINE_JSON: ExportJsonOptions<PipelineJson>['order'];
9
+ /**
10
+ * Nonce which is used for replacing things in strings
11
+ *
12
+ * @private within the repository
13
+ */
14
+ export declare const REPLACING_NONCE = "u$k42k%!V2zo34w7Fu#@QUHYPW";
15
+ /**
16
+ * @@@
17
+ *
18
+ * @private within the repository
19
+ */
20
+ export declare const RESERVED_PARAMETER_MISSING_VALUE: string;
21
+ /**
22
+ * @@@
23
+ *
24
+ * @private within the repository
25
+ */
26
+ export declare const RESERVED_PARAMETER_RESTRICTED: string;
27
+ /**
28
+ * The names of the parameters that are reserved for special purposes
29
+ *
30
+ * @public exported from `@promptbook/core`
31
+ */
32
+ export declare const RESERVED_PARAMETER_NAMES: readonly ["content", "context", "knowledge", "examples", "modelName", "currentDate"];
33
+ /**
34
+ * Note: [💞] Ignore a discrepancy between file name and entity name
35
+ */
@@ -6,8 +6,8 @@ import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions
6
6
  * Compile pipeline from string (markdown) format to JSON format
7
7
  *
8
8
  * Note: There are 3 similar functions:
9
- * - `pipelineStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
10
- * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
9
+ * - `compilePipeline` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
10
+ * - `precompilePipeline` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
11
11
  * - `preparePipeline` - just one step in the compilation process
12
12
  *
13
13
  * Note: This function does not validate logic of the pipeline only the parsing
@@ -20,7 +20,7 @@ import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions
20
20
  * @throws {ParseError} if the promptbook string is not valid
21
21
  * @public exported from `@promptbook/core`
22
22
  */
23
- export declare function pipelineStringToJson(pipelineString: PipelineString, tools?: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options?: PrepareAndScrapeOptions): Promise<PipelineJson>;
23
+ export declare function compilePipeline(pipelineString: PipelineString, tools?: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options?: PrepareAndScrapeOptions): Promise<PipelineJson>;
24
24
  /**
25
25
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
26
26
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
@@ -3,6 +3,7 @@ import type { PipelineString } from '../pipeline/PipelineString';
3
3
  /**
4
4
  * Converts promptbook in JSON format to string format
5
5
  *
6
+ * @deprecated TODO: [🥍][🧠] Backup original files in `PipelineJson` same as in Promptbook.studio
6
7
  * @param pipelineJson Promptbook in JSON format (.book.json)
7
8
  * @returns Promptbook in string format (.book.md)
8
9
  * @public exported from `@promptbook/core`
@@ -4,8 +4,8 @@ import type { PipelineString } from '../pipeline/PipelineString';
4
4
  * Compile pipeline from string (markdown) format to JSON format synchronously
5
5
  *
6
6
  * Note: There are 3 similar functions:
7
- * - `pipelineStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
8
- * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
7
+ * - `compilePipeline` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
8
+ * - `precompilePipeline` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
9
9
  * - `preparePipeline` - just one step in the compilation process
10
10
  *
11
11
  * Note: This function does not validate logic of the pipeline only the parsing
@@ -16,8 +16,9 @@ import type { PipelineString } from '../pipeline/PipelineString';
16
16
  * @throws {ParseError} if the promptbook string is not valid
17
17
  * @public exported from `@promptbook/core`
18
18
  */
19
- export declare function pipelineStringToJsonSync(pipelineString: PipelineString): PipelineJson;
19
+ export declare function precompilePipeline(pipelineString: PipelineString): PipelineJson;
20
20
  /**
21
+ * TODO: [🧠] Maybe more things here can be refactored as high-level abstractions
21
22
  * TODO: [main] !!!! Warn if used only sync version
22
23
  * TODO: [🚞] Report here line/column of error
23
24
  * TODO: Use spaceTrim more effectively
@@ -0,0 +1,20 @@
1
+ import type { $PipelineJson } from '../../commands/_common/types/CommandParser';
2
+ /**
3
+ * Used in `precompilePipeline`
4
+ *
5
+ * @private
6
+ */
7
+ export type SyncHighLevelAbstraction = {
8
+ type: 'SYNC';
9
+ /**
10
+ * Apply the abstraction to the `pipelineJson`
11
+ *
12
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
13
+ */
14
+ $applyToPipelineJson($pipelineJson: $PipelineJson): void;
15
+ };
16
+ /**
17
+ * TODO: [♓️] Add order here
18
+ * TODO: [🧠][🍱] Maybe make some common abstraction between `HighLevelAbstraction` and `CommandParser`
19
+ * Note: [💞] Ignore a discrepancy between file name and entity name
20
+ */
@@ -0,0 +1,10 @@
1
+ import type { $PipelineJson } from '../../commands/_common/types/CommandParser';
2
+ /**
3
+ * Set formfactor based on the pipeline interface e
4
+ *
5
+ * @private
6
+ */
7
+ export declare const ImplicitFormfactorHla: {
8
+ type: "SYNC";
9
+ $applyToPipelineJson($pipelineJson: $PipelineJson): void;
10
+ };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * All high-level abstractions
3
+ *
4
+ * @private internal index of `precompilePipeline` (= used for sync) and `preparePipeline` (= used for async)
5
+ */
6
+ export declare const HIGH_LEVEL_ABSTRACTIONS: readonly [{
7
+ type: "SYNC";
8
+ $applyToPipelineJson($pipelineJson: import("type-fest/source/writable-deep").WritableObjectDeep<{
9
+ readonly pipelineUrl?: string | undefined;
10
+ readonly sourceFile?: string | undefined;
11
+ readonly title: string;
12
+ readonly bookVersion?: string | undefined;
13
+ readonly description?: string | undefined;
14
+ readonly parameters: import("../_packages/types.index").ParameterJson[];
15
+ readonly defaultModelRequirements?: Partial<import("../types/ModelRequirements").ModelRequirements> | undefined;
16
+ readonly tasks: import("../_packages/types.index").TaskJson[];
17
+ readonly knowledgeSources: (import("../_packages/types.index").KnowledgeSourceJson | import("../_packages/types.index").KnowledgeSourcePreparedJson)[];
18
+ readonly knowledgePieces: import("../_packages/types.index").KnowledgePiecePreparedJson[];
19
+ readonly personas: (import("../_packages/types.index").PersonaJson | import("../_packages/types.index").PersonaPreparedJson)[];
20
+ readonly preparations: import("../_packages/types.index").PreparationJson[];
21
+ readonly formfactorName?: "CHATBOT" | "GENERATOR" | "GENERIC" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
22
+ }>): void;
23
+ }, {
24
+ type: "SYNC";
25
+ $applyToPipelineJson($pipelineJson: import("type-fest/source/writable-deep").WritableObjectDeep<{
26
+ readonly pipelineUrl?: string | undefined;
27
+ readonly sourceFile?: string | undefined;
28
+ readonly title: string;
29
+ readonly bookVersion?: string | undefined;
30
+ readonly description?: string | undefined;
31
+ readonly parameters: import("../_packages/types.index").ParameterJson[];
32
+ readonly defaultModelRequirements?: Partial<import("../types/ModelRequirements").ModelRequirements> | undefined;
33
+ readonly tasks: import("../_packages/types.index").TaskJson[];
34
+ readonly knowledgeSources: (import("../_packages/types.index").KnowledgeSourceJson | import("../_packages/types.index").KnowledgeSourcePreparedJson)[];
35
+ readonly knowledgePieces: import("../_packages/types.index").KnowledgePiecePreparedJson[];
36
+ readonly personas: (import("../_packages/types.index").PersonaJson | import("../_packages/types.index").PersonaPreparedJson)[];
37
+ readonly preparations: import("../_packages/types.index").PreparationJson[];
38
+ readonly formfactorName?: "CHATBOT" | "GENERATOR" | "GENERIC" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
39
+ }>): void;
40
+ }];
41
+ /**
42
+ * TODO: Test that all sync high-level abstractions are before async high-level abstractions
43
+ * Note: [💞] Ignore a discrepancy between file name and entity name
44
+ */
@@ -0,0 +1,10 @@
1
+ import type { $PipelineJson } from '../../commands/_common/types/CommandParser';
2
+ /**
3
+ * Allow to define chatbot with no need to write full interface
4
+ *
5
+ * @private
6
+ */
7
+ export declare const QuickChatbotHla: {
8
+ type: "SYNC";
9
+ $applyToPipelineJson($pipelineJson: $PipelineJson): void;
10
+ };
@@ -54,7 +54,7 @@ export declare class RemoteLlmExecutionTools<TCustomOptions = undefined> impleme
54
54
  private callCommonModel;
55
55
  }
56
56
  /**
57
- * TODO: Maybe use `$asDeeplyFrozenSerializableJson`
57
+ * TODO: Maybe use `$exportJson`
58
58
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
59
59
  * TODO: [🍓] Allow to list compatible models with each variant
60
60
  * TODO: [🗯] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable
@@ -11,7 +11,7 @@ import type { RemoteServerOptions } from './interfaces/RemoteServerOptions';
11
11
  */
12
12
  export declare function startRemoteServer<TCustomOptions = undefined>(options: RemoteServerOptions<TCustomOptions>): IDestroyable;
13
13
  /**
14
- * TODO: Maybe use `$asDeeplyFrozenSerializableJson`
14
+ * TODO: Maybe use `$exportJson`
15
15
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
16
16
  * TODO: [⚖] Expose the collection to be able to connect to same collection via createCollectionFromUrl
17
17
  * TODO: Handle progress - support streaming
@@ -22,6 +22,7 @@ type PreparedTasks = {
22
22
  export declare function prepareTasks(pipeline: PrepareTaskInput, tools: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options: PrepareAndScrapeOptions): Promise<PreparedTasks>;
23
23
  export {};
24
24
  /**
25
+ * TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
25
26
  * TODO: [🧠] Add context to each task (if missing)
26
27
  * TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
27
28
  * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
@@ -2,6 +2,7 @@ import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
2
2
  /**
3
3
  * Unprepare just strips the preparation data of the pipeline
4
4
  *
5
+ * @deprecated In future version this function will be removed or deprecated
5
6
  * @public exported from `@promptbook/core`
6
7
  */
7
8
  export declare function unpreparePipeline(pipeline: PipelineJson): PipelineJson;
@@ -1,5 +1,5 @@
1
1
  import type { TupleToUnion } from 'type-fest';
2
- import { RESERVED_PARAMETER_NAMES } from '../config';
2
+ import { RESERVED_PARAMETER_NAMES } from '../constants';
3
3
  /**
4
4
  * Semantic helper
5
5
  */
@@ -0,0 +1,21 @@
1
+ import type { JsonArray, JsonObject } from 'type-fest';
2
+ /**
3
+ * Options for the `orderJson` function
4
+ */
5
+ export type OrderJsonOptions<TObject extends JsonObject | JsonArray> = {
6
+ /**
7
+ * Value to checked, ordered and deeply frozen
8
+ */
9
+ value: TObject;
10
+ /**
11
+ * Order of the object properties
12
+ */
13
+ order: Array<keyof TObject>;
14
+ };
15
+ /**
16
+ * Orders JSON object by keys
17
+ *
18
+ * @returns The same type of object as the input re-ordered
19
+ * @public exported from `@promptbook/utils`
20
+ */
21
+ export declare function orderJson<TObject extends JsonObject | JsonArray>(options: OrderJsonOptions<TObject>): TObject;
@@ -0,0 +1,4 @@
1
+ export {};
2
+ /**
3
+ * TODO: [🧠] Is there a way how to test order of value better way than via `JSON.stringify`
4
+ */
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Just says that the type is used but `organize-imports-cli` does not recognize it.
3
+ * [🤛] This is a workaround for the issue.
4
+ *
5
+ * @param value any values
6
+ * @returns void
7
+ * @private within the repository
8
+ */
9
+ export declare function keepTypeImported<TTypeToKeep>(): void;
@@ -1,6 +1,6 @@
1
1
  import type { ReadonlyDeep } from 'type-fest';
2
2
  /**
3
- * @@@
3
+ * Freezes the given object and all its nested objects recursively
4
4
  *
5
5
  * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
6
6
  * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
@@ -1,4 +1,22 @@
1
1
  import type { string_name } from '../../types/typeAliases';
2
+ import type { really_unknown } from '../organization/really_unknown';
3
+ /**
4
+ * Options for the `checkSerializableAsJson` function
5
+ */
6
+ export type CheckSerializableAsJsonOptions = {
7
+ /**
8
+ * Value to be checked
9
+ */
10
+ value: really_unknown;
11
+ /**
12
+ * Semantic name of the value for debugging purposes
13
+ */
14
+ name?: string_name;
15
+ /**
16
+ * Message alongside the value for debugging purposes
17
+ */
18
+ message?: string;
19
+ };
2
20
  /**
3
21
  * Checks if the value is [🚉] serializable as JSON
4
22
  * If not, throws an UnexpectedError with a rich error message and tracking
@@ -19,9 +37,9 @@ import type { string_name } from '../../types/typeAliases';
19
37
  * @throws UnexpectedError if the value is not serializable as JSON
20
38
  * @public exported from `@promptbook/utils`
21
39
  */
22
- export declare function checkSerializableAsJson(name: string_name, value: unknown): void;
40
+ export declare function checkSerializableAsJson(options: CheckSerializableAsJsonOptions): void;
23
41
  /**
24
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
42
+ * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
25
43
  * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
26
44
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
27
45
  */
@@ -0,0 +1,29 @@
1
+ import type { JsonArray, JsonObject } from 'type-fest';
2
+ import type { OrderJsonOptions } from '../normalization/orderJson';
3
+ import type { CheckSerializableAsJsonOptions } from './checkSerializableAsJson';
4
+ /**
5
+ * Options for the `$exportJson` function
6
+ */
7
+ export type ExportJsonOptions<TObject> = CheckSerializableAsJsonOptions & Partial<Pick<OrderJsonOptions<TObject & (JsonObject | JsonArray)>, 'order'>> & {
8
+ /**
9
+ * Value to be checked, ordered and deeply frozen
10
+ */
11
+ value: TObject;
12
+ };
13
+ /**
14
+ * Utility to export a JSON object from a function
15
+ *
16
+ * 1) Checks if the value is serializable as JSON
17
+ * 2) Makes a deep clone of the object
18
+ * 2) Orders the object properties
19
+ * 2) Deeply freezes the cloned object
20
+ *
21
+ * Note: This function does not mutates the given object
22
+ *
23
+ * @returns The same type of object as the input but read-only and re-ordered
24
+ * @public exported from `@promptbook/utils`
25
+ */
26
+ export declare function exportJson<TObject>(options: ExportJsonOptions<TObject>): TObject;
27
+ /**
28
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
29
+ */
@@ -1,3 +1,4 @@
1
+ import { JsonValue } from 'type-fest';
1
2
  /**
2
3
  * Tests if the value is [🚉] serializable as JSON
3
4
  *
@@ -17,7 +18,7 @@
17
18
  *
18
19
  * @public exported from `@promptbook/utils`
19
20
  */
20
- export declare function isSerializableAsJson(value: unknown): boolean;
21
+ export declare function isSerializableAsJson(value: unknown): value is JsonValue;
21
22
  /**
22
23
  * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
23
24
  * TODO: [🧠][💺] Can be done this on type-level?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/markdown-utils",
3
- "version": "0.79.0",
3
+ "version": "0.80.0-1",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "--note-0": " <- [🐊]",
6
6
  "private": false,