@promptbook/markdown-utils 0.72.0 → 0.74.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 +88 -241
- package/esm/index.es.js +18 -18
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/commands/TEMPLATE/TemplateTypes.d.ts +1 -1
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
- package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +1 -1
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -2
- package/esm/typings/src/execution/createPipelineExecutor/{getSamplesForTemplate.d.ts → getExamplesForTemplate.d.ts} +1 -1
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +2 -2
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +1 -1
- package/esm/typings/src/personas/preparePersona.d.ts +1 -1
- package/esm/typings/src/prepare/isPipelinePrepared.d.ts +2 -2
- package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
- package/esm/typings/src/scrapers/document/DocumentScraper.test.d.ts +1 -1
- package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.test.d.ts +1 -1
- package/esm/typings/src/scrapers/markdown/MarkdownScraper.test.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +2 -2
- package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
- package/package.json +3 -2
- package/umd/index.umd.js +18 -18
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -18,10 +18,16 @@ Build responsible, controlled and transparent applications on top of LLM models!
|
|
|
18
18
|
|
|
19
19
|
## ✨ New Features
|
|
20
20
|
|
|
21
|
+
- 💙 Working on [the **Book** language v1](https://github.com/webgptorg/book)
|
|
22
|
+
- 📚 Support of `.docx`, `.doc` and `.pdf` documents
|
|
21
23
|
- ✨ **Support of [OpenAI o1 model](https://openai.com/o1/)**
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
|
|
27
|
+
<blockquote style="color: #ff8811">
|
|
28
|
+
<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>.
|
|
29
|
+
</blockquote>
|
|
30
|
+
|
|
25
31
|
## 📦 Package `@promptbook/markdown-utils`
|
|
26
32
|
|
|
27
33
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
@@ -50,7 +56,7 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
50
56
|
|
|
51
57
|
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.
|
|
52
58
|
|
|
53
|
-
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
|
|
59
|
+
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:
|
|
54
60
|
|
|
55
61
|
1. **Fine-tune** the model to your specifications or even train your own.
|
|
56
62
|
2. **Prompt-engineer** the prompt to the best shape you can achieve.
|
|
@@ -58,248 +64,87 @@ But often you will struggle with the **limitations of LLMs**, such as **hallucin
|
|
|
58
64
|
|
|
59
65
|
In all of these situations, but especially in 3., the **✨ Promptbook can make your life waaaaaaaaaay easier**.
|
|
60
66
|
|
|
61
|
-
- [**Separates concerns**](https://github.com/webgptorg/promptbook/discussions/32) between prompt-engineer and programmer, between code files and prompt files, and between prompts and their execution logic.
|
|
62
|
-
-
|
|
63
|
-
- **Forget** about **low-level details** like choosing the right model, tokens, context size, temperature
|
|
64
|
-
-
|
|
67
|
+
- [**Separates concerns**](https://github.com/webgptorg/promptbook/discussions/32) between prompt-engineer and programmer, between code files and prompt files, and between prompts and their execution logic. For this purpose, it introduces a new language called [the **💙 Book**](https://github.com/webgptorg/book).
|
|
68
|
+
- Book allows you to **focus on the business** logic without having to write code or deal with the technicalities of LLMs.
|
|
69
|
+
- **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.
|
|
70
|
+
- 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.
|
|
65
71
|
- 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.
|
|
66
|
-
-
|
|
67
|
-
- Promptbook is designed to
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
##
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
>
|
|
89
|
-
|
|
90
|
-
>
|
|
91
|
-
>
|
|
92
|
-
>
|
|
93
|
-
>
|
|
94
|
-
>
|
|
95
|
-
>
|
|
96
|
-
>
|
|
97
|
-
>
|
|
98
|
-
>
|
|
99
|
-
>
|
|
100
|
-
>
|
|
101
|
-
>
|
|
102
|
-
>
|
|
103
|
-
>
|
|
104
|
-
>
|
|
105
|
-
>
|
|
106
|
-
>
|
|
107
|
-
>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
>
|
|
114
|
-
> ```
|
|
115
|
-
> As an experienced marketing specialist, you have been entrusted with improving the name of your client's business.
|
|
116
|
-
>
|
|
117
|
-
> A suggested name from a client:
|
|
118
|
-
> "{rawTitle}"
|
|
119
|
-
>
|
|
120
|
-
> Assignment from customer:
|
|
121
|
-
>
|
|
122
|
-
> > {assigment}
|
|
123
|
-
>
|
|
124
|
-
> ## Instructions:
|
|
125
|
-
>
|
|
126
|
-
> - Write only one name suggestion
|
|
127
|
-
> - The name will be used on the website, business cards, visuals, etc.
|
|
128
|
-
> ```
|
|
129
|
-
>
|
|
130
|
-
> `-> {enhancedTitle}` Enhanced title
|
|
131
|
-
>
|
|
132
|
-
> ## 👤 Website title approval
|
|
133
|
-
>
|
|
134
|
-
> Is the title for your website okay?
|
|
135
|
-
>
|
|
136
|
-
> - DIALOG TEMPLATE
|
|
137
|
-
>
|
|
138
|
-
> ```
|
|
139
|
-
> {enhancedTitle}
|
|
140
|
-
> ```
|
|
141
|
-
>
|
|
142
|
-
> `-> {title}` Title for the website
|
|
143
|
-
>
|
|
144
|
-
> ## 🐰 Cunning subtitle
|
|
145
|
-
>
|
|
146
|
-
> - PERSONA Josh, a copywriter, tasked with creating a claim for the website.
|
|
147
|
-
>
|
|
148
|
-
> ```
|
|
149
|
-
> As an experienced copywriter, you have been entrusted with creating a claim for the "{title}" web page.
|
|
150
|
-
>
|
|
151
|
-
> A website assignment from a customer:
|
|
152
|
-
>
|
|
153
|
-
> > {assigment}
|
|
154
|
-
>
|
|
155
|
-
> ## Instructions:
|
|
156
|
-
>
|
|
157
|
-
> - Write only one name suggestion
|
|
158
|
-
> - Claim will be used on website, business cards, visuals, etc.
|
|
159
|
-
> - Claim should be punchy, funny, original
|
|
160
|
-
> ```
|
|
161
|
-
>
|
|
162
|
-
> `-> {claim}` Claim for the web
|
|
163
|
-
>
|
|
164
|
-
> ## 🚦 Keyword analysis
|
|
165
|
-
>
|
|
166
|
-
> - PERSONA Paul, extremely creative SEO specialist.
|
|
167
|
-
>
|
|
168
|
-
> ```
|
|
169
|
-
> As an experienced SEO specialist, you have been entrusted with creating keywords for the website "{title}".
|
|
170
|
-
>
|
|
171
|
-
> Website assignment from the customer:
|
|
172
|
-
>
|
|
173
|
-
> > {assigment}
|
|
174
|
-
>
|
|
175
|
-
> ## Instructions:
|
|
176
|
-
>
|
|
177
|
-
> - Write a list of keywords
|
|
178
|
-
> - Keywords are in basic form
|
|
179
|
-
>
|
|
180
|
-
> ## Example:
|
|
181
|
-
>
|
|
182
|
-
> - Ice cream
|
|
183
|
-
> - Olomouc
|
|
184
|
-
> - Quality
|
|
185
|
-
> - Family
|
|
186
|
-
> - Tradition
|
|
187
|
-
> - Italy
|
|
188
|
-
> - Craft
|
|
189
|
-
>
|
|
190
|
-
> ```
|
|
191
|
-
>
|
|
192
|
-
> `-> {keywords}` Keywords
|
|
193
|
-
>
|
|
194
|
-
> ## 🔗 Combine the beginning
|
|
195
|
-
>
|
|
196
|
-
> - SIMPLE TEMPLATE
|
|
197
|
-
>
|
|
198
|
-
> ```
|
|
199
|
-
>
|
|
200
|
-
> # {title}
|
|
201
|
-
>
|
|
202
|
-
> > {claim}
|
|
203
|
-
>
|
|
204
|
-
> ```
|
|
205
|
-
>
|
|
206
|
-
> `-> {contentBeginning}` Beginning of web content
|
|
207
|
-
>
|
|
208
|
-
> ## 🖋 Write the content
|
|
209
|
-
>
|
|
210
|
-
> - PERSONA Jane
|
|
211
|
-
>
|
|
212
|
-
> ```
|
|
213
|
-
> As an experienced copywriter and web designer, you have been entrusted with creating text for a new website {title}.
|
|
214
|
-
>
|
|
215
|
-
> A website assignment from a customer:
|
|
216
|
-
>
|
|
217
|
-
> > {assigment}
|
|
218
|
-
>
|
|
219
|
-
> ## Instructions:
|
|
220
|
-
>
|
|
221
|
-
> - Text formatting is in Markdown
|
|
222
|
-
> - Be concise and to the point
|
|
223
|
-
> - Use keywords, but they should be naturally in the text
|
|
224
|
-
> - This is the complete content of the page, so don't forget all the important information and elements the page should contain
|
|
225
|
-
> - Use headings, bullets, text formatting
|
|
226
|
-
>
|
|
227
|
-
> ## Keywords:
|
|
228
|
-
>
|
|
229
|
-
> {keywords}
|
|
230
|
-
>
|
|
231
|
-
> ## Web Content:
|
|
232
|
-
>
|
|
233
|
-
> {contentBeginning}
|
|
234
|
-
> ```
|
|
235
|
-
>
|
|
236
|
-
> `-> {contentBody}` Middle of the web content
|
|
237
|
-
>
|
|
238
|
-
> ## 🔗 Combine the content
|
|
239
|
-
>
|
|
240
|
-
> - SIMPLE TEMPLATE
|
|
241
|
-
>
|
|
242
|
-
> ```markdown
|
|
243
|
-
> {contentBeginning}
|
|
244
|
-
>
|
|
245
|
-
> {contentBody}
|
|
246
|
-
> ```
|
|
247
|
-
>
|
|
248
|
-
> `-> {websiteContent}`
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
Following is the scheme how the promptbook above is executed:
|
|
253
|
-
|
|
254
|
-
```mermaid
|
|
255
|
-
%% 🔮 Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually
|
|
256
|
-
|
|
257
|
-
flowchart LR
|
|
258
|
-
subgraph "🌍 Create website content"
|
|
259
|
-
|
|
260
|
-
direction TB
|
|
261
|
-
|
|
262
|
-
input((Input)):::input
|
|
263
|
-
templateSpecifyingTheAssigment(👤 Specifying the assigment)
|
|
264
|
-
input--"{rawAssigment}"-->templateSpecifyingTheAssigment
|
|
265
|
-
templateImprovingTheTitle(✨ Improving the title)
|
|
266
|
-
input--"{rawTitle}"-->templateImprovingTheTitle
|
|
267
|
-
templateSpecifyingTheAssigment--"{assigment}"-->templateImprovingTheTitle
|
|
268
|
-
templateWebsiteTitleApproval(👤 Website title approval)
|
|
269
|
-
templateImprovingTheTitle--"{enhancedTitle}"-->templateWebsiteTitleApproval
|
|
270
|
-
templateCunningSubtitle(🐰 Cunning subtitle)
|
|
271
|
-
templateWebsiteTitleApproval--"{title}"-->templateCunningSubtitle
|
|
272
|
-
templateSpecifyingTheAssigment--"{assigment}"-->templateCunningSubtitle
|
|
273
|
-
templateKeywordAnalysis(🚦 Keyword analysis)
|
|
274
|
-
templateWebsiteTitleApproval--"{title}"-->templateKeywordAnalysis
|
|
275
|
-
templateSpecifyingTheAssigment--"{assigment}"-->templateKeywordAnalysis
|
|
276
|
-
templateCombineTheBeginning(🔗 Combine the beginning)
|
|
277
|
-
templateWebsiteTitleApproval--"{title}"-->templateCombineTheBeginning
|
|
278
|
-
templateCunningSubtitle--"{claim}"-->templateCombineTheBeginning
|
|
279
|
-
templateWriteTheContent(🖋 Write the content)
|
|
280
|
-
templateWebsiteTitleApproval--"{title}"-->templateWriteTheContent
|
|
281
|
-
templateSpecifyingTheAssigment--"{assigment}"-->templateWriteTheContent
|
|
282
|
-
templateKeywordAnalysis--"{keywords}"-->templateWriteTheContent
|
|
283
|
-
templateCombineTheBeginning--"{contentBeginning}"-->templateWriteTheContent
|
|
284
|
-
templateCombineTheContent(🔗 Combine the content)
|
|
285
|
-
templateCombineTheBeginning--"{contentBeginning}"-->templateCombineTheContent
|
|
286
|
-
templateWriteTheContent--"{contentBody}"-->templateCombineTheContent
|
|
287
|
-
|
|
288
|
-
templateCombineTheContent--"{websiteContent}"-->output
|
|
289
|
-
output((Output)):::output
|
|
290
|
-
|
|
291
|
-
classDef input color: grey;
|
|
292
|
-
classDef output color: grey;
|
|
293
|
-
|
|
294
|
-
end;
|
|
295
|
-
```
|
|
72
|
+
- Versioning is build in. You can test multiple **A/B versions** of pipelines and see which one works best.
|
|
73
|
+
- 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.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
## 💜 The Promptbook Project
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
<table>
|
|
82
|
+
<tbody>
|
|
83
|
+
<tr>
|
|
84
|
+
<td>Promptbook whitepaper</td>
|
|
85
|
+
<td>Basic motivations and problems which we are trying to solve</td>
|
|
86
|
+
<td rowspan=3>https://github.com/webgptorg/book</td>
|
|
87
|
+
</tr>
|
|
88
|
+
<tr>
|
|
89
|
+
<td>Promptbook <i>(system)</i></td>
|
|
90
|
+
<td>Promptbook ...</td>
|
|
91
|
+
</tr>
|
|
92
|
+
<tr>
|
|
93
|
+
<td>Book language</td>
|
|
94
|
+
<td>
|
|
95
|
+
Book is a markdown-like language to define projects, pipelines, knowledge,... in the Promptbook system. It is designed to be understandable by non-programmers and non-technical people
|
|
96
|
+
</td>
|
|
97
|
+
</tr>
|
|
98
|
+
<tr>
|
|
99
|
+
<td>Promptbook typescript project</td>
|
|
100
|
+
<td>Implementation of Promptbook in TypeScript published into multiple packages to NPM</td>
|
|
101
|
+
<td>https://github.com/webgptorg/promptbook</td>
|
|
102
|
+
</tr>
|
|
103
|
+
<tr>
|
|
104
|
+
<td>Promptbook studio</td>
|
|
105
|
+
<td>Promptbook studio</td>
|
|
106
|
+
<td rowspan=2>https://github.com/hejny/promptbook-studio</td>
|
|
107
|
+
</tr>
|
|
108
|
+
<tr>
|
|
109
|
+
<td>Promptbook miniapps</td>
|
|
110
|
+
<td>Promptbook miniapps</td>
|
|
111
|
+
</tr>
|
|
112
|
+
</tbody>
|
|
113
|
+
</table>
|
|
114
|
+
|
|
115
|
+
## 💙 Book language _(for prompt-engineer)_
|
|
116
|
+
|
|
117
|
+
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.
|
|
118
|
+
|
|
296
119
|
|
|
297
|
-
- [More template samples](./samples/pipelines/)
|
|
298
|
-
- [Read more about `.ptbk.md` file format here](https://github.com/webgptorg/promptbook/discussions/categories/concepts?discussions_q=is%3Aopen+label%3A.ptbk.md+category%3AConcepts)
|
|
299
120
|
|
|
300
|
-
|
|
121
|
+
```markdown
|
|
122
|
+
# 🌟 My first Book
|
|
301
123
|
|
|
302
|
-
|
|
124
|
+
- INPUT PARAMETER {subject}
|
|
125
|
+
- OUTPUT PARAMETER {article}
|
|
126
|
+
|
|
127
|
+
## Sample subject
|
|
128
|
+
|
|
129
|
+
> Promptbook
|
|
130
|
+
|
|
131
|
+
-> {subject}
|
|
132
|
+
|
|
133
|
+
## Write an article
|
|
134
|
+
|
|
135
|
+
- PERSONA Jane, marketing specialist with prior experience in writing articles about technology and artificial intelligence
|
|
136
|
+
- KNOWLEDGE https://ptbk.io
|
|
137
|
+
- KNOWLEDGE ./promptbook.pdf
|
|
138
|
+
- EXPECT MIN 1 Sentence
|
|
139
|
+
- EXPECT MAX 1 Paragraph
|
|
140
|
+
|
|
141
|
+
> 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.
|
|
142
|
+
> Look specifically at the impact of {subject} on the AI industry.
|
|
143
|
+
|
|
144
|
+
-> {article}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 📦 Packages _(for developers)_
|
|
303
148
|
|
|
304
149
|
This library is divided into several packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
305
150
|
You can install all of them at once:
|
|
@@ -341,6 +186,8 @@ Or you can install them separately:
|
|
|
341
186
|
|
|
342
187
|
The following glossary is used to clarify certain concepts:
|
|
343
188
|
|
|
189
|
+
### Basic terms
|
|
190
|
+
|
|
344
191
|
|
|
345
192
|
|
|
346
193
|
### Core concepts
|
|
@@ -373,8 +220,8 @@ The following glossary is used to clarify certain concepts:
|
|
|
373
220
|
|
|
374
221
|
## 🔌 Usage in Typescript / Javascript
|
|
375
222
|
|
|
376
|
-
- [Simple usage](./
|
|
377
|
-
- [Usage with client and remote server](./
|
|
223
|
+
- [Simple usage](./examples/usage/simple-script)
|
|
224
|
+
- [Usage with client and remote server](./examples/usage/remote)
|
|
378
225
|
|
|
379
226
|
## ➕➖ When to use Promptbook?
|
|
380
227
|
|
package/esm/index.es.js
CHANGED
|
@@ -12,7 +12,7 @@ import { unparse, parse } from 'papaparse';
|
|
|
12
12
|
/**
|
|
13
13
|
* The version of the Promptbook library
|
|
14
14
|
*/
|
|
15
|
-
var PROMPTBOOK_VERSION = '0.
|
|
15
|
+
var PROMPTBOOK_VERSION = '0.73.0';
|
|
16
16
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
17
17
|
|
|
18
18
|
/*! *****************************************************************************
|
|
@@ -362,7 +362,7 @@ function TODO_USE() {
|
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n##
|
|
365
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
366
366
|
|
|
367
367
|
/**
|
|
368
368
|
* Prettify the html code
|
|
@@ -861,10 +861,10 @@ var RESERVED_PARAMETER_NAMES = $asDeeplyFrozenSerializableJson('RESERVED_PARAMET
|
|
|
861
861
|
'content',
|
|
862
862
|
'context',
|
|
863
863
|
'knowledge',
|
|
864
|
-
'
|
|
864
|
+
'examples',
|
|
865
865
|
'modelName',
|
|
866
866
|
'currentDate',
|
|
867
|
-
// <- TODO:
|
|
867
|
+
// <- TODO: list here all command names
|
|
868
868
|
// <- TODO: Add more like 'date', 'modelName',...
|
|
869
869
|
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
870
870
|
]);
|
|
@@ -1317,7 +1317,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1317
1317
|
}
|
|
1318
1318
|
}
|
|
1319
1319
|
/**
|
|
1320
|
-
* TODO:
|
|
1320
|
+
* TODO: !! [🧞♀️] Do not allow joker + foreach
|
|
1321
1321
|
* TODO: [🧠] Work with promptbookVersion
|
|
1322
1322
|
* TODO: Use here some json-schema, Zod or something similar and change it to:
|
|
1323
1323
|
* > /**
|
|
@@ -1329,7 +1329,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1329
1329
|
* > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
|
|
1330
1330
|
*/
|
|
1331
1331
|
/**
|
|
1332
|
-
* TODO: [🧳][main] !!!! Validate that all
|
|
1332
|
+
* TODO: [🧳][main] !!!! Validate that all examples match expectations
|
|
1333
1333
|
* TODO: [🧳][🐝][main] !!!! Validate that knowledge is valid (non-void)
|
|
1334
1334
|
* TODO: [🧳][main] !!!! Validate that persona can be used only with CHAT variant
|
|
1335
1335
|
* TODO: [🧳][main] !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
|
|
@@ -2117,12 +2117,12 @@ function isPipelinePrepared(pipeline) {
|
|
|
2117
2117
|
return true;
|
|
2118
2118
|
}
|
|
2119
2119
|
/**
|
|
2120
|
-
* TODO: [🔃][main]
|
|
2120
|
+
* TODO: [🔃][main] !! If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
2121
2121
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
2122
2122
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2123
2123
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2124
2124
|
* - [🏍] ? Is context in each template
|
|
2125
|
-
* - [♨] Are
|
|
2125
|
+
* - [♨] Are examples prepared
|
|
2126
2126
|
* - [♨] Are templates prepared
|
|
2127
2127
|
*/
|
|
2128
2128
|
|
|
@@ -2827,7 +2827,7 @@ function preparePersona(personaDescription, tools, options) {
|
|
|
2827
2827
|
});
|
|
2828
2828
|
}
|
|
2829
2829
|
/**
|
|
2830
|
-
* TODO: [🔃][main]
|
|
2830
|
+
* TODO: [🔃][main] !! If the persona was prepared with different version or different set of models, prepare it once again
|
|
2831
2831
|
* TODO: [🏢] !! Check validity of `modelName` in pipeline
|
|
2832
2832
|
* TODO: [🏢] !! Check validity of `systemMessage` in pipeline
|
|
2833
2833
|
* TODO: [🏢] !! Check validity of `temperature` in pipeline
|
|
@@ -3493,7 +3493,7 @@ function prepareTemplates(pipeline, tools, options) {
|
|
|
3493
3493
|
case 0:
|
|
3494
3494
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
3495
3495
|
templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
3496
|
-
// TODO: [main]
|
|
3496
|
+
// TODO: [main] !! Apply examples to each template (if missing and is for the template defined)
|
|
3497
3497
|
TODO_USE(parameters);
|
|
3498
3498
|
templatesPrepared = new Array(templates.length);
|
|
3499
3499
|
return [4 /*yield*/, forEachAsync(templates, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -3523,7 +3523,7 @@ function prepareTemplates(pipeline, tools, options) {
|
|
|
3523
3523
|
/**
|
|
3524
3524
|
* TODO: [🧠] Add context to each template (if missing)
|
|
3525
3525
|
* TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
|
|
3526
|
-
* TODO: [♨][main] !!! Prepare index the
|
|
3526
|
+
* TODO: [♨][main] !!! Prepare index the examples and maybe templates
|
|
3527
3527
|
* TODO: Write tests for `preparePipeline`
|
|
3528
3528
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
3529
3529
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
@@ -4916,7 +4916,7 @@ function getKnowledgeForTemplate(options) {
|
|
|
4916
4916
|
var preparedPipeline, template;
|
|
4917
4917
|
return __generator(this, function (_a) {
|
|
4918
4918
|
preparedPipeline = options.preparedPipeline, template = options.template;
|
|
4919
|
-
// TODO: [♨] Implement Better - use real index and keyword search from `template` and {
|
|
4919
|
+
// TODO: [♨] Implement Better - use real index and keyword search from `template` and {examples}
|
|
4920
4920
|
TODO_USE(template);
|
|
4921
4921
|
return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
|
|
4922
4922
|
var content = _a.content;
|
|
@@ -4931,7 +4931,7 @@ function getKnowledgeForTemplate(options) {
|
|
|
4931
4931
|
*
|
|
4932
4932
|
* @private internal utility of `createPipelineExecutor`
|
|
4933
4933
|
*/
|
|
4934
|
-
function
|
|
4934
|
+
function getExamplesForTemplate(template) {
|
|
4935
4935
|
return __awaiter(this, void 0, void 0, function () {
|
|
4936
4936
|
return __generator(this, function (_a) {
|
|
4937
4937
|
// TODO: [♨] Implement Better - use real index and keyword search
|
|
@@ -4948,7 +4948,7 @@ function getSamplesForTemplate(template) {
|
|
|
4948
4948
|
*/
|
|
4949
4949
|
function getReservedParametersForTemplate(options) {
|
|
4950
4950
|
return __awaiter(this, void 0, void 0, function () {
|
|
4951
|
-
var preparedPipeline, template, pipelineIdentification, context, knowledge,
|
|
4951
|
+
var preparedPipeline, template, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
|
|
4952
4952
|
var e_1, _a;
|
|
4953
4953
|
return __generator(this, function (_b) {
|
|
4954
4954
|
switch (_b.label) {
|
|
@@ -4960,16 +4960,16 @@ function getReservedParametersForTemplate(options) {
|
|
|
4960
4960
|
return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
|
|
4961
4961
|
case 2:
|
|
4962
4962
|
knowledge = _b.sent();
|
|
4963
|
-
return [4 /*yield*/,
|
|
4963
|
+
return [4 /*yield*/, getExamplesForTemplate(template)];
|
|
4964
4964
|
case 3:
|
|
4965
|
-
|
|
4965
|
+
examples = _b.sent();
|
|
4966
4966
|
currentDate = new Date().toISOString();
|
|
4967
4967
|
modelName = RESERVED_PARAMETER_MISSING_VALUE;
|
|
4968
4968
|
reservedParameters = {
|
|
4969
4969
|
content: RESERVED_PARAMETER_RESTRICTED,
|
|
4970
4970
|
context: context,
|
|
4971
4971
|
knowledge: knowledge,
|
|
4972
|
-
|
|
4972
|
+
examples: examples,
|
|
4973
4973
|
currentDate: currentDate,
|
|
4974
4974
|
modelName: modelName,
|
|
4975
4975
|
};
|
|
@@ -5628,7 +5628,7 @@ var MarkdownScraper = /** @class */ (function () {
|
|
|
5628
5628
|
outputParameters = result.outputParameters;
|
|
5629
5629
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
5630
5630
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
5631
|
-
// <- TODO: [main]
|
|
5631
|
+
// <- TODO: [main] !! Smarter split and filter out empty pieces
|
|
5632
5632
|
if (isVerbose) {
|
|
5633
5633
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
5634
5634
|
}
|