@promptbook/openai 0.72.0-9 → 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.
Files changed (146) hide show
  1. package/README.md +43 -256
  2. package/esm/index.es.js +26 -25
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +24 -18
  5. package/esm/typings/src/_packages/node.index.d.ts +2 -0
  6. package/esm/typings/src/_packages/types.index.d.ts +18 -12
  7. package/esm/typings/src/_packages/utils.index.d.ts +2 -2
  8. package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
  9. package/esm/typings/src/collection/SimplePipelineCollection.d.ts +2 -2
  10. package/esm/typings/src/collection/collectionToJson.d.ts +1 -1
  11. package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -1
  12. package/esm/typings/src/collection/constructors/createCollectionFromPromise.d.ts +1 -1
  13. package/esm/typings/src/commands/TEMPLATE/TemplateTypes.d.ts +1 -1
  14. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +5 -5
  15. package/esm/typings/src/config.d.ts +22 -15
  16. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
  17. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
  18. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +1 -1
  19. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -2
  20. package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +12 -0
  21. package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +11 -0
  22. package/esm/typings/src/executables/apps/locatePandoc.d.ts +11 -0
  23. package/esm/typings/src/executables/locateApp.d.ts +33 -0
  24. package/esm/typings/src/executables/locateApp.test.d.ts +1 -0
  25. package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +12 -0
  26. package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +12 -0
  27. package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +12 -0
  28. package/esm/typings/src/execution/EmbeddingVector.d.ts +1 -1
  29. package/esm/typings/src/execution/Executables.d.ts +18 -0
  30. package/esm/typings/src/execution/ExecutionTools.d.ts +9 -3
  31. package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
  32. package/esm/typings/src/execution/LlmExecutionTools.d.ts +2 -2
  33. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
  34. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +3 -2
  35. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +29 -6
  36. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -11
  37. package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +4 -13
  38. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +9 -14
  39. package/esm/typings/src/execution/createPipelineExecutor/{getSamplesForTemplate.d.ts → getExamplesForTemplate.d.ts} +1 -1
  40. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +11 -3
  41. package/esm/typings/src/execution/utils/addUsage.d.ts +1 -1
  42. package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -1
  43. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +4 -4
  44. package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +3 -3
  45. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForCli.d.ts +2 -2
  46. package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +1 -1
  47. package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +7 -0
  48. package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +4 -1
  49. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
  50. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -2
  51. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  52. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
  53. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +2 -1
  54. package/esm/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +1 -1
  55. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -1
  56. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
  57. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
  58. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +4 -5
  59. package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +1 -1
  60. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +0 -1
  61. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +2 -2
  62. package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
  63. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  64. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +4 -4
  65. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Request.d.ts +15 -6
  66. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Response.d.ts +4 -4
  67. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Request.d.ts +6 -12
  68. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Response.d.ts +3 -3
  69. package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +9 -14
  70. package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +23 -8
  71. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  72. package/esm/typings/src/personas/preparePersona.d.ts +1 -1
  73. package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +4 -23
  74. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +2 -2
  75. package/esm/typings/src/prepare/prepareTemplates.d.ts +2 -2
  76. package/esm/typings/src/scrapers/_common/Scraper.d.ts +2 -9
  77. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +1 -1
  78. package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +2 -2
  79. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +2 -2
  80. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +2 -2
  81. package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +2 -2
  82. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
  83. package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +2 -2
  84. package/esm/typings/src/scrapers/document/DocumentScraper.test.d.ts +1 -1
  85. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
  86. package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -1
  87. package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +3 -3
  88. package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.test.d.ts +1 -1
  89. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -1
  90. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -1
  91. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -1
  92. package/esm/typings/src/scrapers/markdown/MarkdownScraper.test.d.ts +1 -1
  93. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -1
  94. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -1
  95. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +2 -2
  96. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -1
  97. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -1
  98. package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +6 -3
  99. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -1
  100. package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -1
  101. package/esm/typings/src/scrapers/website/utils/createShowdownConverter.d.ts +7 -0
  102. package/esm/typings/src/scrapers/website/utils/createShowdownConverter.test.d.ts +1 -0
  103. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  104. package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +1 -1
  105. package/esm/typings/src/types/Arrayable.d.ts +1 -1
  106. package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +7 -0
  107. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +4 -4
  108. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
  109. package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +2 -2
  110. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +1 -1
  111. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
  112. package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +2 -2
  113. package/esm/typings/src/types/Prompt.d.ts +2 -1
  114. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +1 -1
  115. package/esm/typings/src/types/typeAliases.d.ts +11 -8
  116. package/esm/typings/src/utils/$Register.d.ts +1 -1
  117. package/esm/typings/src/utils/FromtoItems.d.ts +1 -1
  118. package/esm/typings/src/utils/arrayableToArray.d.ts +1 -1
  119. package/esm/typings/src/utils/emojis.d.ts +1 -1
  120. package/esm/typings/src/utils/execCommand/$execCommand.d.ts +4 -2
  121. package/esm/typings/src/utils/execCommand/$execCommandNormalizeOptions.d.ts +12 -0
  122. package/esm/typings/src/utils/execCommand/$execCommands.d.ts +1 -0
  123. package/esm/typings/src/utils/execCommand/ExecCommandOptions.d.ts +45 -0
  124. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
  125. package/esm/typings/src/utils/files/isExecutable.d.ts +11 -0
  126. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
  127. package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +1 -1
  128. package/esm/typings/src/utils/normalization/IKeywords.d.ts +2 -2
  129. package/esm/typings/src/utils/normalization/parseKeywords.d.ts +2 -2
  130. package/esm/typings/src/utils/normalization/parseKeywordsFromString.d.ts +2 -2
  131. package/esm/typings/src/utils/normalization/searchKeywords.d.ts +2 -2
  132. package/esm/typings/src/utils/organization/TODO_USE.d.ts +1 -1
  133. package/esm/typings/src/utils/organization/keepUnused.d.ts +1 -1
  134. package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
  135. package/esm/typings/src/utils/sets/intersection.d.ts +1 -1
  136. package/esm/typings/src/utils/sets/union.d.ts +1 -1
  137. package/esm/typings/src/utils/unwrapResult.d.ts +4 -4
  138. package/package.json +6 -4
  139. package/umd/index.umd.js +26 -25
  140. package/umd/index.umd.js.map +1 -1
  141. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +0 -29
  142. package/esm/typings/src/scrapers/website/utils/markdownConverter.d.ts +0 -12
  143. package/esm/typings/src/utils/execCommand/IExecCommandOptions.d.ts +0 -23
  144. package/esm/typings/src/utils/execCommand/execCommandNormalizeOptions.d.ts +0 -10
  145. /package/esm/typings/src/{scrapers/website/WebsiteScraper.test.d.ts → executables/apps/locateLibreoffice.test.d.ts} +0 -0
  146. /package/esm/typings/src/{scrapers/website/utils/markdownConverter.test.d.ts → executables/apps/locatePandoc.test.d.ts} +0 -0
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # ![Promptbook logo - cube with letters P and B](./other/design/logo-h1.png) Promptbook
4
4
 
5
- Supercharge your use of large language models
5
+ Build responsible, controlled and transparent applications on top of LLM models!
6
6
 
7
7
 
8
8
 
@@ -18,12 +18,10 @@ Supercharge your use of large language 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
- <blockquote style="color: #ff8811">
24
- <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>.
25
- </blockquote>
26
-
27
25
 
28
26
 
29
27
  ## 📦 Package `@promptbook/openai`
@@ -64,10 +62,11 @@ const llm = new OpenAiExecutionTools(
64
62
  apiKey: process.env.OPENAI_API_KEY,
65
63
  },
66
64
  );
65
+ const executables = await $provideExecutablesForNode();
67
66
  const tools = {
68
67
  llm,
69
68
  fs,
70
- scrapers: await $provideScrapersForNode({ fs, llm }),
69
+ scrapers: await $provideScrapersForNode({ fs, llm, executables }),
71
70
  script: [new JavascriptExecutionTools()],
72
71
  };
73
72
 
@@ -96,8 +95,9 @@ console.info(outputParameters);
96
95
 
97
96
  ## 🤺 Usage with OpenAI`s Assistants (GPTs)
98
97
 
99
- !!!!!!
100
- OpenAiExecutionTools.createAssistantSubtools
98
+ > TODO: Write a guide how to use OpenAI's Assistants with Promptbook
99
+
100
+
101
101
 
102
102
  ## 🧙‍♂️ Connect to LLM providers automatically
103
103
 
@@ -177,10 +177,11 @@ const llm = [
177
177
  },
178
178
  ),
179
179
  ];
180
+ const executables = await $provideExecutablesForNode();
180
181
  const tools = {
181
182
  llm,
182
183
  fs,
183
- scrapers: await $provideScrapersForNode({ fs, llm }),
184
+ scrapers: await $provideScrapersForNode({ fs, llm, executables }),
184
185
  script: [new JavascriptExecutionTools()],
185
186
  };
186
187
 
@@ -223,260 +224,48 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
223
224
 
224
225
  ## 🤍 The Promptbook Whitepaper
225
226
 
227
+ 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.
226
228
 
227
-
228
- If you have a simple, single prompt for ChatGPT, GPT-4, Anthropic Claude, Google Gemini, Llama 2, 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.
229
-
230
- But often you will struggle with the limitations of LLMs, such as hallucinations, off-topic responses, poor quality output, language 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:
229
+ 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:
231
230
 
232
231
  1. **Fine-tune** the model to your specifications or even train your own.
233
232
  2. **Prompt-engineer** the prompt to the best shape you can achieve.
234
233
  3. Orchestrate **multiple prompts** in a [pipeline](https://github.com/webgptorg/promptbook/discussions/64) to get the best result.
235
234
 
236
- In all of these situations, but especially in 3., the Promptbook library can make your life easier.
235
+ In all of these situations, but especially in 3., the **✨ Promptbook can make your life waaaaaaaaaay easier**.
237
236
 
238
- - [**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.
239
- - 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.
240
- - **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.
241
- - 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.
237
+ - [**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).
238
+ - Book allows you to **focus on the business** logic without having to write code or deal with the technicalities of LLMs.
239
+ - **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.
240
+ - 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.
242
241
  - 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.
243
- - Promptbook has built in versioning. You can test multiple **A/B versions** of pipelines and see which one works best.
244
- - 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.
245
-
246
-
247
-
248
- ## 🧔 Pipeline _(for prompt-engeneers)_
249
-
250
- **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.
251
-
252
- - Multiple pipelines forms a **collection** which will handle core **know-how of your LLM application**.
253
- - Theese pipelines are designed such as they **can be written by non-programmers**.
254
-
255
-
256
-
257
- ### Sample:
258
-
259
- File `write-website-content.ptbk.md`:
260
-
261
-
262
-
263
-
264
-
265
- > # 🌍 Create website content
266
- >
267
- > Instructions for creating web page content.
268
- >
269
- > - PIPELINE URL https://promptbook.studio/webgpt/write-website-content.ptbk.md
270
- > - INPUT  PARAM `{rawTitle}` Automatically suggested a site name or empty text
271
- > - INPUT  PARAM `{rawAssigment}` Automatically generated site entry from image recognition
272
- > - OUTPUT PARAM `{websiteContent}` Web content
273
- > - OUTPUT PARAM `{keywords}` Keywords
274
- >
275
- > ## 👤 Specifying the assigment
276
- >
277
- > What is your web about?
278
- >
279
- > - DIALOG TEMPLATE
280
- >
281
- > ```
282
- > {rawAssigment}
283
- > ```
284
- >
285
- > `-> {assigment}` Website assignment and specification
286
- >
287
- > ## ✨ Improving the title
288
- >
289
- > - PERSONA Jane, Copywriter and Marketing Specialist.
290
- >
291
- > ```
292
- > As an experienced marketing specialist, you have been entrusted with improving the name of your client's business.
293
- >
294
- > A suggested name from a client:
295
- > "{rawTitle}"
296
- >
297
- > Assignment from customer:
298
- >
299
- > > {assigment}
300
- >
301
- > ## Instructions:
302
- >
303
- > - Write only one name suggestion
304
- > - The name will be used on the website, business cards, visuals, etc.
305
- > ```
306
- >
307
- > `-> {enhancedTitle}` Enhanced title
308
- >
309
- > ## 👤 Website title approval
310
- >
311
- > Is the title for your website okay?
312
- >
313
- > - DIALOG TEMPLATE
314
- >
315
- > ```
316
- > {enhancedTitle}
317
- > ```
318
- >
319
- > `-> {title}` Title for the website
320
- >
321
- > ## 🐰 Cunning subtitle
322
- >
323
- > - PERSONA Josh, a copywriter, tasked with creating a claim for the website.
324
- >
325
- > ```
326
- > As an experienced copywriter, you have been entrusted with creating a claim for the "{title}" web page.
327
- >
328
- > A website assignment from a customer:
329
- >
330
- > > {assigment}
331
- >
332
- > ## Instructions:
333
- >
334
- > - Write only one name suggestion
335
- > - Claim will be used on website, business cards, visuals, etc.
336
- > - Claim should be punchy, funny, original
337
- > ```
338
- >
339
- > `-> {claim}` Claim for the web
340
- >
341
- > ## 🚦 Keyword analysis
342
- >
343
- > - PERSONA Paul, extremely creative SEO specialist.
344
- >
345
- > ```
346
- > As an experienced SEO specialist, you have been entrusted with creating keywords for the website "{title}".
347
- >
348
- > Website assignment from the customer:
349
- >
350
- > > {assigment}
351
- >
352
- > ## Instructions:
353
- >
354
- > - Write a list of keywords
355
- > - Keywords are in basic form
356
- >
357
- > ## Example:
358
- >
359
- > - Ice cream
360
- > - Olomouc
361
- > - Quality
362
- > - Family
363
- > - Tradition
364
- > - Italy
365
- > - Craft
366
- >
367
- > ```
368
- >
369
- > `-> {keywords}` Keywords
370
- >
371
- > ## 🔗 Combine the beginning
372
- >
373
- > - SIMPLE TEMPLATE
374
- >
375
- > ```
376
- >
377
- > # {title}
378
- >
379
- > > {claim}
380
- >
381
- > ```
382
- >
383
- > `-> {contentBeginning}` Beginning of web content
384
- >
385
- > ## 🖋 Write the content
386
- >
387
- > - PERSONA Jane
388
- >
389
- > ```
390
- > As an experienced copywriter and web designer, you have been entrusted with creating text for a new website {title}.
391
- >
392
- > A website assignment from a customer:
393
- >
394
- > > {assigment}
395
- >
396
- > ## Instructions:
397
- >
398
- > - Text formatting is in Markdown
399
- > - Be concise and to the point
400
- > - Use keywords, but they should be naturally in the text
401
- > - This is the complete content of the page, so don't forget all the important information and elements the page should contain
402
- > - Use headings, bullets, text formatting
403
- >
404
- > ## Keywords:
405
- >
406
- > {keywords}
407
- >
408
- > ## Web Content:
409
- >
410
- > {contentBeginning}
411
- > ```
412
- >
413
- > `-> {contentBody}` Middle of the web content
414
- >
415
- > ## 🔗 Combine the content
416
- >
417
- > - SIMPLE TEMPLATE
418
- >
419
- > ```markdown
420
- > {contentBeginning}
421
- >
422
- > {contentBody}
423
- > ```
424
- >
425
- > `-> {websiteContent}`
426
-
427
-
428
-
429
- Following is the scheme how the promptbook above is executed:
430
-
431
- ```mermaid
432
- %% 🔮 Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually
433
-
434
- flowchart LR
435
- subgraph "🌍 Create website content"
436
-
437
- direction TB
438
-
439
- input((Input)):::input
440
- templateSpecifyingTheAssigment(👤 Specifying the assigment)
441
- input--"{rawAssigment}"-->templateSpecifyingTheAssigment
442
- templateImprovingTheTitle(✨ Improving the title)
443
- input--"{rawTitle}"-->templateImprovingTheTitle
444
- templateSpecifyingTheAssigment--"{assigment}"-->templateImprovingTheTitle
445
- templateWebsiteTitleApproval(👤 Website title approval)
446
- templateImprovingTheTitle--"{enhancedTitle}"-->templateWebsiteTitleApproval
447
- templateCunningSubtitle(🐰 Cunning subtitle)
448
- templateWebsiteTitleApproval--"{title}"-->templateCunningSubtitle
449
- templateSpecifyingTheAssigment--"{assigment}"-->templateCunningSubtitle
450
- templateKeywordAnalysis(🚦 Keyword analysis)
451
- templateWebsiteTitleApproval--"{title}"-->templateKeywordAnalysis
452
- templateSpecifyingTheAssigment--"{assigment}"-->templateKeywordAnalysis
453
- templateCombineTheBeginning(🔗 Combine the beginning)
454
- templateWebsiteTitleApproval--"{title}"-->templateCombineTheBeginning
455
- templateCunningSubtitle--"{claim}"-->templateCombineTheBeginning
456
- templateWriteTheContent(🖋 Write the content)
457
- templateWebsiteTitleApproval--"{title}"-->templateWriteTheContent
458
- templateSpecifyingTheAssigment--"{assigment}"-->templateWriteTheContent
459
- templateKeywordAnalysis--"{keywords}"-->templateWriteTheContent
460
- templateCombineTheBeginning--"{contentBeginning}"-->templateWriteTheContent
461
- templateCombineTheContent(🔗 Combine the content)
462
- templateCombineTheBeginning--"{contentBeginning}"-->templateCombineTheContent
463
- templateWriteTheContent--"{contentBody}"-->templateCombineTheContent
464
-
465
- templateCombineTheContent--"{websiteContent}"-->output
466
- output((Output)):::output
467
-
468
- classDef input color: grey;
469
- classDef output color: grey;
470
-
471
- end;
472
- ```
242
+ - Versioning is build in. You can test multiple **A/B versions** of pipelines and see which one works best.
243
+ - 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.
244
+
245
+
246
+
247
+ ## 💙 Book language _(for prompt-engineer)_
473
248
 
474
- - [More template samples](./samples/pipelines/)
475
- - [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)
249
+ 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.
476
250
 
477
- _Note: We are using [postprocessing functions](#postprocessing-functions) like `unwrapResult` that can be used to postprocess the result._
478
251
 
479
- ## 📦 Packages
252
+
253
+ ```markdown
254
+ # 🌟 My first Book
255
+
256
+ - PERSONA Jane, marketing specialist with prior experience in writing articles about technology and artificial intelligence
257
+ - KNOWLEDGE https://ptbk.io
258
+ - KNOWLEDGE ./promptbook.pdf
259
+ - EXPECT MIN 1 Sentence
260
+ - EXPECT MAX 1 Paragraph
261
+
262
+ > 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.
263
+ > Look specifically at the impact of Promptbook on the AI industry.
264
+
265
+ -> {article}
266
+ ```
267
+
268
+ ## 📦 Packages _(for developers)_
480
269
 
481
270
  This library is divided into several packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
482
271
  You can install all of them at once:
@@ -518,8 +307,6 @@ Or you can install them separately:
518
307
 
519
308
  The following glossary is used to clarify certain concepts:
520
309
 
521
-
522
-
523
310
  ### Core concepts
524
311
 
525
312
  - [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
@@ -550,8 +337,8 @@ The following glossary is used to clarify certain concepts:
550
337
 
551
338
  ## 🔌 Usage in Typescript / Javascript
552
339
 
553
- - [Simple usage](./samples/usage/simple-script)
554
- - [Usage with client and remote server](./samples/usage/remote)
340
+ - [Simple usage](./examples/usage/simple-script)
341
+ - [Usage with client and remote server](./examples/usage/remote)
555
342
 
556
343
  ## ➕➖ When to use Promptbook?
557
344
 
package/esm/index.es.js CHANGED
@@ -6,7 +6,7 @@ import OpenAI from 'openai';
6
6
  /**
7
7
  * The version of the Promptbook library
8
8
  */
9
- var PROMPTBOOK_VERSION = '0.72.0-8';
9
+ var PROMPTBOOK_VERSION = '0.72.0';
10
10
  // TODO: [main] !!!! List here all the versions and annotate + put into script
11
11
 
12
12
  /*! *****************************************************************************
@@ -455,10 +455,10 @@ $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', [
455
455
  'content',
456
456
  'context',
457
457
  'knowledge',
458
- 'samples',
458
+ 'examples',
459
459
  'modelName',
460
460
  'currentDate',
461
- // <- TODO: !!!!! list here all command names
461
+ // <- TODO: list here all command names
462
462
  // <- TODO: Add more like 'date', 'modelName',...
463
463
  // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
464
464
  ]);
@@ -1413,7 +1413,6 @@ var OpenAiExecutionTools = /** @class */ (function () {
1413
1413
  * @param options which are relevant are directly passed to the OpenAI client
1414
1414
  */
1415
1415
  function OpenAiExecutionTools(options) {
1416
- if (options === void 0) { options = {}; }
1417
1416
  this.options = options;
1418
1417
  /**
1419
1418
  * OpenAI API client.
@@ -1441,8 +1440,8 @@ var OpenAiExecutionTools = /** @class */ (function () {
1441
1440
  if (this.client === null) {
1442
1441
  openAiOptions = __assign({}, this.options);
1443
1442
  delete openAiOptions.isVerbose;
1444
- delete openAiOptions.user;
1445
- this.client = new OpenAI(__assign({}, openAiOptions));
1443
+ delete openAiOptions.userId;
1444
+ this.client = new OpenAI(openAiOptions);
1446
1445
  }
1447
1446
  return [2 /*return*/, this.client];
1448
1447
  });
@@ -1489,11 +1488,12 @@ var OpenAiExecutionTools = /** @class */ (function () {
1489
1488
  * Calls OpenAI API to use a chat model.
1490
1489
  */
1491
1490
  OpenAiExecutionTools.prototype.callChatModel = function (prompt) {
1491
+ var _a;
1492
1492
  return __awaiter(this, void 0, void 0, function () {
1493
1493
  var content, parameters, modelRequirements, format, client, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
1494
1494
  var _this = this;
1495
- return __generator(this, function (_a) {
1496
- switch (_a.label) {
1495
+ return __generator(this, function (_b) {
1496
+ switch (_b.label) {
1497
1497
  case 0:
1498
1498
  if (this.options.isVerbose) {
1499
1499
  console.info('💬 OpenAI callChatModel call', { prompt: prompt });
@@ -1501,7 +1501,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
1501
1501
  content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements, format = prompt.format;
1502
1502
  return [4 /*yield*/, this.getClient()];
1503
1503
  case 1:
1504
- client = _a.sent();
1504
+ client = _b.sent();
1505
1505
  // TODO: [☂] Use here more modelRequirements
1506
1506
  if (modelRequirements.modelVariant !== 'CHAT') {
1507
1507
  throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
@@ -1533,7 +1533,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
1533
1533
  role: 'user',
1534
1534
  content: rawPromptContent,
1535
1535
  },
1536
- ], false), user: this.options.user });
1536
+ ], false), user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString() });
1537
1537
  start = getCurrentIsoDate();
1538
1538
  if (this.options.isVerbose) {
1539
1539
  console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
@@ -1545,7 +1545,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
1545
1545
  throw error;
1546
1546
  })];
1547
1547
  case 2:
1548
- rawResponse = _a.sent();
1548
+ rawResponse = _b.sent();
1549
1549
  if (this.options.isVerbose) {
1550
1550
  console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
1551
1551
  }
@@ -1584,11 +1584,12 @@ var OpenAiExecutionTools = /** @class */ (function () {
1584
1584
  * Calls OpenAI API to use a complete model.
1585
1585
  */
1586
1586
  OpenAiExecutionTools.prototype.callCompletionModel = function (prompt) {
1587
+ var _a;
1587
1588
  return __awaiter(this, void 0, void 0, function () {
1588
1589
  var content, parameters, modelRequirements, client, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
1589
1590
  var _this = this;
1590
- return __generator(this, function (_a) {
1591
- switch (_a.label) {
1591
+ return __generator(this, function (_b) {
1592
+ switch (_b.label) {
1592
1593
  case 0:
1593
1594
  if (this.options.isVerbose) {
1594
1595
  console.info('🖋 OpenAI callCompletionModel call', { prompt: prompt });
@@ -1596,7 +1597,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
1596
1597
  content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
1597
1598
  return [4 /*yield*/, this.getClient()];
1598
1599
  case 1:
1599
- client = _a.sent();
1600
+ client = _b.sent();
1600
1601
  // TODO: [☂] Use here more modelRequirements
1601
1602
  if (modelRequirements.modelVariant !== 'COMPLETION') {
1602
1603
  throw new PipelineExecutionError('Use callCompletionModel only for COMPLETION variant');
@@ -1611,7 +1612,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
1611
1612
  // <- Note: [🧆]
1612
1613
  };
1613
1614
  rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
1614
- rawRequest = __assign(__assign({}, modelSettings), { prompt: rawPromptContent, user: this.options.user });
1615
+ rawRequest = __assign(__assign({}, modelSettings), { prompt: rawPromptContent, user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString() });
1615
1616
  start = getCurrentIsoDate();
1616
1617
  if (this.options.isVerbose) {
1617
1618
  console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
@@ -1623,7 +1624,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
1623
1624
  throw error;
1624
1625
  })];
1625
1626
  case 2:
1626
- rawResponse = _a.sent();
1627
+ rawResponse = _b.sent();
1627
1628
  if (this.options.isVerbose) {
1628
1629
  console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
1629
1630
  }
@@ -1849,17 +1850,16 @@ var OpenAiAssistantExecutionTools = /** @class */ (function (_super) {
1849
1850
  assistant_id: this.assistantId,
1850
1851
  thread: {
1851
1852
  messages: [
1852
- // TODO: !!!!!! Allow threads to be passed
1853
+ // TODO: [🗯] !! Allow threads to be passed
1853
1854
  { role: 'user', content: rawPromptContent },
1854
1855
  ],
1855
1856
  },
1856
- // !!!!!! user: this.options.user,
1857
+ // <- TODO: Add user identification here> user: this.options.user,
1857
1858
  };
1858
1859
  start = getCurrentIsoDate();
1859
1860
  if (this.options.isVerbose) {
1860
1861
  console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
1861
1862
  }
1862
- console.log('!!!!!! OpenAI client', client);
1863
1863
  return [4 /*yield*/, client.beta.threads.createAndRunStream(rawRequest)];
1864
1864
  case 2:
1865
1865
  stream = _g.sent();
@@ -1877,7 +1877,7 @@ var OpenAiAssistantExecutionTools = /** @class */ (function (_super) {
1877
1877
  messageDelta.content[0].type === 'text') {
1878
1878
  console.info('messageDelta', (_a = messageDelta.content[0].text) === null || _a === void 0 ? void 0 : _a.value);
1879
1879
  }
1880
- // TODO: !!!!!! report progress
1880
+ // <- TODO: [🐚] Make streaming and running tasks working
1881
1881
  });
1882
1882
  stream.on('messageCreated', function (message) {
1883
1883
  if (_this.options.isVerbose) {
@@ -1905,18 +1905,20 @@ var OpenAiAssistantExecutionTools = /** @class */ (function (_super) {
1905
1905
  throw new PipelineExecutionError("There is NOT 'text' BUT ".concat((_b = rawResponse[0].content[0]) === null || _b === void 0 ? void 0 : _b.type, " finalMessages content type from OpenAI"));
1906
1906
  }
1907
1907
  resultContent = (_c = rawResponse[0].content[0]) === null || _c === void 0 ? void 0 : _c.text.value;
1908
- // <- TODO: !!!!!! There are also annotations, maybe use them
1908
+ // <- TODO: [🧠] There are also annotations, maybe use them
1909
1909
  // eslint-disable-next-line prefer-const
1910
1910
  complete = getCurrentIsoDate();
1911
1911
  usage = UNCERTAIN_USAGE;
1912
- // TODO: !!!!!!> = computeOpenAiUsage(content, resultContent || '', rawResponse);
1912
+ // <- TODO: [🥘] Compute real usage for assistant
1913
+ // ?> const usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
1913
1914
  if (resultContent === null) {
1914
1915
  throw new PipelineExecutionError('No response message from OpenAI');
1915
1916
  }
1916
1917
  return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiAssistantExecutionTools ChatPromptResult', {
1917
1918
  content: resultContent,
1918
1919
  modelName: 'assistant',
1919
- // <- TODO: !!!!!! Can we detect really used model: rawResponse.model || modelName,
1920
+ // <- TODO: [🥘] Detect used model in assistant
1921
+ // ?> model: rawResponse.model || modelName,
1920
1922
  timing: {
1921
1923
  start: start,
1922
1924
  complete: complete,
@@ -1934,7 +1936,6 @@ var OpenAiAssistantExecutionTools = /** @class */ (function (_super) {
1934
1936
  return OpenAiAssistantExecutionTools;
1935
1937
  }(OpenAiExecutionTools));
1936
1938
  /**
1937
- * TODO: !!!!!! DO not use colors - can be used in browser
1938
1939
  * TODO: [🧠][🧙‍♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
1939
1940
  * TODO: Maybe make custom OpenAiError
1940
1941
  * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
@@ -2092,7 +2093,7 @@ var $Register = /** @class */ (function () {
2092
2093
  this.storage = globalScope[storageName];
2093
2094
  }
2094
2095
  $Register.prototype.list = function () {
2095
- // <- TODO: ReadonlyDeep<Array<TRegistered>>
2096
+ // <- TODO: ReadonlyDeep<ReadonlyArray<TRegistered>>
2096
2097
  return this.storage;
2097
2098
  };
2098
2099
  $Register.prototype.register = function (registered) {