@promptbook/utils 0.75.0-2 → 0.75.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 +46 -30
- package/esm/index.es.js +57 -46
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +16 -4
- package/esm/typings/src/_packages/types.index.d.ts +8 -6
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- 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 +34 -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/organization/spaceTrim.d.ts +11 -0
- package/esm/typings/src/utils/parameters/extractParameterNames.d.ts +1 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +55 -43
- 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
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
#  Promptbook
|
|
4
4
|
|
|
5
|
-
Build responsible, controlled and transparent applications on top of LLM models!
|
|
6
|
-
|
|
7
5
|
|
|
8
6
|
|
|
9
7
|
|
|
@@ -25,10 +23,6 @@ Build responsible, controlled and transparent applications on top of LLM models!
|
|
|
25
23
|
|
|
26
24
|
|
|
27
25
|
|
|
28
|
-
<blockquote style="color: #ff8811">
|
|
29
|
-
<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>.
|
|
30
|
-
</blockquote>
|
|
31
|
-
|
|
32
26
|
## 📦 Package `@promptbook/utils`
|
|
33
27
|
|
|
34
28
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
@@ -172,28 +166,33 @@ See also the documentation for all the functions in the `@promptbook/utils` pack
|
|
|
172
166
|
|
|
173
167
|
Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
174
168
|
|
|
175
|
-
## 🤍 The Promptbook Whitepaper
|
|
176
169
|
|
|
177
|
-
If you have a simple, single prompt for ChatGPT, GPT-4, Anthropic Claude, Google Gemini, Llama 3, or whatever, it doesn't matter how you integrate it. Whether it's calling a REST API directly, using the SDK, hardcoding the prompt into the source code, or importing a text file, the process remains the same.
|
|
178
170
|
|
|
179
|
-
But often you will struggle with the **limitations of LLMs**, such as **hallucinations, off-topic responses, poor quality output, language and prompt drift, word repetition repetition repetition repetition or misuse, lack of context, or just plain w𝒆𝐢rd resp0nses**. When this happens, you generally have three options:
|
|
180
171
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
172
|
+
## 🤍 The Book Abstract
|
|
173
|
+
|
|
174
|
+
**It's time for a paradigm shift! The future of software is in plain English, French or Latin.**
|
|
175
|
+
|
|
176
|
+
During the computer revolution, we have seen [multiple generations of computer languages](https://github.com/webgptorg/promptbook/discussions/180), from the physical rewiring of the vacuum tubes through low-level machine code to the high-level languages like Python or JavaScript. And now, we're on the edge of the **next revolution**!
|
|
177
|
+
|
|
178
|
+
It's a revolution of writing software in plain human language that is understandable and executable by both humans and machines – and it's going to change everything!
|
|
179
|
+
|
|
180
|
+
The incredible growth in power of microprocessors and the Moore's Law have been the driving force behind the ever-more powerful languages, and it's been an amazing journey! Similarly, the large language models (like GPT or Claude) are the next big thing in language technology, and they're set to transform the way we interact with computers.
|
|
184
181
|
|
|
185
|
-
|
|
182
|
+
This shift is going to happen, whether we are ready for it or not. Our mission is to make it excellently, not just good.
|
|
186
183
|
|
|
187
|
-
|
|
188
|
-
- Book allows you to **focus on the business** logic without having to write code or deal with the technicalities of LLMs.
|
|
189
|
-
- **Forget** about **low-level details** like choosing the right model, tokens, context size, `temperature`, `top-k`, `top-p`, or kernel sampling. **Just write your intent** and [**persona**](https://github.com/webgptorg/promptbook/discussions/22) who should be responsible for the task and let the library do the rest.
|
|
190
|
-
- We have built-in **orchestration** of [pipeline](https://github.com/webgptorg/promptbook/discussions/64) execution and many tools to make the process easier, more reliable, and more efficient, such as caching, [compilation+preparation](https://github.com/webgptorg/promptbook/discussions/78), [just-in-time fine-tuning](https://github.com/webgptorg/promptbook/discussions/33), [expectation-aware generation](https://github.com/webgptorg/promptbook/discussions/37), [agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39), and more.
|
|
191
|
-
- Sometimes even the best prompts with the best framework like Promptbook `:)` can't avoid the problems. In this case, the library has built-in **[anomaly detection](https://github.com/webgptorg/promptbook/discussions/40) and logging** to help you find and fix the problems.
|
|
192
|
-
- Versioning is build in. You can test multiple **A/B versions** of pipelines and see which one works best.
|
|
193
|
-
- Promptbook is designed to use [**RAG** (Retrieval-Augmented Generation)](https://github.com/webgptorg/promptbook/discussions/41) and other advanced techniques to bring the context of your business to generic LLM. You can use **knowledge** to improve the quality of the output.
|
|
184
|
+
**Join us in this journey!**
|
|
194
185
|
|
|
195
186
|
|
|
196
187
|
|
|
188
|
+
## 🚀 Get started
|
|
189
|
+
|
|
190
|
+
Take a look at the simple starter kit with books integrated into the **Hello World** sample applications:
|
|
191
|
+
|
|
192
|
+
- [Hello Book](https://github.com/webgptorg/hello-world)
|
|
193
|
+
- [Hello Book in Node.js](https://github.com/webgptorg/hello-world-node-js)
|
|
194
|
+
- [Hello Book in Next.js](https://github.com/webgptorg/hello-world-next-js)
|
|
195
|
+
|
|
197
196
|
|
|
198
197
|
|
|
199
198
|
|
|
@@ -212,7 +211,7 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
|
|
|
212
211
|
<tbody>
|
|
213
212
|
<tr>
|
|
214
213
|
<td>Core</td>
|
|
215
|
-
<td>Promptbook
|
|
214
|
+
<td>Promptbook Core is a description and documentation of the basic concepts, ideas and inner workings of how Promptbook should be implemented, and defines what features must be describable by book language.</td>
|
|
216
215
|
<td rowspan=2>https://ptbk.io<br/>https://github.com/webgptorg/book</td>
|
|
217
216
|
</tr>
|
|
218
217
|
<tr>
|
|
@@ -223,17 +222,23 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
|
|
|
223
222
|
</tr>
|
|
224
223
|
<tr>
|
|
225
224
|
<td>Promptbook typescript project</td>
|
|
226
|
-
<td>
|
|
225
|
+
<td>Promptbook implementation in TypeScript released as multiple NPM packages</td>
|
|
227
226
|
<td>https://github.com/webgptorg/promptbook + Multiple packages on NPM</td>
|
|
228
227
|
</tr>
|
|
229
228
|
<tr>
|
|
230
229
|
<td>Promptbook studio</td>
|
|
231
|
-
<td>
|
|
232
|
-
<td
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
<td>
|
|
230
|
+
<td>Studio to write Books and instantly publish them as miniapps</td>
|
|
231
|
+
<td>
|
|
232
|
+
https://promptbook.studio<br/>
|
|
233
|
+
https://github.com/hejny/promptbook-studio</td>
|
|
234
|
+
</tr><tr>
|
|
235
|
+
<td>Hello World</td>
|
|
236
|
+
<td>Simple starter kit with Books integrated into the sample applications</td>
|
|
237
|
+
<td>
|
|
238
|
+
https://github.com/webgptorg/hello-world<br/>
|
|
239
|
+
https://github.com/webgptorg/hello-world-node-js<br/>
|
|
240
|
+
https://github.com/webgptorg/hello-world-next-js
|
|
241
|
+
</td>
|
|
237
242
|
</tr>
|
|
238
243
|
</tbody>
|
|
239
244
|
</table>
|
|
@@ -302,7 +307,9 @@ Reserved words:
|
|
|
302
307
|
|
|
303
308
|
#### Parameter notation
|
|
304
309
|
|
|
305
|
-
###
|
|
310
|
+
### Task
|
|
311
|
+
|
|
312
|
+
### Task type
|
|
306
313
|
|
|
307
314
|
Todo todo
|
|
308
315
|
|
|
@@ -363,6 +370,11 @@ Or you can install them separately:
|
|
|
363
370
|
|
|
364
371
|
## 📚 Dictionary
|
|
365
372
|
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
366
378
|
### 📚 Dictionary
|
|
367
379
|
|
|
368
380
|
The following glossary is used to clarify certain concepts:
|
|
@@ -378,6 +390,8 @@ The following glossary is used to clarify certain concepts:
|
|
|
378
390
|
- **Retrieval-augmented generation** is a machine learning paradigm where a model generates text by retrieving relevant information from a large database of text. This approach combines the benefits of generative models and retrieval models.
|
|
379
391
|
- **Longtail** refers to non-common or rare events, items, or entities that are not well-represented in the training data of machine learning models. Longtail items are often challenging for models to predict accurately.
|
|
380
392
|
|
|
393
|
+
|
|
394
|
+
|
|
381
395
|
_Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
382
396
|
|
|
383
397
|
#### Promptbook core
|
|
@@ -414,7 +428,7 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
414
428
|
|
|
415
429
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
|
416
430
|
- [📯 Pipeline](https://github.com/webgptorg/promptbook/discussions/64)
|
|
417
|
-
- [
|
|
431
|
+
- [🙇♂️ Tasks and pipeline sections](https://github.com/webgptorg/promptbook/discussions/88)
|
|
418
432
|
- [🤼 Personas](https://github.com/webgptorg/promptbook/discussions/22)
|
|
419
433
|
- [⭕ Parameters](https://github.com/webgptorg/promptbook/discussions/83)
|
|
420
434
|
- [🚀 Pipeline execution](https://github.com/webgptorg/promptbook/discussions/84)
|
|
@@ -438,6 +452,8 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
438
452
|
- [👮 Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)
|
|
439
453
|
- [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)
|
|
440
454
|
|
|
455
|
+
|
|
456
|
+
|
|
441
457
|
### Terms specific to Promptbook TypeScript implementation
|
|
442
458
|
|
|
443
459
|
- Anonymous mode
|
package/esm/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import spaceTrim$
|
|
1
|
+
import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
2
2
|
import { basename } from 'path';
|
|
3
3
|
|
|
4
4
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
@@ -13,7 +13,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
13
13
|
*
|
|
14
14
|
* @see https://github.com/webgptorg/promptbook
|
|
15
15
|
*/
|
|
16
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.75.0
|
|
16
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.75.0';
|
|
17
17
|
/**
|
|
18
18
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
19
19
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -146,7 +146,7 @@ function __spreadArray(to, from, pack) {
|
|
|
146
146
|
var UnexpectedError = /** @class */ (function (_super) {
|
|
147
147
|
__extends(UnexpectedError, _super);
|
|
148
148
|
function UnexpectedError(message) {
|
|
149
|
-
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
149
|
+
var _this = _super.call(this, spaceTrim$1(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
150
150
|
_this.name = 'UnexpectedError';
|
|
151
151
|
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
152
152
|
return _this;
|
|
@@ -644,8 +644,8 @@ function titleToName(value) {
|
|
|
644
644
|
* @public exported from `@promptbook/utils`
|
|
645
645
|
*/
|
|
646
646
|
function renderPromptbookMermaid(pipelineJson, options) {
|
|
647
|
-
var _a = (options || {}).
|
|
648
|
-
var
|
|
647
|
+
var _a = (options || {}).linkTask, linkTask = _a === void 0 ? function () { return null; } : _a;
|
|
648
|
+
var parameterNameToTaskName = function (parameterName) {
|
|
649
649
|
var parameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
650
650
|
if (!parameter) {
|
|
651
651
|
throw new UnexpectedError("Could not find {".concat(parameterName, "}"));
|
|
@@ -653,19 +653,19 @@ function renderPromptbookMermaid(pipelineJson, options) {
|
|
|
653
653
|
if (parameter.isInput) {
|
|
654
654
|
return 'input';
|
|
655
655
|
}
|
|
656
|
-
var
|
|
657
|
-
if (!
|
|
658
|
-
throw new Error("Could not find
|
|
656
|
+
var task = pipelineJson.tasks.find(function (task) { return task.resultingParameterName === parameterName; });
|
|
657
|
+
if (!task) {
|
|
658
|
+
throw new Error("Could not find task for {".concat(parameterName, "}"));
|
|
659
659
|
}
|
|
660
|
-
return normalizeTo_camelCase('
|
|
660
|
+
return normalizeTo_camelCase('task-' + titleToName(task.title));
|
|
661
661
|
};
|
|
662
|
-
var promptbookMermaid = spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.tasks
|
|
662
|
+
var promptbookMermaid = spaceTrim$1(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.tasks
|
|
663
663
|
.flatMap(function (_a) {
|
|
664
664
|
var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
|
|
665
665
|
return __spreadArray([
|
|
666
|
-
"".concat(
|
|
666
|
+
"".concat(parameterNameToTaskName(resultingParameterName), "(\"").concat(title, "\")")
|
|
667
667
|
], __read(dependentParameterNames.map(function (dependentParameterName) {
|
|
668
|
-
return "".concat(
|
|
668
|
+
return "".concat(parameterNameToTaskName(dependentParameterName), "--\"{").concat(dependentParameterName, "}\"-->").concat(parameterNameToTaskName(resultingParameterName));
|
|
669
669
|
})), false);
|
|
670
670
|
})
|
|
671
671
|
.join('\n')), "\n\n ").concat(block(pipelineJson.parameters
|
|
@@ -675,17 +675,17 @@ function renderPromptbookMermaid(pipelineJson, options) {
|
|
|
675
675
|
})
|
|
676
676
|
.map(function (_a) {
|
|
677
677
|
var name = _a.name;
|
|
678
|
-
return "".concat(
|
|
678
|
+
return "".concat(parameterNameToTaskName(name), "--\"{").concat(name, "}\"-->output");
|
|
679
679
|
})
|
|
680
680
|
.join('\n')), "\n output((Output)):::output\n\n ").concat(block(pipelineJson.tasks
|
|
681
|
-
.map(function (
|
|
682
|
-
var link =
|
|
681
|
+
.map(function (task) {
|
|
682
|
+
var link = linkTask(task);
|
|
683
683
|
if (link === null) {
|
|
684
684
|
return '';
|
|
685
685
|
}
|
|
686
686
|
var href = link.href, title = link.title;
|
|
687
|
-
var
|
|
688
|
-
return "click ".concat(
|
|
687
|
+
var taskName = parameterNameToTaskName(task.resultingParameterName);
|
|
688
|
+
return "click ".concat(taskName, " href \"").concat(href, "\" \"").concat(title, "\";");
|
|
689
689
|
})
|
|
690
690
|
.filter(function (line) { return line !== ''; })
|
|
691
691
|
.join('\n')), "\n\n classDef input color: grey;\n classDef output color: grey;\n\n end;\n\n "); });
|
|
@@ -702,7 +702,7 @@ function renderPromptbookMermaid(pipelineJson, options) {
|
|
|
702
702
|
/**
|
|
703
703
|
* Parses the task and returns the list of all parameter names
|
|
704
704
|
*
|
|
705
|
-
* @param template the
|
|
705
|
+
* @param template the string template with parameters in {curly} braces
|
|
706
706
|
* @returns the list of parameter names
|
|
707
707
|
* @public exported from `@promptbook/utils`
|
|
708
708
|
*/
|
|
@@ -787,7 +787,7 @@ function extractVariables(script) {
|
|
|
787
787
|
if (!(error instanceof Error)) {
|
|
788
788
|
throw error;
|
|
789
789
|
}
|
|
790
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n "); }));
|
|
790
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n "); }));
|
|
791
791
|
}
|
|
792
792
|
return variables;
|
|
793
793
|
}
|
|
@@ -796,16 +796,16 @@ function extractVariables(script) {
|
|
|
796
796
|
*/
|
|
797
797
|
|
|
798
798
|
/**
|
|
799
|
-
* Parses the
|
|
799
|
+
* Parses the task and returns the set of all used parameters
|
|
800
800
|
*
|
|
801
|
-
* @param
|
|
801
|
+
* @param task the task with used parameters
|
|
802
802
|
* @returns the set of parameter names
|
|
803
803
|
* @throws {ParseError} if the script is invalid
|
|
804
804
|
* @public exported from `@promptbook/utils`
|
|
805
805
|
*/
|
|
806
|
-
function extractParameterNamesFromTask(
|
|
806
|
+
function extractParameterNamesFromTask(task) {
|
|
807
807
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
808
|
-
var title =
|
|
808
|
+
var title = task.title, description = task.description, taskType = task.taskType, content = task.content, preparedContent = task.preparedContent, jokerParameterNames = task.jokerParameterNames, foreach = task.foreach;
|
|
809
809
|
var parameterNames = new Set();
|
|
810
810
|
try {
|
|
811
811
|
for (var _e = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameterNames(title)), false), __read(extractParameterNames(description || '')), false), __read(extractParameterNames(content)), false), __read(extractParameterNames(preparedContent || '')), false)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
@@ -893,8 +893,8 @@ var PipelineLogicError = /** @class */ (function (_super) {
|
|
|
893
893
|
}(Error));
|
|
894
894
|
|
|
895
895
|
/**
|
|
896
|
-
* Function `renameParameter` will find all usable parameters for given
|
|
897
|
-
* In other words, it will find all parameters that are not used in the
|
|
896
|
+
* Function `renameParameter` will find all usable parameters for given task
|
|
897
|
+
* In other words, it will find all parameters that are not used in the task itseld and all its dependencies
|
|
898
898
|
*
|
|
899
899
|
* @throws {PipelineLogicError} If the new parameter name is already used in the pipeline
|
|
900
900
|
* @public exported from `@promptbook/utils`
|
|
@@ -926,19 +926,19 @@ function renameParameter(options) {
|
|
|
926
926
|
}
|
|
927
927
|
try {
|
|
928
928
|
for (var _e = __values(renamedPipeline.tasks), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
929
|
-
var
|
|
930
|
-
if (
|
|
931
|
-
|
|
929
|
+
var task = _f.value;
|
|
930
|
+
if (task.resultingParameterName === oldParameterName) {
|
|
931
|
+
task.resultingParameterName = newParameterName;
|
|
932
932
|
}
|
|
933
|
-
|
|
933
|
+
task.dependentParameterNames = task.dependentParameterNames.map(function (dependentParameterName) {
|
|
934
934
|
return dependentParameterName === oldParameterName ? newParameterName : dependentParameterName;
|
|
935
935
|
});
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
936
|
+
task.content = task.content.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
|
|
937
|
+
task.title = task.title.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
|
|
938
|
+
task.description =
|
|
939
|
+
task.description === undefined
|
|
940
940
|
? undefined
|
|
941
|
-
:
|
|
941
|
+
: task.description.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
|
|
942
942
|
}
|
|
943
943
|
}
|
|
944
944
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -1042,7 +1042,7 @@ var NotFoundError = /** @class */ (function (_super) {
|
|
|
1042
1042
|
var NotYetImplementedError = /** @class */ (function (_super) {
|
|
1043
1043
|
__extends(NotYetImplementedError, _super);
|
|
1044
1044
|
function NotYetImplementedError(message) {
|
|
1045
|
-
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
1045
|
+
var _this = _super.call(this, spaceTrim$1(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
1046
1046
|
_this.name = 'NotYetImplementedError';
|
|
1047
1047
|
Object.setPrototypeOf(_this, NotYetImplementedError.prototype);
|
|
1048
1048
|
return _this;
|
|
@@ -1126,7 +1126,7 @@ function deserializeError(error) {
|
|
|
1126
1126
|
function serializeError(error) {
|
|
1127
1127
|
var name = error.name, message = error.message, stack = error.stack;
|
|
1128
1128
|
if (!__spreadArray(['Error'], __read(Object.keys(ERRORS)), false).includes(name)) {
|
|
1129
|
-
throw new UnexpectedError(spaceTrim$
|
|
1129
|
+
throw new UnexpectedError(spaceTrim$2(function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
1130
1130
|
}
|
|
1131
1131
|
return {
|
|
1132
1132
|
name: name,
|
|
@@ -1632,6 +1632,17 @@ function searchKeywords(haystack, needle) {
|
|
|
1632
1632
|
return true;
|
|
1633
1633
|
}
|
|
1634
1634
|
|
|
1635
|
+
/**
|
|
1636
|
+
* Trims string from all 4 sides
|
|
1637
|
+
*
|
|
1638
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
1639
|
+
* Developed by same author @hejny as this package
|
|
1640
|
+
*
|
|
1641
|
+
* @public exported from `@promptbook/utils`
|
|
1642
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
1643
|
+
*/
|
|
1644
|
+
var spaceTrim = spaceTrim$1;
|
|
1645
|
+
|
|
1635
1646
|
/**
|
|
1636
1647
|
* @@@
|
|
1637
1648
|
*
|
|
@@ -1716,7 +1727,7 @@ function checkSerializableAsJson(name, value) {
|
|
|
1716
1727
|
}
|
|
1717
1728
|
else if (typeof value === 'object') {
|
|
1718
1729
|
if (value instanceof Date) {
|
|
1719
|
-
throw new UnexpectedError(spaceTrim$
|
|
1730
|
+
throw new UnexpectedError(spaceTrim$2("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
|
|
1720
1731
|
}
|
|
1721
1732
|
else if (value instanceof Map) {
|
|
1722
1733
|
throw new UnexpectedError("".concat(name, " is Map"));
|
|
@@ -1728,7 +1739,7 @@ function checkSerializableAsJson(name, value) {
|
|
|
1728
1739
|
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
1729
1740
|
}
|
|
1730
1741
|
else if (value instanceof Error) {
|
|
1731
|
-
throw new UnexpectedError(spaceTrim$
|
|
1742
|
+
throw new UnexpectedError(spaceTrim$2("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
|
|
1732
1743
|
}
|
|
1733
1744
|
else {
|
|
1734
1745
|
try {
|
|
@@ -1755,7 +1766,7 @@ function checkSerializableAsJson(name, value) {
|
|
|
1755
1766
|
if (!(error instanceof Error)) {
|
|
1756
1767
|
throw error;
|
|
1757
1768
|
}
|
|
1758
|
-
throw new UnexpectedError(spaceTrim$
|
|
1769
|
+
throw new UnexpectedError(spaceTrim$2(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
|
|
1759
1770
|
}
|
|
1760
1771
|
/*
|
|
1761
1772
|
TODO: [0] Is there some more elegant way to check circular references?
|
|
@@ -2259,13 +2270,13 @@ function union() {
|
|
|
2259
2270
|
* @public exported from `@promptbook/utils`
|
|
2260
2271
|
*/
|
|
2261
2272
|
function trimCodeBlock(value) {
|
|
2262
|
-
value = spaceTrim(value);
|
|
2273
|
+
value = spaceTrim$1(value);
|
|
2263
2274
|
if (!/^```[a-z]*(.*)```$/is.test(value)) {
|
|
2264
2275
|
return value;
|
|
2265
2276
|
}
|
|
2266
2277
|
value = value.replace(/^```[a-z]*/i, '');
|
|
2267
2278
|
value = value.replace(/```$/i, '');
|
|
2268
|
-
value = spaceTrim(value);
|
|
2279
|
+
value = spaceTrim$1(value);
|
|
2269
2280
|
return value;
|
|
2270
2281
|
}
|
|
2271
2282
|
|
|
@@ -2278,9 +2289,9 @@ function trimCodeBlock(value) {
|
|
|
2278
2289
|
* @public exported from `@promptbook/utils`
|
|
2279
2290
|
*/
|
|
2280
2291
|
function trimEndOfCodeBlock(value) {
|
|
2281
|
-
value = spaceTrim(value);
|
|
2292
|
+
value = spaceTrim$1(value);
|
|
2282
2293
|
value = value.replace(/```$/g, '');
|
|
2283
|
-
value = spaceTrim(value);
|
|
2294
|
+
value = spaceTrim$1(value);
|
|
2284
2295
|
return value;
|
|
2285
2296
|
}
|
|
2286
2297
|
|
|
@@ -2302,7 +2313,7 @@ function unwrapResult(text, options) {
|
|
|
2302
2313
|
var trimmedText = text;
|
|
2303
2314
|
// Remove leading and trailing spaces and newlines
|
|
2304
2315
|
if (isTrimmed) {
|
|
2305
|
-
trimmedText = spaceTrim(trimmedText);
|
|
2316
|
+
trimmedText = spaceTrim$1(trimmedText);
|
|
2306
2317
|
}
|
|
2307
2318
|
var processedText = trimmedText;
|
|
2308
2319
|
if (isIntroduceSentenceRemoved) {
|
|
@@ -2311,7 +2322,7 @@ function unwrapResult(text, options) {
|
|
|
2311
2322
|
// Remove the introduce sentence and quotes by replacing it with an empty string
|
|
2312
2323
|
processedText = processedText.replace(introduceSentenceRegex, '');
|
|
2313
2324
|
}
|
|
2314
|
-
processedText = spaceTrim(processedText);
|
|
2325
|
+
processedText = spaceTrim$1(processedText);
|
|
2315
2326
|
}
|
|
2316
2327
|
if (processedText.length < 3) {
|
|
2317
2328
|
return trimmedText;
|
|
@@ -2519,5 +2530,5 @@ function isValidUuid(value) {
|
|
|
2519
2530
|
return /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i.test(value);
|
|
2520
2531
|
}
|
|
2521
2532
|
|
|
2522
|
-
export { $currentDate, $deepFreeze, $isRunningInBrowser, $isRunningInNode, $isRunningInWebWorker, $randomSeed, BOOK_LANGUAGE_VERSION, CHARACTERS_PER_STANDARD_LINE, CountUtils, DIACRITIC_VARIANTS_LETTERS, LINES_PER_STANDARD_PAGE, PROMPTBOOK_ENGINE_VERSION, capitalize, checkSerializableAsJson, clonePipeline, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, decapitalize, deepClone, deserializeError, difference, extractParameterNames, extractParameterNamesFromTask, extractVariables, forEachAsync, intersection, isHostnameOnPrivateNetwork, isSerializableAsJson, isUrlOnPrivateNetwork, isValidEmail, isValidFilePath, isValidJavascriptName, isValidJsonString, isValidKeyword, isValidPipelineUrl, isValidPromptbookVersion, isValidSemanticVersion, isValidUrl, isValidUuid, nameToUriPart, nameToUriParts, normalizeToKebabCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_camelCase, normalizeTo_snake_case, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, parseNumber, removeDiacritics, removeEmojis, removeQuotes, renameParameter, renderPromptbookMermaid, replaceParameters, searchKeywords, serializeError, splitIntoSentences, titleToName, trimCodeBlock, trimEndOfCodeBlock, union, unwrapResult };
|
|
2533
|
+
export { $currentDate, $deepFreeze, $isRunningInBrowser, $isRunningInNode, $isRunningInWebWorker, $randomSeed, BOOK_LANGUAGE_VERSION, CHARACTERS_PER_STANDARD_LINE, CountUtils, DIACRITIC_VARIANTS_LETTERS, LINES_PER_STANDARD_PAGE, PROMPTBOOK_ENGINE_VERSION, capitalize, checkSerializableAsJson, clonePipeline, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, decapitalize, deepClone, deserializeError, difference, extractParameterNames, extractParameterNamesFromTask, extractVariables, forEachAsync, intersection, isHostnameOnPrivateNetwork, isSerializableAsJson, isUrlOnPrivateNetwork, isValidEmail, isValidFilePath, isValidJavascriptName, isValidJsonString, isValidKeyword, isValidPipelineUrl, isValidPromptbookVersion, isValidSemanticVersion, isValidUrl, isValidUuid, nameToUriPart, nameToUriParts, normalizeToKebabCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_camelCase, normalizeTo_snake_case, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, parseNumber, removeDiacritics, removeEmojis, removeQuotes, renameParameter, renderPromptbookMermaid, replaceParameters, searchKeywords, serializeError, spaceTrim, splitIntoSentences, titleToName, trimCodeBlock, trimEndOfCodeBlock, union, unwrapResult };
|
|
2523
2534
|
//# sourceMappingURL=index.es.js.map
|