@promptbook/remote-client 0.83.0 → 0.84.0-0

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.
@@ -36,8 +36,11 @@ import type { ActionCommand } from '../commands/X_ACTION/ActionCommand';
36
36
  import { actionCommandParser } from '../commands/X_ACTION/actionCommandParser';
37
37
  import type { InstrumentCommand } from '../commands/X_INSTRUMENT/InstrumentCommand';
38
38
  import { instrumentCommandParser } from '../commands/X_INSTRUMENT/instrumentCommandParser';
39
+ import { addPipelineCommand } from '../utils/editable/edit-pipeline-string/addPipelineCommand';
40
+ import { deflatePipeline } from '../utils/editable/edit-pipeline-string/deflatePipeline';
41
+ import { removePipelineCommand } from '../utils/editable/edit-pipeline-string/removePipelineCommand';
39
42
  import type { PipelineEditableSerialized } from '../utils/editable/types/PipelineEditableSerialized';
40
- import { removePipelineCommand } from '../utils/editable/utils/removePipelineCommand';
43
+ import { isFlatPipeline } from '../utils/editable/utils/isFlatPipeline';
41
44
  import { renamePipelineParameter } from '../utils/editable/utils/renamePipelineParameter';
42
45
  import { stringifyPipelineJson } from '../utils/editable/utils/stringifyPipelineJson';
43
46
  export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
@@ -78,7 +81,10 @@ export type { ActionCommand };
78
81
  export { actionCommandParser };
79
82
  export type { InstrumentCommand };
80
83
  export { instrumentCommandParser };
81
- export type { PipelineEditableSerialized };
84
+ export { addPipelineCommand };
85
+ export { deflatePipeline };
82
86
  export { removePipelineCommand };
87
+ export type { PipelineEditableSerialized };
88
+ export { isFlatPipeline };
83
89
  export { renamePipelineParameter };
84
90
  export { stringifyPipelineJson };
@@ -0,0 +1,17 @@
1
+ import type { PipelineString } from '../../../pipeline/PipelineString';
2
+ import type { string_markdown_text } from '../../../types/typeAliases';
3
+ type AddPipelineCommandOptions = {
4
+ commandString: string_markdown_text;
5
+ pipelineString: PipelineString;
6
+ };
7
+ /**
8
+ * @@@
9
+ *
10
+ * @public exported from `@promptbook/editable`
11
+ */
12
+ export declare function addPipelineCommand(options: AddPipelineCommandOptions): PipelineString;
13
+ export {};
14
+ /**
15
+ * TODO: [🧠] What is the better solution - `- xxx`, - `- xxx` or preserve (see also next TODO)
16
+ * TODO: When existing commands 1) as 2) number 3) list, add 4) new command as next number
17
+ */
@@ -0,0 +1,10 @@
1
+ import type { PipelineString } from '../../../pipeline/PipelineString';
2
+ /**
3
+ * @@@
4
+ *
5
+ * @public exported from `@promptbook/editable`
6
+ */
7
+ export declare function deflatePipeline(pipelineString: PipelineString): PipelineString;
8
+ /**
9
+ * TODO: Unit test
10
+ */
@@ -11,7 +11,7 @@ type RemovePipelineCommandOptions = {
11
11
  /**
12
12
  * Pipeline you want to remove command from
13
13
  */
14
- pipeline: PipelineString;
14
+ pipelineString: PipelineString;
15
15
  };
16
16
  /**
17
17
  * Function `removePipelineCommand` will remove one command from pipeline string
@@ -0,0 +1,7 @@
1
+ import type { PipelineString } from '../../../pipeline/PipelineString';
2
+ /**
3
+ * @@@
4
+ *
5
+ * @public exported from `@promptbook/editable`
6
+ */
7
+ export declare function isFlatPipeline(pipelineString: PipelineString): boolean;
@@ -24,3 +24,6 @@ type RenameParameterOptions = {
24
24
  */
25
25
  export declare function renamePipelineParameter(options: RenameParameterOptions): PipelineJson;
26
26
  export {};
27
+ /**
28
+ * TODO: Also variant for `edit-pipeline-string`
29
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-client",
3
- "version": "0.83.0",
3
+ "version": "0.84.0-0",
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,
@@ -54,7 +54,7 @@
54
54
  "module": "./esm/index.es.js",
55
55
  "typings": "./esm/typings/src/_packages/remote-client.index.d.ts",
56
56
  "peerDependencies": {
57
- "@promptbook/core": "0.83.0"
57
+ "@promptbook/core": "0.84.0-0"
58
58
  },
59
59
  "dependencies": {
60
60
  "crypto-js": "4.2.0",
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- var PROMPTBOOK_ENGINE_VERSION = '0.82.0';
26
+ var PROMPTBOOK_ENGINE_VERSION = '0.83.0';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -4540,6 +4540,55 @@
4540
4540
  var SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
4541
4541
  // <- TODO: [🏥] DRY
4542
4542
 
4543
+ /**
4544
+ * Removes Markdown (or HTML) comments
4545
+ *
4546
+ * @param {string} content - The string to remove comments from.
4547
+ * @returns {string} The input string with all comments removed.
4548
+ * @public exported from `@promptbook/markdown-utils`
4549
+ */
4550
+ function removeMarkdownComments(content) {
4551
+ return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
4552
+ }
4553
+
4554
+ /**
4555
+ * @@@
4556
+ *
4557
+ * @public exported from `@promptbook/editable`
4558
+ */
4559
+ function isFlatPipeline(pipelineString) {
4560
+ pipelineString = removeMarkdownComments(pipelineString);
4561
+ pipelineString = spaceTrim__default["default"](pipelineString);
4562
+ var isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
4563
+ var isLastLineReturnStatement = pipelineString.split('\n').pop().split('`').join('').startsWith('->');
4564
+ // TODO: Also (double)check
4565
+ // > const usedCommands
4566
+ // > const isBlocksUsed
4567
+ // > const returnStatementCount
4568
+ var isFlat = !isMarkdownBeginningWithHeadline && isLastLineReturnStatement;
4569
+ return isFlat;
4570
+ }
4571
+
4572
+ /**
4573
+ * @@@
4574
+ *
4575
+ * @public exported from `@promptbook/editable`
4576
+ */
4577
+ function deflatePipeline(pipelineString) {
4578
+ if (!isFlatPipeline(pipelineString)) {
4579
+ return pipelineString;
4580
+ }
4581
+ var pipelineStringLines = pipelineString.split('\n');
4582
+ var returnStatement = pipelineStringLines.pop();
4583
+ var prompt = spaceTrim__default["default"](pipelineStringLines.join('\n'));
4584
+ pipelineString = validatePipelineString(spaceTrim__default["default"](function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ```\n ").concat(block(prompt), "\n ```\n\n ").concat(returnStatement, "\n "); }));
4585
+ // <- TODO: Maybe use book` notation
4586
+ return pipelineString;
4587
+ }
4588
+ /**
4589
+ * TODO: Unit test
4590
+ */
4591
+
4543
4592
  /**
4544
4593
  * Utility function to extract all list items from markdown
4545
4594
  *
@@ -4841,17 +4890,6 @@
4841
4890
  * NOW we are working just with markdown string and its good enough
4842
4891
  */
4843
4892
 
4844
- /**
4845
- * Removes Markdown (or HTML) comments
4846
- *
4847
- * @param {string} content - The string to remove comments from.
4848
- * @returns {string} The input string with all comments removed.
4849
- * @public exported from `@promptbook/markdown-utils`
4850
- */
4851
- function removeMarkdownComments(content) {
4852
- return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
4853
- }
4854
-
4855
4893
  /**
4856
4894
  * @@@
4857
4895
  *
@@ -5109,26 +5147,9 @@
5109
5147
  pipelineString = removeMarkdownComments(pipelineString);
5110
5148
  pipelineString = spaceTrim.spaceTrim(pipelineString);
5111
5149
  // <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
5150
+ pipelineString = deflatePipeline(pipelineString);
5112
5151
  // ==============
5113
- // Note: 1️⃣◽2️⃣ Process flat pipeline
5114
- var isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
5115
- var isLastLineReturnStatement = pipelineString.split('\n').pop().split('`').join('').startsWith('->');
5116
- // TODO: Also (double)check
5117
- // > const usedCommands
5118
- // > const isBlocksUsed
5119
- // > const returnStatementCount
5120
- var isFlatPipeline = !isMarkdownBeginningWithHeadline && isLastLineReturnStatement;
5121
- // console.log({ isMarkdownBeginningWithHeadline, isLastLineReturnStatement, isFlatPipeline });
5122
- if (isFlatPipeline) {
5123
- var pipelineStringLines = pipelineString.split('\n');
5124
- var returnStatement_1 = pipelineStringLines.pop();
5125
- var prompt_1 = spaceTrim.spaceTrim(pipelineStringLines.join('\n'));
5126
- pipelineString = validatePipelineString(spaceTrim.spaceTrim(function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ```\n ").concat(block(prompt_1), "\n ```\n\n ").concat(returnStatement_1, "\n "); }));
5127
- // <- TODO: Maybe use book` notation
5128
- // console.log(pipelineString);
5129
- }
5130
- // ==============
5131
- // Note: 1️⃣◽3️⃣ Parse the markdown
5152
+ // Note: 1️⃣◽2️⃣ Parse the markdown
5132
5153
  pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
5133
5154
  pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
5134
5155
  pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');