@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.
- package/README.md +4 -0
- package/esm/index.es.js +52 -31
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/editable.index.d.ts +8 -2
- package/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +17 -0
- package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.d.ts +10 -0
- package/esm/typings/src/utils/editable/{utils → edit-pipeline-string}/removePipelineCommand.d.ts +1 -1
- package/esm/typings/src/utils/editable/edit-pipeline-string/removePipelineCommand.test.d.ts +1 -0
- package/esm/typings/src/utils/editable/utils/isFlatPipeline.d.ts +7 -0
- package/esm/typings/src/utils/editable/utils/renamePipelineParameter.d.ts +3 -0
- package/package.json +2 -2
- package/umd/index.umd.js +52 -31
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/utils/editable/{utils/removePipelineCommand.test.d.ts → edit-pipeline-string/addPipelineCommand.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
<blockquote style="color: #ff8811">
|
|
27
|
+
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
28
|
+
</blockquote>
|
|
29
|
+
|
|
26
30
|
## 📦 Package `@promptbook/remote-client`
|
|
27
31
|
|
|
28
32
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
package/esm/index.es.js
CHANGED
|
@@ -19,7 +19,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
19
19
|
* @generated
|
|
20
20
|
* @see https://github.com/webgptorg/promptbook
|
|
21
21
|
*/
|
|
22
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
22
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.83.0';
|
|
23
23
|
/**
|
|
24
24
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
25
25
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -4536,6 +4536,55 @@ function validatePipelineString(pipelineString) {
|
|
|
4536
4536
|
var SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
|
|
4537
4537
|
// <- TODO: [🏥] DRY
|
|
4538
4538
|
|
|
4539
|
+
/**
|
|
4540
|
+
* Removes Markdown (or HTML) comments
|
|
4541
|
+
*
|
|
4542
|
+
* @param {string} content - The string to remove comments from.
|
|
4543
|
+
* @returns {string} The input string with all comments removed.
|
|
4544
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
4545
|
+
*/
|
|
4546
|
+
function removeMarkdownComments(content) {
|
|
4547
|
+
return spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
4548
|
+
}
|
|
4549
|
+
|
|
4550
|
+
/**
|
|
4551
|
+
* @@@
|
|
4552
|
+
*
|
|
4553
|
+
* @public exported from `@promptbook/editable`
|
|
4554
|
+
*/
|
|
4555
|
+
function isFlatPipeline(pipelineString) {
|
|
4556
|
+
pipelineString = removeMarkdownComments(pipelineString);
|
|
4557
|
+
pipelineString = spaceTrim$1(pipelineString);
|
|
4558
|
+
var isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
4559
|
+
var isLastLineReturnStatement = pipelineString.split('\n').pop().split('`').join('').startsWith('->');
|
|
4560
|
+
// TODO: Also (double)check
|
|
4561
|
+
// > const usedCommands
|
|
4562
|
+
// > const isBlocksUsed
|
|
4563
|
+
// > const returnStatementCount
|
|
4564
|
+
var isFlat = !isMarkdownBeginningWithHeadline && isLastLineReturnStatement;
|
|
4565
|
+
return isFlat;
|
|
4566
|
+
}
|
|
4567
|
+
|
|
4568
|
+
/**
|
|
4569
|
+
* @@@
|
|
4570
|
+
*
|
|
4571
|
+
* @public exported from `@promptbook/editable`
|
|
4572
|
+
*/
|
|
4573
|
+
function deflatePipeline(pipelineString) {
|
|
4574
|
+
if (!isFlatPipeline(pipelineString)) {
|
|
4575
|
+
return pipelineString;
|
|
4576
|
+
}
|
|
4577
|
+
var pipelineStringLines = pipelineString.split('\n');
|
|
4578
|
+
var returnStatement = pipelineStringLines.pop();
|
|
4579
|
+
var prompt = spaceTrim$1(pipelineStringLines.join('\n'));
|
|
4580
|
+
pipelineString = validatePipelineString(spaceTrim$1(function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ```\n ").concat(block(prompt), "\n ```\n\n ").concat(returnStatement, "\n "); }));
|
|
4581
|
+
// <- TODO: Maybe use book` notation
|
|
4582
|
+
return pipelineString;
|
|
4583
|
+
}
|
|
4584
|
+
/**
|
|
4585
|
+
* TODO: Unit test
|
|
4586
|
+
*/
|
|
4587
|
+
|
|
4539
4588
|
/**
|
|
4540
4589
|
* Utility function to extract all list items from markdown
|
|
4541
4590
|
*
|
|
@@ -4837,17 +4886,6 @@ function flattenMarkdown(markdown) {
|
|
|
4837
4886
|
* NOW we are working just with markdown string and its good enough
|
|
4838
4887
|
*/
|
|
4839
4888
|
|
|
4840
|
-
/**
|
|
4841
|
-
* Removes Markdown (or HTML) comments
|
|
4842
|
-
*
|
|
4843
|
-
* @param {string} content - The string to remove comments from.
|
|
4844
|
-
* @returns {string} The input string with all comments removed.
|
|
4845
|
-
* @public exported from `@promptbook/markdown-utils`
|
|
4846
|
-
*/
|
|
4847
|
-
function removeMarkdownComments(content) {
|
|
4848
|
-
return spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
4849
|
-
}
|
|
4850
|
-
|
|
4851
4889
|
/**
|
|
4852
4890
|
* @@@
|
|
4853
4891
|
*
|
|
@@ -5105,26 +5143,9 @@ function parsePipeline(pipelineString) {
|
|
|
5105
5143
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
5106
5144
|
pipelineString = spaceTrim(pipelineString);
|
|
5107
5145
|
// <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
|
|
5146
|
+
pipelineString = deflatePipeline(pipelineString);
|
|
5108
5147
|
// ==============
|
|
5109
|
-
// Note: 1️⃣◽2️⃣
|
|
5110
|
-
var isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
5111
|
-
var isLastLineReturnStatement = pipelineString.split('\n').pop().split('`').join('').startsWith('->');
|
|
5112
|
-
// TODO: Also (double)check
|
|
5113
|
-
// > const usedCommands
|
|
5114
|
-
// > const isBlocksUsed
|
|
5115
|
-
// > const returnStatementCount
|
|
5116
|
-
var isFlatPipeline = !isMarkdownBeginningWithHeadline && isLastLineReturnStatement;
|
|
5117
|
-
// console.log({ isMarkdownBeginningWithHeadline, isLastLineReturnStatement, isFlatPipeline });
|
|
5118
|
-
if (isFlatPipeline) {
|
|
5119
|
-
var pipelineStringLines = pipelineString.split('\n');
|
|
5120
|
-
var returnStatement_1 = pipelineStringLines.pop();
|
|
5121
|
-
var prompt_1 = spaceTrim(pipelineStringLines.join('\n'));
|
|
5122
|
-
pipelineString = validatePipelineString(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 "); }));
|
|
5123
|
-
// <- TODO: Maybe use book` notation
|
|
5124
|
-
// console.log(pipelineString);
|
|
5125
|
-
}
|
|
5126
|
-
// ==============
|
|
5127
|
-
// Note: 1️⃣◽3️⃣ Parse the markdown
|
|
5148
|
+
// Note: 1️⃣◽2️⃣ Parse the markdown
|
|
5128
5149
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
5129
5150
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
5130
5151
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|