ptbk 0.63.0-9 โ†’ 0.63.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +45 -253
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -52,12 +52,23 @@ In any of these situations, but especially in (3), the Promptbook library can ma
52
52
 
53
53
 
54
54
 
55
+ ## ๐Ÿง” Promptbook _(for prompt-engeneers)_
56
+
57
+ **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.
58
+
59
+ - Multiple pipelines forms a **collection** which will handle core **know-how of your LLM application**.
60
+ - Theese pipelines are designed such as they **can be written by non-programmers**.
61
+
62
+
63
+
55
64
  ### Sample:
56
65
 
57
66
  File `write-website-content.ptbk.md`:
58
67
 
59
68
 
60
69
 
70
+
71
+
61
72
  > # ๐ŸŒ Create website content
62
73
  >
63
74
  > Instructions for creating web page content.
@@ -274,7 +285,8 @@ flowchart LR
274
285
  end;
275
286
  ```
276
287
 
277
- [More template samples](./samples/templates/)
288
+ - [More template samples](./samples/templates/)
289
+ - [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)
278
290
 
279
291
  _Note: We are using [postprocessing functions](#postprocessing-functions) like `unwrapResult` that can be used to postprocess the result._
280
292
 
@@ -291,7 +303,6 @@ Or you can install them separately:
291
303
 
292
304
  > โญ Marked packages are worth to try first
293
305
 
294
-
295
306
  - โญ **[ptbk](https://www.npmjs.com/package/ptbk)** - Bundle of all packages, when you want to install everything and you don't care about the size
296
307
  - **[promptbook](https://www.npmjs.com/package/promptbook)** - Same as `ptbk`
297
308
  - **[@promptbook/core](https://www.npmjs.com/package/@promptbook/core)** - Core of the library, it contains the main logic for promptbooks
@@ -315,263 +326,39 @@ Or you can install them separately:
315
326
 
316
327
  ## ๐Ÿ“š Dictionary
317
328
 
318
- The following glossary is used to clarify certain basic concepts:
319
-
320
- ### Prompt
321
-
322
- Prompt in a text along with model requirements, but without any execution or templating logic.
323
-
324
- For example:
325
-
326
- ```json
327
- {
328
- "request": "Which sound does a cat make?",
329
- "modelRequirements": {
330
- "variant": "CHAT"
331
- }
332
- }
333
- ```
334
-
335
- ```json
336
- {
337
- "request": "I am a cat.\nI like to eat fish.\nI like to sleep.\nI like to play with a ball.\nI l",
338
- "modelRequirements": {
339
- "variant": "COMPLETION"
340
- }
341
- }
342
- ```
343
-
344
- ### Prompt Template
345
-
346
- Similar concept to Prompt, but with templating logic.
347
-
348
- For example:
349
-
350
- ```json
351
- {
352
- "request": "Which sound does a {animalName} make?",
353
- "modelRequirements": {
354
- "variant": "CHAT"
355
- }
356
- }
357
- ```
358
-
359
- ### Model Requirements
360
-
361
- Abstract way to specify the LLM.
362
- It does not specify the LLM with concrete version itself, only the requirements for the LLM.
363
- _NOT chatgpt-3.5-turbo BUT CHAT variant of GPT-3.5._
364
-
365
- For example:
366
-
367
- ```json
368
- {
369
- "variant": "CHAT",
370
- "version": "GPT-3.5",
371
- "temperature": 0.7
372
- }
373
- ```
374
-
375
- ### Block type
376
-
377
- Each block of promptbook can have a different execution type.
378
- It is specified in list of requirements for the block.
379
- By default, it is `Prompt template`
380
-
381
- - _(default)_ `Prompt template` The block is a prompt template and is executed by LLM (OpenAI, Azure,...)
382
- - `SIMPLE TEMPLATE` The block is a simple text template which is just filled with parameters
383
- - `Script` The block is a script that is executed by some script runtime, the runtime is determined by block type, currently only `javascript` is supported but we plan to add `python` and `typescript` in the future.
384
- - `PROMPT DIALOG` Ask user for input
385
-
386
- ### Parameters
387
-
388
- Parameters that are placed in the prompt template and replaced to create the prompt.
389
- It is a simple key-value object.
390
-
391
- ```json
392
- {
393
- "animalName": "cat",
394
- "animalSound": "Meow!"
395
- }
396
- ```
397
-
398
- There are three types of template parameters, depending on how they are used in the promptbook:
399
-
400
- - **INPUT PARAMETER**s are required to execute the promptbook.
401
- - **Intermediate parameters** are used internally in the promptbook.
402
- - **OUTPUT PARAMETER**s are explicitelly marked and they are returned as the result of the promptbook execution.
403
-
404
- _Note: Parameter can be both intermedite and output at the same time._
405
-
406
- ### Promptbook
407
-
408
- Promptbook is **core concept of this library**.
409
- It represents a series of prompt templates chained together to form a **pipeline** / one big prompt template with input and result parameters.
410
-
411
- Internally it can have multiple formats:
412
-
413
- - **.ptbk.md file** in custom markdown format described above
414
- - _(concept)_ **.ptbk** format, custom fileextension based on markdown
415
- - _(internal)_ **JSON** format, parsed from the .ptbk.md file
416
-
417
- ### Promptbook **Library**
418
-
419
- Library of all promptbooks used in your application.
420
- Each promptbook is a separate `.ptbk.md` file with unique `PIPELINE URL`. Theese urls are used to reference promptbooks in other promptbooks or in the application code.
421
-
422
- ### Prompt Result
423
-
424
- Prompt result is the simplest concept of execution.
425
- It is the result of executing one prompt _(NOT a template)_.
426
-
427
- For example:
428
-
429
- ```json
430
- {
431
- "response": "Meow!",
432
- "model": "chatgpt-3.5-turbo"
433
- }
434
- ```
435
-
436
- ### Execution Tools
437
-
438
-
439
-
440
- `ExecutionTools` is an interface which contains all the tools needed to execute prompts.
441
- It contais 3 subtools:
442
-
443
- - `LlmExecutionTools`
444
- - `ScriptExecutionTools`
445
- - `UserInterfaceTools`
446
-
447
- Which are described below:
329
+ The following glossary is used to clarify certain concepts:
448
330
 
449
- #### LLM Execution Tools
450
331
 
451
- `LlmExecutionTools` is a container for all the tools needed to execute prompts to large language models like GPT-4.
452
- On its interface it exposes common methods for prompt execution.
453
- Internally it calls OpenAI, Azure, GPU, proxy, cache, logging,...
454
332
 
455
- `LlmExecutionTools` an abstract interface that is implemented by concrete execution tools:
333
+ ### Core concepts
456
334
 
457
- - `OpenAiExecutionTools`
458
- - `AnthropicClaudeExecutionTools`
459
- - `AzureOpenAiExecutionTools`
460
- - `LangtailExecutionTools`
461
- - _(Not implemented yet)_ `BardExecutionTools`
462
- - _(Not implemented yet)_ `LamaExecutionTools`
463
- - _(Not implemented yet)_ `GpuExecutionTools`
464
- - Special case are `RemoteLlmExecutionTools` that connect to a remote server and run one of the above execution tools on that server.
465
- - Another special case is `MockedEchoLlmExecutionTools` that is used for testing and mocking.
466
- - The another special case is `LogLlmExecutionToolsWrapper` that is technically also an execution tools but it is more proxy wrapper around other execution tools that logs all calls to execution tools.
335
+ - [๐Ÿ“š Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
336
+ - [๐Ÿ“ฏ Pipeline](https://github.com/webgptorg/promptbook/discussions/64)
337
+ - [๐ŸŽบ Pipeline templates](https://github.com/webgptorg/promptbook/discussions/88)
338
+ - [๐Ÿคผ Personas](https://github.com/webgptorg/promptbook/discussions/22)
339
+ - [โญ• Parameters](https://github.com/webgptorg/promptbook/discussions/83)
340
+ - [๐Ÿš€ Pipeline execution](https://github.com/webgptorg/promptbook/discussions/84)
341
+ - [๐Ÿงช Expectations](https://github.com/webgptorg/promptbook/discussions/30)
342
+ - [โœ‚๏ธ Postprocessing](https://github.com/webgptorg/promptbook/discussions/31)
343
+ - [๐Ÿ”ฃ Words not tokens](https://github.com/webgptorg/promptbook/discussions/29)
344
+ - [โ˜ฏ Separation of concerns](https://github.com/webgptorg/promptbook/discussions/32)
467
345
 
468
- #### Script Execution Tools
346
+ ### Advanced concepts
469
347
 
470
- `ScriptExecutionTools` is an abstract container that represents all the tools needed to EXECUTE SCRIPTs. It is implemented by concrete execution tools:
348
+ - [๐Ÿ“š Knowledge (Retrieval-augmented generation)](https://github.com/webgptorg/promptbook/discussions/41)
349
+ - [๐ŸŒ Remote server](https://github.com/webgptorg/promptbook/discussions/89)
350
+ - [๐Ÿƒ Jokers (conditions)](https://github.com/webgptorg/promptbook/discussions/66)
351
+ - [๐Ÿ”ณ Metaprompting](https://github.com/webgptorg/promptbook/discussions/35)
352
+ - [๐ŸŒ Linguistically typed languages](https://github.com/webgptorg/promptbook/discussions/53)
353
+ - [๐ŸŒ Auto-Translations](https://github.com/webgptorg/promptbook/discussions/42)
354
+ - [๐Ÿ“ฝ Images, audio, video, spreadsheets](https://github.com/webgptorg/promptbook/discussions/54)
355
+ - [๐Ÿ”™ Expectation-aware generation](https://github.com/webgptorg/promptbook/discussions/37)
356
+ - [โณ Just-in-time fine-tuning](https://github.com/webgptorg/promptbook/discussions/33)
357
+ - [๐Ÿ”ด Anomaly detection](https://github.com/webgptorg/promptbook/discussions/40)
358
+ - [๐Ÿ‘ฎ Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)
359
+ - [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)
471
360
 
472
- - `JavascriptExecutionTools` is a wrapper around `vm2` module that executes javascript code in a sandbox.
473
- - `JavascriptEvalExecutionTools` is wrapper around `eval` function that executes javascript. It is used for testing and mocking **NOT intended to use in the production** due to its unsafe nature, use `JavascriptExecutionTools` instead.
474
- - _(Not implemented yet)_ `TypescriptExecutionTools` executes typescript code in a sandbox.
475
- - _(Not implemented yet)_ `PythonExecutionTools` executes python code in a sandbox.
476
-
477
- There are [postprocessing functions](#postprocessing-functions) that can be used to postprocess the result.
478
-
479
- #### User Interface Tools
480
-
481
- `UserInterfaceTools` is an abstract container that represents all the tools needed to interact with the user. It is implemented by concrete execution tools:
482
-
483
- - _(Not implemented yet)_ `ConsoleInterfaceTools` is a wrapper around `readline` module that interacts with the user via console.
484
- - `SimplePromptInterfaceTools` is a wrapper around `window.prompt` synchronous function that interacts with the user via browser prompt. It is used for testing and mocking **NOT intended to use in the production** due to its synchronous nature.
485
- - `CallbackInterfaceTools` delagates the user interaction to a async callback function. You need to provide your own implementation of this callback function and its bind to UI.
486
-
487
- ### Executor
488
-
489
- Executor is a simple async function that takes **input parameters** and returns **output parameters**.
490
- It is constructed by combining execution tools and promptbook to execute together.
491
-
492
- ### ๐Ÿƒ Jokers (conditions)
493
-
494
- Joker is a previously defined parameter that is used to bypass some parts of the pipeline.
495
- If the joker is present in the template, it is checked to see if it meets the requirements (without postprocessing), and if so, it is used instead of executing that prompt template. There can be multiple wildcards in a prompt template, if so they are checked in order and the first one that meets the requirements is used.
496
-
497
- If none of the jokers meet the requirements, the prompt template is executed as usual.
498
-
499
- This can be useful, for example, if you want to use some predefined data, or if you want to use some data from the user, but you are not sure if it is suitable form.
500
-
501
- When using wildcards, you must have at least one minimum expectation. If you do not have a minimum expectation, the joker will always fulfil the expectation because it has none, so it makes no logical sense.
502
-
503
- Look at [jokers.ptbk.md](samples/templates/41-jokers.ptbk.md) sample.
504
-
505
- ### Postprocessing functions
506
-
507
- You can define postprocessing functions when creating `JavascriptEvalExecutionTools`:
508
-
509
- ```
510
-
511
- ```
512
-
513
- Additionally there are some usefull string-manipulation build-in functions, which are [listed here](src/scripting/javascript/JavascriptEvalExecutionTools.ts).
514
-
515
- ### Expectations
516
-
517
- `Expect` command describes the desired output of the prompt template (after post-processing)
518
- It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs,...
519
-
520
- _Note: LLMs work with tokens, not characters, but in Promptbooks we want to use some human-recognisable and cross-model interoperable units._
521
-
522
- ```markdown
523
- # โœจ Sample: Expectations
524
-
525
- - INPUTโ€ฏโ€ฏPARAMETER {yourName} Name of the hero
526
-
527
- ## ๐Ÿ’ฌ Question
528
-
529
- - EXPECT MAX 30 CHARACTERS
530
- - EXPECT MIN 2 CHARACTERS
531
- - EXPECT MAX 3 WORDS
532
- - EXPECT EXACTLY 1 SENTENCE
533
- - EXPECT EXACTLY 1 LINE
534
-
535
- ...
536
- ```
537
-
538
- There are two types of expectations which are not strictly symmetrical:
539
-
540
- #### Minimal expectations
541
-
542
- - `EXPECT MIN 0 ...` is not valid minimal expectation. It makes no sense.
543
- - `EXPECT JSON` is both minimal and maximal expectation
544
- - When you are using `JOKER` in same prompt template, you need to have at least one minimal expectation
545
-
546
- #### Maximal expectations
547
-
548
- - `EXPECT MAX 0 ...` is valid maximal expectation. For example, you can expect 0 pages and 2 sentences.
549
- - `EXPECT JSON` is both minimal and maximal expectation
550
-
551
- Look at [expectations.ptbk.md](samples/templates/45-expectations.ptbk.md) and [expect-json.ptbk.md](samples/templates/45-expect-json.ptbk.md) samples for more.
552
-
553
- ### Execution report
554
-
555
- Execution report is a simple object or markdown that contains information about the execution of the pipeline.
556
-
557
- [See the example of such a report](/samples/templates/50-advanced.report.md)
558
-
559
-
560
-
561
-
562
-
563
- ### Remote server
564
-
565
- Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
566
-
567
- You can simply use `RemoteExecutionTools` on client-side javascript and connect to your remote server.
568
- This is useful to make all logic on browser side but not expose your API keys or no need to use customer's GPU.
569
-
570
- ## ๐Ÿ‘จโ€๐Ÿ’ป Usage and integration _(for developers)_
571
-
572
-
573
-
574
- ### ๐Ÿ”Œ Usage in Typescript / Javascript
361
+ ## ๐Ÿ”Œ Usage in Typescript / Javascript
575
362
 
576
363
  - [Simple usage](./samples/usage/simple-script)
577
364
  - [Usage with client and remote server](./samples/usage/remote)
@@ -594,14 +381,19 @@ This is useful to make all logic on browser side but not expose your API keys or
594
381
 
595
382
  ## ๐Ÿœ Known issues
596
383
 
597
-
384
+ - [๐Ÿคธโ€โ™‚๏ธ Iterations not working yet](https://github.com/webgptorg/promptbook/discussions/55)
385
+ - [โคต๏ธ Imports not working yet](https://github.com/webgptorg/promptbook/discussions/34)
598
386
 
599
387
  ## ๐Ÿงผ Intentionally not implemented features
600
388
 
601
389
 
390
+ - [โžฟ No recursion](https://github.com/webgptorg/promptbook/discussions/38)
391
+ - [๐Ÿณ There are no types, just strings](https://github.com/webgptorg/promptbook/discussions/52)
602
392
 
603
393
  ## โ” FAQ
604
394
 
395
+
396
+
605
397
  If you have a question [start a discussion](https://github.com/webgptorg/promptbook/discussions/), [open an issue](https://github.com/webgptorg/promptbook/issues) or [write me an email](https://www.pavolhejny.com/contact).
606
398
 
607
399
  ### Why not just use the OpenAI SDK / Anthropic Claude SDK / ...?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ptbk",
3
- "version": "0.63.0-9",
3
+ "version": "0.63.1",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -44,9 +44,9 @@
44
44
  }
45
45
  ],
46
46
  "peerDependencies": {
47
- "@promptbook/core": "0.63.0-9"
47
+ "@promptbook/core": "0.63.1"
48
48
  },
49
49
  "dependencies": {
50
- "promptbook": "0.63.0-9"
50
+ "promptbook": "0.63.1"
51
51
  }
52
52
  }