@promptbook/utils 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 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
 
@@ -167,11 +169,9 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
167
169
 
168
170
  ## 🤍 The Promptbook Whitepaper
169
171
 
170
-
171
-
172
172
  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.
173
173
 
174
- 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 responses**. When this happens, you generally have three options:
174
+ 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:
175
175
 
176
176
  1. **Fine-tune** the model to your specifications or even train your own.
177
177
  2. **Prompt-engineer** the prompt to the best shape you can achieve.
@@ -179,248 +179,38 @@ But often you will struggle with the **limitations of LLMs**, such as **hallucin
179
179
 
180
180
  In all of these situations, but especially in 3., the **✨ Promptbook can make your life waaaaaaaaaay easier**.
181
181
 
182
- - [**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.
183
- - Establishes a [**common format `.ptbk.md`**](https://github.com/webgptorg/promptbook/discussions/85) that can be used to describe your prompt business logic without having to write code or deal with the technicalities of LLMs.
184
- - **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.
185
- - Has 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.
182
+ - [**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).
183
+ - Book allows you to **focus on the business** logic without having to write code or deal with the technicalities of LLMs.
184
+ - **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.
185
+ - 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.
186
186
  - 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.
187
- - Promptbook has built in versioning. You can test multiple **A/B versions** of pipelines and see which one works best.
188
- - Promptbook is designed to do [**RAG** (Retrieval-Augmented Generation)](https://github.com/webgptorg/promptbook/discussions/41) and other advanced techniques. You can use **knowledge** to improve the quality of the output.
189
-
190
-
191
-
192
- ## 🧔 Pipeline _(for prompt-engeneers)_
193
-
194
- **P**romp**t** **b**oo**k** markdown file (or `.ptbk.md` file) is document that describes a **pipeline** - a series of prompts that are chained together to form somewhat reciepe for transforming natural language input.
195
-
196
- - Multiple pipelines forms a **collection** which will handle core **know-how of your LLM application**.
197
- - Theese pipelines are designed such as they **can be written by non-programmers**.
198
-
199
-
200
-
201
- ### Sample:
202
-
203
- File `write-website-content.ptbk.md`:
204
-
205
-
206
-
207
-
208
-
209
- > # 🌍 Create website content
210
- >
211
- > Instructions for creating web page content.
212
- >
213
- > - PIPELINE URL https://promptbook.studio/webgpt/write-website-content.ptbk.md
214
- > - INPUT  PARAM `{rawTitle}` Automatically suggested a site name or empty text
215
- > - INPUT  PARAM `{rawAssigment}` Automatically generated site entry from image recognition
216
- > - OUTPUT PARAM `{websiteContent}` Web content
217
- > - OUTPUT PARAM `{keywords}` Keywords
218
- >
219
- > ## 👤 Specifying the assigment
220
- >
221
- > What is your web about?
222
- >
223
- > - DIALOG TEMPLATE
224
- >
225
- > ```
226
- > {rawAssigment}
227
- > ```
228
- >
229
- > `-> {assigment}` Website assignment and specification
230
- >
231
- > ## ✨ Improving the title
232
- >
233
- > - PERSONA Jane, Copywriter and Marketing Specialist.
234
- >
235
- > ```
236
- > As an experienced marketing specialist, you have been entrusted with improving the name of your client's business.
237
- >
238
- > A suggested name from a client:
239
- > "{rawTitle}"
240
- >
241
- > Assignment from customer:
242
- >
243
- > > {assigment}
244
- >
245
- > ## Instructions:
246
- >
247
- > - Write only one name suggestion
248
- > - The name will be used on the website, business cards, visuals, etc.
249
- > ```
250
- >
251
- > `-> {enhancedTitle}` Enhanced title
252
- >
253
- > ## 👤 Website title approval
254
- >
255
- > Is the title for your website okay?
256
- >
257
- > - DIALOG TEMPLATE
258
- >
259
- > ```
260
- > {enhancedTitle}
261
- > ```
262
- >
263
- > `-> {title}` Title for the website
264
- >
265
- > ## 🐰 Cunning subtitle
266
- >
267
- > - PERSONA Josh, a copywriter, tasked with creating a claim for the website.
268
- >
269
- > ```
270
- > As an experienced copywriter, you have been entrusted with creating a claim for the "{title}" web page.
271
- >
272
- > A website assignment from a customer:
273
- >
274
- > > {assigment}
275
- >
276
- > ## Instructions:
277
- >
278
- > - Write only one name suggestion
279
- > - Claim will be used on website, business cards, visuals, etc.
280
- > - Claim should be punchy, funny, original
281
- > ```
282
- >
283
- > `-> {claim}` Claim for the web
284
- >
285
- > ## 🚦 Keyword analysis
286
- >
287
- > - PERSONA Paul, extremely creative SEO specialist.
288
- >
289
- > ```
290
- > As an experienced SEO specialist, you have been entrusted with creating keywords for the website "{title}".
291
- >
292
- > Website assignment from the customer:
293
- >
294
- > > {assigment}
295
- >
296
- > ## Instructions:
297
- >
298
- > - Write a list of keywords
299
- > - Keywords are in basic form
300
- >
301
- > ## Example:
302
- >
303
- > - Ice cream
304
- > - Olomouc
305
- > - Quality
306
- > - Family
307
- > - Tradition
308
- > - Italy
309
- > - Craft
310
- >
311
- > ```
312
- >
313
- > `-> {keywords}` Keywords
314
- >
315
- > ## 🔗 Combine the beginning
316
- >
317
- > - SIMPLE TEMPLATE
318
- >
319
- > ```
320
- >
321
- > # {title}
322
- >
323
- > > {claim}
324
- >
325
- > ```
326
- >
327
- > `-> {contentBeginning}` Beginning of web content
328
- >
329
- > ## 🖋 Write the content
330
- >
331
- > - PERSONA Jane
332
- >
333
- > ```
334
- > As an experienced copywriter and web designer, you have been entrusted with creating text for a new website {title}.
335
- >
336
- > A website assignment from a customer:
337
- >
338
- > > {assigment}
339
- >
340
- > ## Instructions:
341
- >
342
- > - Text formatting is in Markdown
343
- > - Be concise and to the point
344
- > - Use keywords, but they should be naturally in the text
345
- > - This is the complete content of the page, so don't forget all the important information and elements the page should contain
346
- > - Use headings, bullets, text formatting
347
- >
348
- > ## Keywords:
349
- >
350
- > {keywords}
351
- >
352
- > ## Web Content:
353
- >
354
- > {contentBeginning}
355
- > ```
356
- >
357
- > `-> {contentBody}` Middle of the web content
358
- >
359
- > ## 🔗 Combine the content
360
- >
361
- > - SIMPLE TEMPLATE
362
- >
363
- > ```markdown
364
- > {contentBeginning}
365
- >
366
- > {contentBody}
367
- > ```
368
- >
369
- > `-> {websiteContent}`
370
-
371
-
372
-
373
- Following is the scheme how the promptbook above is executed:
374
-
375
- ```mermaid
376
- %% 🔮 Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually
377
-
378
- flowchart LR
379
- subgraph "🌍 Create website content"
380
-
381
- direction TB
382
-
383
- input((Input)):::input
384
- templateSpecifyingTheAssigment(👤 Specifying the assigment)
385
- input--"{rawAssigment}"-->templateSpecifyingTheAssigment
386
- templateImprovingTheTitle(✨ Improving the title)
387
- input--"{rawTitle}"-->templateImprovingTheTitle
388
- templateSpecifyingTheAssigment--"{assigment}"-->templateImprovingTheTitle
389
- templateWebsiteTitleApproval(👤 Website title approval)
390
- templateImprovingTheTitle--"{enhancedTitle}"-->templateWebsiteTitleApproval
391
- templateCunningSubtitle(🐰 Cunning subtitle)
392
- templateWebsiteTitleApproval--"{title}"-->templateCunningSubtitle
393
- templateSpecifyingTheAssigment--"{assigment}"-->templateCunningSubtitle
394
- templateKeywordAnalysis(🚦 Keyword analysis)
395
- templateWebsiteTitleApproval--"{title}"-->templateKeywordAnalysis
396
- templateSpecifyingTheAssigment--"{assigment}"-->templateKeywordAnalysis
397
- templateCombineTheBeginning(🔗 Combine the beginning)
398
- templateWebsiteTitleApproval--"{title}"-->templateCombineTheBeginning
399
- templateCunningSubtitle--"{claim}"-->templateCombineTheBeginning
400
- templateWriteTheContent(🖋 Write the content)
401
- templateWebsiteTitleApproval--"{title}"-->templateWriteTheContent
402
- templateSpecifyingTheAssigment--"{assigment}"-->templateWriteTheContent
403
- templateKeywordAnalysis--"{keywords}"-->templateWriteTheContent
404
- templateCombineTheBeginning--"{contentBeginning}"-->templateWriteTheContent
405
- templateCombineTheContent(🔗 Combine the content)
406
- templateCombineTheBeginning--"{contentBeginning}"-->templateCombineTheContent
407
- templateWriteTheContent--"{contentBody}"-->templateCombineTheContent
408
-
409
- templateCombineTheContent--"{websiteContent}"-->output
410
- output((Output)):::output
411
-
412
- classDef input color: grey;
413
- classDef output color: grey;
414
-
415
- end;
416
- ```
187
+ - Versioning is build in. You can test multiple **A/B versions** of pipelines and see which one works best.
188
+ - 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.
189
+
190
+
191
+
192
+ ## 💙 Book language _(for prompt-engineer)_
193
+
194
+ 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.
417
195
 
418
- - [More template samples](./samples/pipelines/)
419
- - [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)
420
196
 
421
- _Note: We are using [postprocessing functions](#postprocessing-functions) like `unwrapResult` that can be used to postprocess the result._
422
197
 
423
- ## 📦 Packages
198
+ ```markdown
199
+ # 🌟 My first Book
200
+
201
+ - PERSONA Jane, marketing specialist with prior experience in writing articles about technology and artificial intelligence
202
+ - KNOWLEDGE https://ptbk.io
203
+ - KNOWLEDGE ./promptbook.pdf
204
+ - EXPECT MIN 1 Sentence
205
+ - EXPECT MAX 1 Paragraph
206
+
207
+ > 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.
208
+ > Look specifically at the impact of Promptbook on the AI industry.
209
+
210
+ -> {article}
211
+ ```
212
+
213
+ ## 📦 Packages _(for developers)_
424
214
 
425
215
  This library is divided into several packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
426
216
  You can install all of them at once:
@@ -462,8 +252,6 @@ Or you can install them separately:
462
252
 
463
253
  The following glossary is used to clarify certain concepts:
464
254
 
465
-
466
-
467
255
  ### Core concepts
468
256
 
469
257
  - [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
@@ -494,8 +282,8 @@ The following glossary is used to clarify certain concepts:
494
282
 
495
283
  ## 🔌 Usage in Typescript / Javascript
496
284
 
497
- - [Simple usage](./samples/usage/simple-script)
498
- - [Usage with client and remote server](./samples/usage/remote)
285
+ - [Simple usage](./examples/usage/simple-script)
286
+ - [Usage with client and remote server](./examples/usage/remote)
499
287
 
500
288
  ## ➕➖ When to use Promptbook?
501
289
 
package/esm/index.es.js CHANGED
@@ -5,7 +5,7 @@ import { basename } from 'path';
5
5
  /**
6
6
  * The version of the Promptbook library
7
7
  */
8
- var PROMPTBOOK_VERSION = '0.72.0-34';
8
+ var PROMPTBOOK_VERSION = '0.72.0';
9
9
  // TODO: [main] !!!! List here all the versions and annotate + put into script
10
10
 
11
11
  /*! *****************************************************************************
@@ -678,9 +678,9 @@ function renderPromptbookMermaid(pipelineJson, options) {
678
678
  return promptbookMermaid;
679
679
  }
680
680
  /**
681
- * TODO: !!!!! FOREACH in mermaid graph
682
- * TODO: !!!!! Knowledge in mermaid graph
683
- * TODO: !!!!! Personas in mermaid graph
681
+ * TODO: [🧠] !! FOREACH in mermaid graph
682
+ * TODO: [🧠] !! Knowledge in mermaid graph
683
+ * TODO: [🧠] !! Personas in mermaid graph
684
684
  * TODO: Maybe use some Mermaid package instead of string templating
685
685
  * TODO: [🕌] When more than 2 functionalities, split into separate functions
686
686
  */
@@ -1795,10 +1795,10 @@ $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', [
1795
1795
  'content',
1796
1796
  'context',
1797
1797
  'knowledge',
1798
- 'samples',
1798
+ 'examples',
1799
1799
  'modelName',
1800
1800
  'currentDate',
1801
- // <- TODO: !!!!! list here all command names
1801
+ // <- TODO: list here all command names
1802
1802
  // <- TODO: Add more like 'date', 'modelName',...
1803
1803
  // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
1804
1804
  ]);