@promptbook/website-crawler 0.72.0 → 0.73.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 +33 -245
- 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 +4 -3
- package/umd/index.umd.js +18 -18
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,8 @@ 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
|
|
|
@@ -46,11 +48,9 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
46
48
|
|
|
47
49
|
## 🤍 The Promptbook Whitepaper
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
51
|
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
52
|
|
|
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
|
|
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 resp0nses**. When this happens, you generally have three options:
|
|
54
54
|
|
|
55
55
|
1. **Fine-tune** the model to your specifications or even train your own.
|
|
56
56
|
2. **Prompt-engineer** the prompt to the best shape you can achieve.
|
|
@@ -58,248 +58,38 @@ But often you will struggle with the **limitations of LLMs**, such as **hallucin
|
|
|
58
58
|
|
|
59
59
|
In all of these situations, but especially in 3., the **✨ Promptbook can make your life waaaaaaaaaay easier**.
|
|
60
60
|
|
|
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
|
-
-
|
|
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. For this purpose, it introduces a new language called [the **💙 Book**](https://github.com/webgptorg/book).
|
|
62
|
+
- Book allows you to **focus on the business** logic without having to write code or deal with the technicalities of LLMs.
|
|
63
|
+
- **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.
|
|
64
|
+
- 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
65
|
- 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
|
-
- Multiple pipelines forms a **collection** which will handle core **know-how of your LLM application**.
|
|
76
|
-
- Theese pipelines are designed such as they **can be written by non-programmers**.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
### Sample:
|
|
81
|
-
|
|
82
|
-
File `write-website-content.ptbk.md`:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
> # 🌍 Create website content
|
|
89
|
-
>
|
|
90
|
-
> Instructions for creating web page content.
|
|
91
|
-
>
|
|
92
|
-
> - PIPELINE URL https://promptbook.studio/webgpt/write-website-content.ptbk.md
|
|
93
|
-
> - INPUT PARAM `{rawTitle}` Automatically suggested a site name or empty text
|
|
94
|
-
> - INPUT PARAM `{rawAssigment}` Automatically generated site entry from image recognition
|
|
95
|
-
> - OUTPUT PARAM `{websiteContent}` Web content
|
|
96
|
-
> - OUTPUT PARAM `{keywords}` Keywords
|
|
97
|
-
>
|
|
98
|
-
> ## 👤 Specifying the assigment
|
|
99
|
-
>
|
|
100
|
-
> What is your web about?
|
|
101
|
-
>
|
|
102
|
-
> - DIALOG TEMPLATE
|
|
103
|
-
>
|
|
104
|
-
> ```
|
|
105
|
-
> {rawAssigment}
|
|
106
|
-
> ```
|
|
107
|
-
>
|
|
108
|
-
> `-> {assigment}` Website assignment and specification
|
|
109
|
-
>
|
|
110
|
-
> ## ✨ Improving the title
|
|
111
|
-
>
|
|
112
|
-
> - PERSONA Jane, Copywriter and Marketing Specialist.
|
|
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
|
-
```
|
|
66
|
+
- Versioning is build in. You can test multiple **A/B versions** of pipelines and see which one works best.
|
|
67
|
+
- 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.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## 💙 Book language _(for prompt-engineer)_
|
|
72
|
+
|
|
73
|
+
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.
|
|
296
74
|
|
|
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
75
|
|
|
300
|
-
_Note: We are using [postprocessing functions](#postprocessing-functions) like `unwrapResult` that can be used to postprocess the result._
|
|
301
76
|
|
|
302
|
-
|
|
77
|
+
```markdown
|
|
78
|
+
# 🌟 My first Book
|
|
79
|
+
|
|
80
|
+
- PERSONA Jane, marketing specialist with prior experience in writing articles about technology and artificial intelligence
|
|
81
|
+
- KNOWLEDGE https://ptbk.io
|
|
82
|
+
- KNOWLEDGE ./promptbook.pdf
|
|
83
|
+
- EXPECT MIN 1 Sentence
|
|
84
|
+
- EXPECT MAX 1 Paragraph
|
|
85
|
+
|
|
86
|
+
> 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.
|
|
87
|
+
> Look specifically at the impact of Promptbook on the AI industry.
|
|
88
|
+
|
|
89
|
+
-> {article}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 📦 Packages _(for developers)_
|
|
303
93
|
|
|
304
94
|
This library is divided into several packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
305
95
|
You can install all of them at once:
|
|
@@ -341,8 +131,6 @@ Or you can install them separately:
|
|
|
341
131
|
|
|
342
132
|
The following glossary is used to clarify certain concepts:
|
|
343
133
|
|
|
344
|
-
|
|
345
|
-
|
|
346
134
|
### Core concepts
|
|
347
135
|
|
|
348
136
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
|
@@ -373,8 +161,8 @@ The following glossary is used to clarify certain concepts:
|
|
|
373
161
|
|
|
374
162
|
## 🔌 Usage in Typescript / Javascript
|
|
375
163
|
|
|
376
|
-
- [Simple usage](./
|
|
377
|
-
- [Usage with client and remote server](./
|
|
164
|
+
- [Simple usage](./examples/usage/simple-script)
|
|
165
|
+
- [Usage with client and remote server](./examples/usage/remote)
|
|
378
166
|
|
|
379
167
|
## ➕➖ When to use Promptbook?
|
|
380
168
|
|
package/esm/index.es.js
CHANGED
|
@@ -16,7 +16,7 @@ import { Converter } from 'showdown';
|
|
|
16
16
|
/**
|
|
17
17
|
* The version of the Promptbook library
|
|
18
18
|
*/
|
|
19
|
-
var PROMPTBOOK_VERSION = '0.72.0
|
|
19
|
+
var PROMPTBOOK_VERSION = '0.72.0';
|
|
20
20
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
21
21
|
|
|
22
22
|
/*! *****************************************************************************
|
|
@@ -406,10 +406,10 @@ var RESERVED_PARAMETER_NAMES = $asDeeplyFrozenSerializableJson('RESERVED_PARAMET
|
|
|
406
406
|
'content',
|
|
407
407
|
'context',
|
|
408
408
|
'knowledge',
|
|
409
|
-
'
|
|
409
|
+
'examples',
|
|
410
410
|
'modelName',
|
|
411
411
|
'currentDate',
|
|
412
|
-
// <- TODO:
|
|
412
|
+
// <- TODO: list here all command names
|
|
413
413
|
// <- TODO: Add more like 'date', 'modelName',...
|
|
414
414
|
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
415
415
|
]);
|
|
@@ -1193,7 +1193,7 @@ function getScraperIntermediateSource(source, options) {
|
|
|
1193
1193
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
1194
1194
|
*/
|
|
1195
1195
|
|
|
1196
|
-
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##
|
|
1196
|
+
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"}];
|
|
1197
1197
|
|
|
1198
1198
|
/**
|
|
1199
1199
|
* Prettify the html code
|
|
@@ -1837,7 +1837,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1837
1837
|
}
|
|
1838
1838
|
}
|
|
1839
1839
|
/**
|
|
1840
|
-
* TODO:
|
|
1840
|
+
* TODO: !! [🧞♀️] Do not allow joker + foreach
|
|
1841
1841
|
* TODO: [🧠] Work with promptbookVersion
|
|
1842
1842
|
* TODO: Use here some json-schema, Zod or something similar and change it to:
|
|
1843
1843
|
* > /**
|
|
@@ -1849,7 +1849,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1849
1849
|
* > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
|
|
1850
1850
|
*/
|
|
1851
1851
|
/**
|
|
1852
|
-
* TODO: [🧳][main] !!!! Validate that all
|
|
1852
|
+
* TODO: [🧳][main] !!!! Validate that all examples match expectations
|
|
1853
1853
|
* TODO: [🧳][🐝][main] !!!! Validate that knowledge is valid (non-void)
|
|
1854
1854
|
* TODO: [🧳][main] !!!! Validate that persona can be used only with CHAT variant
|
|
1855
1855
|
* TODO: [🧳][main] !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
|
|
@@ -2219,12 +2219,12 @@ function isPipelinePrepared(pipeline) {
|
|
|
2219
2219
|
return true;
|
|
2220
2220
|
}
|
|
2221
2221
|
/**
|
|
2222
|
-
* TODO: [🔃][main]
|
|
2222
|
+
* TODO: [🔃][main] !! If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
2223
2223
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
2224
2224
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2225
2225
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2226
2226
|
* - [🏍] ? Is context in each template
|
|
2227
|
-
* - [♨] Are
|
|
2227
|
+
* - [♨] Are examples prepared
|
|
2228
2228
|
* - [♨] Are templates prepared
|
|
2229
2229
|
*/
|
|
2230
2230
|
|
|
@@ -2929,7 +2929,7 @@ function preparePersona(personaDescription, tools, options) {
|
|
|
2929
2929
|
});
|
|
2930
2930
|
}
|
|
2931
2931
|
/**
|
|
2932
|
-
* TODO: [🔃][main]
|
|
2932
|
+
* TODO: [🔃][main] !! If the persona was prepared with different version or different set of models, prepare it once again
|
|
2933
2933
|
* TODO: [🏢] !! Check validity of `modelName` in pipeline
|
|
2934
2934
|
* TODO: [🏢] !! Check validity of `systemMessage` in pipeline
|
|
2935
2935
|
* TODO: [🏢] !! Check validity of `temperature` in pipeline
|
|
@@ -3428,7 +3428,7 @@ function prepareTemplates(pipeline, tools, options) {
|
|
|
3428
3428
|
case 0:
|
|
3429
3429
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
3430
3430
|
templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
3431
|
-
// TODO: [main]
|
|
3431
|
+
// TODO: [main] !! Apply examples to each template (if missing and is for the template defined)
|
|
3432
3432
|
TODO_USE(parameters);
|
|
3433
3433
|
templatesPrepared = new Array(templates.length);
|
|
3434
3434
|
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 () {
|
|
@@ -3458,7 +3458,7 @@ function prepareTemplates(pipeline, tools, options) {
|
|
|
3458
3458
|
/**
|
|
3459
3459
|
* TODO: [🧠] Add context to each template (if missing)
|
|
3460
3460
|
* TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
|
|
3461
|
-
* TODO: [♨][main] !!! Prepare index the
|
|
3461
|
+
* TODO: [♨][main] !!! Prepare index the examples and maybe templates
|
|
3462
3462
|
* TODO: Write tests for `preparePipeline`
|
|
3463
3463
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
3464
3464
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
@@ -4988,7 +4988,7 @@ function getKnowledgeForTemplate(options) {
|
|
|
4988
4988
|
var preparedPipeline, template;
|
|
4989
4989
|
return __generator(this, function (_a) {
|
|
4990
4990
|
preparedPipeline = options.preparedPipeline, template = options.template;
|
|
4991
|
-
// TODO: [♨] Implement Better - use real index and keyword search from `template` and {
|
|
4991
|
+
// TODO: [♨] Implement Better - use real index and keyword search from `template` and {examples}
|
|
4992
4992
|
TODO_USE(template);
|
|
4993
4993
|
return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
|
|
4994
4994
|
var content = _a.content;
|
|
@@ -5003,7 +5003,7 @@ function getKnowledgeForTemplate(options) {
|
|
|
5003
5003
|
*
|
|
5004
5004
|
* @private internal utility of `createPipelineExecutor`
|
|
5005
5005
|
*/
|
|
5006
|
-
function
|
|
5006
|
+
function getExamplesForTemplate(template) {
|
|
5007
5007
|
return __awaiter(this, void 0, void 0, function () {
|
|
5008
5008
|
return __generator(this, function (_a) {
|
|
5009
5009
|
// TODO: [♨] Implement Better - use real index and keyword search
|
|
@@ -5020,7 +5020,7 @@ function getSamplesForTemplate(template) {
|
|
|
5020
5020
|
*/
|
|
5021
5021
|
function getReservedParametersForTemplate(options) {
|
|
5022
5022
|
return __awaiter(this, void 0, void 0, function () {
|
|
5023
|
-
var preparedPipeline, template, pipelineIdentification, context, knowledge,
|
|
5023
|
+
var preparedPipeline, template, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
|
|
5024
5024
|
var e_1, _a;
|
|
5025
5025
|
return __generator(this, function (_b) {
|
|
5026
5026
|
switch (_b.label) {
|
|
@@ -5032,16 +5032,16 @@ function getReservedParametersForTemplate(options) {
|
|
|
5032
5032
|
return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
|
|
5033
5033
|
case 2:
|
|
5034
5034
|
knowledge = _b.sent();
|
|
5035
|
-
return [4 /*yield*/,
|
|
5035
|
+
return [4 /*yield*/, getExamplesForTemplate(template)];
|
|
5036
5036
|
case 3:
|
|
5037
|
-
|
|
5037
|
+
examples = _b.sent();
|
|
5038
5038
|
currentDate = new Date().toISOString();
|
|
5039
5039
|
modelName = RESERVED_PARAMETER_MISSING_VALUE;
|
|
5040
5040
|
reservedParameters = {
|
|
5041
5041
|
content: RESERVED_PARAMETER_RESTRICTED,
|
|
5042
5042
|
context: context,
|
|
5043
5043
|
knowledge: knowledge,
|
|
5044
|
-
|
|
5044
|
+
examples: examples,
|
|
5045
5045
|
currentDate: currentDate,
|
|
5046
5046
|
modelName: modelName,
|
|
5047
5047
|
};
|
|
@@ -5700,7 +5700,7 @@ var MarkdownScraper = /** @class */ (function () {
|
|
|
5700
5700
|
outputParameters = result.outputParameters;
|
|
5701
5701
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
5702
5702
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
5703
|
-
// <- TODO: [main]
|
|
5703
|
+
// <- TODO: [main] !! Smarter split and filter out empty pieces
|
|
5704
5704
|
if (isVerbose) {
|
|
5705
5705
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
5706
5706
|
}
|