@promptbook/node 0.74.0-5 → 0.74.0-7
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 +60 -14
- package/esm/index.es.js +13 -9
- package/esm/index.es.js.map +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +13 -9
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -56,8 +56,6 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
56
56
|
|
|
57
57
|
## 🤍 The Promptbook Whitepaper
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
59
|
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.
|
|
62
60
|
|
|
63
61
|
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:
|
|
@@ -126,23 +124,17 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
|
|
|
126
124
|
|
|
127
125
|
## 💙 Book language _(for prompt-engineer)_
|
|
128
126
|
|
|
129
|
-
Promptbook [pipelines](https://github.com/webgptorg/promptbook/discussions/64) are written in markdown-like language called [Book](https://github.com/webgptorg/book). It is designed to be understandable by non-programmers and non-technical people.
|
|
130
|
-
|
|
131
127
|
|
|
132
128
|
|
|
133
|
-
```markdown
|
|
134
|
-
# 🌟 My first Book
|
|
135
129
|
|
|
136
|
-
|
|
137
|
-
- OUTPUT PARAMETER {article}
|
|
130
|
+
## 💙 The blueprint of book language
|
|
138
131
|
|
|
139
|
-
|
|
132
|
+
Following is the documentation and blueprint of the Book language.
|
|
140
133
|
|
|
141
|
-
|
|
134
|
+
### Example
|
|
142
135
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
## Write an article
|
|
136
|
+
```markdown
|
|
137
|
+
# 🌟 My first Book
|
|
146
138
|
|
|
147
139
|
- PERSONA Jane, marketing specialist with prior experience in writing articles about technology and artificial intelligence
|
|
148
140
|
- KNOWLEDGE https://ptbk.io
|
|
@@ -151,11 +143,65 @@ Promptbook [pipelines](https://github.com/webgptorg/promptbook/discussions/64) a
|
|
|
151
143
|
- EXPECT MAX 1 Paragraph
|
|
152
144
|
|
|
153
145
|
> Write an article about the future of artificial intelligence in the next 10 years and how metalanguages will change the way AI is used in the world.
|
|
154
|
-
> Look specifically at the impact of
|
|
146
|
+
> Look specifically at the impact of Promptbook on the AI industry.
|
|
155
147
|
|
|
156
148
|
-> {article}
|
|
157
149
|
```
|
|
158
150
|
|
|
151
|
+
### Goals and principles of book language
|
|
152
|
+
|
|
153
|
+
File is designed to be easy to read and write. It is strict subset of markdown. It is designed to be understandable by both humans and machines and without specific knowledge of the language.
|
|
154
|
+
|
|
155
|
+
It has file with `.ptbk.md` or `.book` extension with `UTF-8` non BOM encoding.
|
|
156
|
+
|
|
157
|
+
As it is source code, it can leverage all the features of version control systems like git and does not suffer from the problems of binary formats, proprietary formats, or no-code solutions.
|
|
158
|
+
|
|
159
|
+
But unlike programming languages, it is designed to be understandable by non-programmers and non-technical people.
|
|
160
|
+
|
|
161
|
+
### Structure
|
|
162
|
+
|
|
163
|
+
Book is divided into sections. Each section starts with heading. The language itself is not sensitive to the type of heading _(`h1`, `h2`, `h3`, ...)_ but it is recommended to use `h1` for header section and `h2` for other sections.
|
|
164
|
+
|
|
165
|
+
### Header
|
|
166
|
+
|
|
167
|
+
Header is the first section of the book. It contains metadata about the pipeline. It is recommended to use `h1` heading for header section but it is not required.
|
|
168
|
+
|
|
169
|
+
### Parameter
|
|
170
|
+
|
|
171
|
+
Foo bar
|
|
172
|
+
|
|
173
|
+
#### Parameter names
|
|
174
|
+
|
|
175
|
+
Reserved words:
|
|
176
|
+
|
|
177
|
+
- _each command_ like `PERSONA`, `EXPECT`, `KNOWLEDGE`, etc.
|
|
178
|
+
- `content`
|
|
179
|
+
- `context`
|
|
180
|
+
- `knowledge`
|
|
181
|
+
- `examples`
|
|
182
|
+
- `modelName`
|
|
183
|
+
- `currentDate`
|
|
184
|
+
|
|
185
|
+
#### Parameter notation
|
|
186
|
+
|
|
187
|
+
### Template
|
|
188
|
+
|
|
189
|
+
Todo todo
|
|
190
|
+
|
|
191
|
+
### Command
|
|
192
|
+
|
|
193
|
+
Todo todo
|
|
194
|
+
|
|
195
|
+
### Block
|
|
196
|
+
|
|
197
|
+
Todo todo
|
|
198
|
+
|
|
199
|
+
### Return parameter
|
|
200
|
+
|
|
201
|
+
### Examples
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
159
205
|
## 📦 Packages _(for developers)_
|
|
160
206
|
|
|
161
207
|
This library is divided into several packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
package/esm/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
*
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.74.0-
|
|
29
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.74.0-6';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
*/
|
|
@@ -7758,11 +7758,18 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7758
7758
|
}
|
|
7759
7759
|
// =============================================================
|
|
7760
7760
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
7761
|
+
if (pipelineString.startsWith('#!')) {
|
|
7762
|
+
var _c = __read(pipelineString.split('\n')), shebangLine_1 = _c[0], restLines = _c.slice(1);
|
|
7763
|
+
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
7764
|
+
throw new ParseError(spaceTrim(function (block) { return "\n It seems that you try to parse a book file which has non-standard shebang line for book files:\n Shebang line must contain 'ptbk'\n\n You have:\n ".concat(block(shebangLine_1 || '(empty line)'), "\n\n It should look like this:\n #!/usr/bin/env ptbk\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
7765
|
+
}
|
|
7766
|
+
pipelineString = restLines.join('\n');
|
|
7767
|
+
}
|
|
7761
7768
|
pipelineString = removeContentComments(pipelineString);
|
|
7762
7769
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
7763
7770
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
7764
7771
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
7765
|
-
var
|
|
7772
|
+
var _d = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _d[0], pipelineSections = _d.slice(1); /* <- Note: [🥞] */
|
|
7766
7773
|
if (pipelineHead === undefined) {
|
|
7767
7774
|
throw new UnexpectedError(spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
7768
7775
|
}
|
|
@@ -7852,10 +7859,10 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7852
7859
|
finally { if (e_1) throw e_1.error; }
|
|
7853
7860
|
}
|
|
7854
7861
|
var _loop_2 = function (section) {
|
|
7855
|
-
var e_3,
|
|
7862
|
+
var e_3, _e;
|
|
7856
7863
|
// TODO: Parse template description (the content out of the codeblock and lists)
|
|
7857
7864
|
var listItems_2 = extractAllListItemsFromMarkdown(section.content);
|
|
7858
|
-
var
|
|
7865
|
+
var _f = extractOneBlockFromMarkdown(section.content), language = _f.language, content = _f.content;
|
|
7859
7866
|
// TODO: [🎾][1] DRY description
|
|
7860
7867
|
var description_1 = section.content;
|
|
7861
7868
|
// Note: Remove codeblocks - TODO: [🎾]
|
|
@@ -7920,14 +7927,14 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7920
7927
|
try {
|
|
7921
7928
|
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
7922
7929
|
for (var commands_1 = (e_3 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
|
|
7923
|
-
var
|
|
7930
|
+
var _g = commands_1_1.value, listItem = _g.listItem, command = _g.command;
|
|
7924
7931
|
_loop_3(listItem, command);
|
|
7925
7932
|
}
|
|
7926
7933
|
}
|
|
7927
7934
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
7928
7935
|
finally {
|
|
7929
7936
|
try {
|
|
7930
|
-
if (commands_1_1 && !commands_1_1.done && (
|
|
7937
|
+
if (commands_1_1 && !commands_1_1.done && (_e = commands_1.return)) _e.call(commands_1);
|
|
7931
7938
|
}
|
|
7932
7939
|
finally { if (e_3) throw e_3.error; }
|
|
7933
7940
|
}
|
|
@@ -9797,12 +9804,9 @@ function $execCommandNormalizeOptions(options) {
|
|
|
9797
9804
|
})
|
|
9798
9805
|
.filter(function (arg) { return arg !== ''; });
|
|
9799
9806
|
if (_.length > 1) {
|
|
9800
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9801
9807
|
_a = __read(_), command = _a[0], args = _a.slice(1);
|
|
9802
9808
|
}
|
|
9803
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9804
9809
|
if (options.args) {
|
|
9805
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9806
9810
|
args = __spreadArray(__spreadArray([], __read(args), false), __read(options.args), false);
|
|
9807
9811
|
}
|
|
9808
9812
|
var humanReadableCommand = !['npx', 'npm'].includes(command) ? command : args[0];
|