@promptbook/azure-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 +40 -254
  2. package/esm/index.es.js +26 -26
  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 -26
  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/azure-openai`
@@ -68,10 +66,11 @@ const llm = new AzureOpenAiExecutionTools(
68
66
  apiKey: process.env.AZUREOPENAI_API_KEY,
69
67
  },
70
68
  );
69
+ const executables = await $provideExecutablesForNode();
71
70
  const tools = {
72
71
  llm,
73
72
  fs,
74
- scrapers: await $provideScrapersForNode({ fs, llm }),
73
+ scrapers: await $provideScrapersForNode({ fs, llm, executables }),
75
74
  script: [new JavascriptExecutionTools()],
76
75
  };
77
76
 
@@ -140,10 +139,11 @@ const llm = [
140
139
  },
141
140
  ),
142
141
  ];
142
+ const executables = await $provideExecutablesForNode();
143
143
  const tools = {
144
144
  llm,
145
145
  fs,
146
- scrapers: await $provideScrapersForNode({ fs, llm }),
146
+ scrapers: await $provideScrapersForNode({ fs, llm, executables }),
147
147
  script: [new JavascriptExecutionTools()],
148
148
  };
149
149
 
@@ -184,260 +184,48 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
184
184
 
185
185
  ## 🤍 The Promptbook Whitepaper
186
186
 
187
+ 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.
187
188
 
188
-
189
- 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.
190
-
191
- 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:
189
+ 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:
192
190
 
193
191
  1. **Fine-tune** the model to your specifications or even train your own.
194
192
  2. **Prompt-engineer** the prompt to the best shape you can achieve.
195
193
  3. Orchestrate **multiple prompts** in a [pipeline](https://github.com/webgptorg/promptbook/discussions/64) to get the best result.
196
194
 
197
- In all of these situations, but especially in 3., the Promptbook library can make your life easier.
195
+ In all of these situations, but especially in 3., the **✨ Promptbook can make your life waaaaaaaaaay easier**.
198
196
 
199
- - [**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.
200
- - 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.
201
- - **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.
202
- - 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.
197
+ - [**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).
198
+ - Book allows you to **focus on the business** logic without having to write code or deal with the technicalities of LLMs.
199
+ - **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.
200
+ - 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.
203
201
  - 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.
204
- - Promptbook has built in versioning. You can test multiple **A/B versions** of pipelines and see which one works best.
205
- - 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.
206
-
207
-
208
-
209
- ## 🧔 Pipeline _(for prompt-engeneers)_
210
-
211
- **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.
212
-
213
- - Multiple pipelines forms a **collection** which will handle core **know-how of your LLM application**.
214
- - Theese pipelines are designed such as they **can be written by non-programmers**.
215
-
216
-
217
-
218
- ### Sample:
219
-
220
- File `write-website-content.ptbk.md`:
221
-
222
-
223
-
224
-
225
-
226
- > # 🌍 Create website content
227
- >
228
- > Instructions for creating web page content.
229
- >
230
- > - PIPELINE URL https://promptbook.studio/webgpt/write-website-content.ptbk.md
231
- > - INPUT  PARAM `{rawTitle}` Automatically suggested a site name or empty text
232
- > - INPUT  PARAM `{rawAssigment}` Automatically generated site entry from image recognition
233
- > - OUTPUT PARAM `{websiteContent}` Web content
234
- > - OUTPUT PARAM `{keywords}` Keywords
235
- >
236
- > ## 👤 Specifying the assigment
237
- >
238
- > What is your web about?
239
- >
240
- > - DIALOG TEMPLATE
241
- >
242
- > ```
243
- > {rawAssigment}
244
- > ```
245
- >
246
- > `-> {assigment}` Website assignment and specification
247
- >
248
- > ## ✨ Improving the title
249
- >
250
- > - PERSONA Jane, Copywriter and Marketing Specialist.
251
- >
252
- > ```
253
- > As an experienced marketing specialist, you have been entrusted with improving the name of your client's business.
254
- >
255
- > A suggested name from a client:
256
- > "{rawTitle}"
257
- >
258
- > Assignment from customer:
259
- >
260
- > > {assigment}
261
- >
262
- > ## Instructions:
263
- >
264
- > - Write only one name suggestion
265
- > - The name will be used on the website, business cards, visuals, etc.
266
- > ```
267
- >
268
- > `-> {enhancedTitle}` Enhanced title
269
- >
270
- > ## 👤 Website title approval
271
- >
272
- > Is the title for your website okay?
273
- >
274
- > - DIALOG TEMPLATE
275
- >
276
- > ```
277
- > {enhancedTitle}
278
- > ```
279
- >
280
- > `-> {title}` Title for the website
281
- >
282
- > ## 🐰 Cunning subtitle
283
- >
284
- > - PERSONA Josh, a copywriter, tasked with creating a claim for the website.
285
- >
286
- > ```
287
- > As an experienced copywriter, you have been entrusted with creating a claim for the "{title}" web page.
288
- >
289
- > A website assignment from a customer:
290
- >
291
- > > {assigment}
292
- >
293
- > ## Instructions:
294
- >
295
- > - Write only one name suggestion
296
- > - Claim will be used on website, business cards, visuals, etc.
297
- > - Claim should be punchy, funny, original
298
- > ```
299
- >
300
- > `-> {claim}` Claim for the web
301
- >
302
- > ## 🚦 Keyword analysis
303
- >
304
- > - PERSONA Paul, extremely creative SEO specialist.
305
- >
306
- > ```
307
- > As an experienced SEO specialist, you have been entrusted with creating keywords for the website "{title}".
308
- >
309
- > Website assignment from the customer:
310
- >
311
- > > {assigment}
312
- >
313
- > ## Instructions:
314
- >
315
- > - Write a list of keywords
316
- > - Keywords are in basic form
317
- >
318
- > ## Example:
319
- >
320
- > - Ice cream
321
- > - Olomouc
322
- > - Quality
323
- > - Family
324
- > - Tradition
325
- > - Italy
326
- > - Craft
327
- >
328
- > ```
329
- >
330
- > `-> {keywords}` Keywords
331
- >
332
- > ## 🔗 Combine the beginning
333
- >
334
- > - SIMPLE TEMPLATE
335
- >
336
- > ```
337
- >
338
- > # {title}
339
- >
340
- > > {claim}
341
- >
342
- > ```
343
- >
344
- > `-> {contentBeginning}` Beginning of web content
345
- >
346
- > ## 🖋 Write the content
347
- >
348
- > - PERSONA Jane
349
- >
350
- > ```
351
- > As an experienced copywriter and web designer, you have been entrusted with creating text for a new website {title}.
352
- >
353
- > A website assignment from a customer:
354
- >
355
- > > {assigment}
356
- >
357
- > ## Instructions:
358
- >
359
- > - Text formatting is in Markdown
360
- > - Be concise and to the point
361
- > - Use keywords, but they should be naturally in the text
362
- > - This is the complete content of the page, so don't forget all the important information and elements the page should contain
363
- > - Use headings, bullets, text formatting
364
- >
365
- > ## Keywords:
366
- >
367
- > {keywords}
368
- >
369
- > ## Web Content:
370
- >
371
- > {contentBeginning}
372
- > ```
373
- >
374
- > `-> {contentBody}` Middle of the web content
375
- >
376
- > ## 🔗 Combine the content
377
- >
378
- > - SIMPLE TEMPLATE
379
- >
380
- > ```markdown
381
- > {contentBeginning}
382
- >
383
- > {contentBody}
384
- > ```
385
- >
386
- > `-> {websiteContent}`
387
-
388
-
389
-
390
- Following is the scheme how the promptbook above is executed:
391
-
392
- ```mermaid
393
- %% 🔮 Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually
394
-
395
- flowchart LR
396
- subgraph "🌍 Create website content"
397
-
398
- direction TB
399
-
400
- input((Input)):::input
401
- templateSpecifyingTheAssigment(👤 Specifying the assigment)
402
- input--"{rawAssigment}"-->templateSpecifyingTheAssigment
403
- templateImprovingTheTitle(✨ Improving the title)
404
- input--"{rawTitle}"-->templateImprovingTheTitle
405
- templateSpecifyingTheAssigment--"{assigment}"-->templateImprovingTheTitle
406
- templateWebsiteTitleApproval(👤 Website title approval)
407
- templateImprovingTheTitle--"{enhancedTitle}"-->templateWebsiteTitleApproval
408
- templateCunningSubtitle(🐰 Cunning subtitle)
409
- templateWebsiteTitleApproval--"{title}"-->templateCunningSubtitle
410
- templateSpecifyingTheAssigment--"{assigment}"-->templateCunningSubtitle
411
- templateKeywordAnalysis(🚦 Keyword analysis)
412
- templateWebsiteTitleApproval--"{title}"-->templateKeywordAnalysis
413
- templateSpecifyingTheAssigment--"{assigment}"-->templateKeywordAnalysis
414
- templateCombineTheBeginning(🔗 Combine the beginning)
415
- templateWebsiteTitleApproval--"{title}"-->templateCombineTheBeginning
416
- templateCunningSubtitle--"{claim}"-->templateCombineTheBeginning
417
- templateWriteTheContent(🖋 Write the content)
418
- templateWebsiteTitleApproval--"{title}"-->templateWriteTheContent
419
- templateSpecifyingTheAssigment--"{assigment}"-->templateWriteTheContent
420
- templateKeywordAnalysis--"{keywords}"-->templateWriteTheContent
421
- templateCombineTheBeginning--"{contentBeginning}"-->templateWriteTheContent
422
- templateCombineTheContent(🔗 Combine the content)
423
- templateCombineTheBeginning--"{contentBeginning}"-->templateCombineTheContent
424
- templateWriteTheContent--"{contentBody}"-->templateCombineTheContent
425
-
426
- templateCombineTheContent--"{websiteContent}"-->output
427
- output((Output)):::output
428
-
429
- classDef input color: grey;
430
- classDef output color: grey;
431
-
432
- end;
433
- ```
202
+ - Versioning is build in. You can test multiple **A/B versions** of pipelines and see which one works best.
203
+ - 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.
204
+
205
+
206
+
207
+ ## 💙 Book language _(for prompt-engineer)_
208
+
209
+ 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.
434
210
 
435
- - [More template samples](./samples/pipelines/)
436
- - [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)
437
211
 
438
- _Note: We are using [postprocessing functions](#postprocessing-functions) like `unwrapResult` that can be used to postprocess the result._
439
212
 
440
- ## 📦 Packages
213
+ ```markdown
214
+ # 🌟 My first Book
215
+
216
+ - PERSONA Jane, marketing specialist with prior experience in writing articles about technology and artificial intelligence
217
+ - KNOWLEDGE https://ptbk.io
218
+ - KNOWLEDGE ./promptbook.pdf
219
+ - EXPECT MIN 1 Sentence
220
+ - EXPECT MAX 1 Paragraph
221
+
222
+ > 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.
223
+ > Look specifically at the impact of Promptbook on the AI industry.
224
+
225
+ -> {article}
226
+ ```
227
+
228
+ ## 📦 Packages _(for developers)_
441
229
 
442
230
  This library is divided into several packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
443
231
  You can install all of them at once:
@@ -479,8 +267,6 @@ Or you can install them separately:
479
267
 
480
268
  The following glossary is used to clarify certain concepts:
481
269
 
482
-
483
-
484
270
  ### Core concepts
485
271
 
486
272
  - [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
@@ -511,8 +297,8 @@ The following glossary is used to clarify certain concepts:
511
297
 
512
298
  ## 🔌 Usage in Typescript / Javascript
513
299
 
514
- - [Simple usage](./samples/usage/simple-script)
515
- - [Usage with client and remote server](./samples/usage/remote)
300
+ - [Simple usage](./examples/usage/simple-script)
301
+ - [Usage with client and remote server](./examples/usage/remote)
516
302
 
517
303
  ## ➕➖ When to use Promptbook?
518
304
 
package/esm/index.es.js CHANGED
@@ -6,7 +6,7 @@ import spaceTrim$1, { spaceTrim } from 'spacetrim';
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
  /*! *****************************************************************************
@@ -349,10 +349,10 @@ $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', [
349
349
  'content',
350
350
  'context',
351
351
  'knowledge',
352
- 'samples',
352
+ 'examples',
353
353
  'modelName',
354
354
  'currentDate',
355
- // <- TODO: !!!!! list here all command names
355
+ // <- TODO: list here all command names
356
356
  // <- TODO: Add more like 'date', 'modelName',...
357
357
  // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
358
358
  ]);
@@ -1362,12 +1362,12 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
1362
1362
  * Calls OpenAI API to use a chat model.
1363
1363
  */
1364
1364
  AzureOpenAiExecutionTools.prototype.callChatModel = function (prompt) {
1365
- var _a, _b;
1365
+ var _a, _b, _c;
1366
1366
  return __awaiter(this, void 0, void 0, function () {
1367
1367
  var content, parameters, modelRequirements, client, modelName, modelSettings, rawPromptContent, messages, start, complete, rawRequest, rawResponse, resultContent, usage, error_1;
1368
1368
  var _this = this;
1369
- return __generator(this, function (_c) {
1370
- switch (_c.label) {
1369
+ return __generator(this, function (_d) {
1370
+ switch (_d.label) {
1371
1371
  case 0:
1372
1372
  if (this.options.isVerbose) {
1373
1373
  console.info('💬 OpenAI callChatModel call');
@@ -1375,20 +1375,20 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
1375
1375
  content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
1376
1376
  return [4 /*yield*/, this.getClient()];
1377
1377
  case 1:
1378
- client = _c.sent();
1378
+ client = _d.sent();
1379
1379
  // TODO: [☂] Use here more modelRequirements
1380
1380
  if (modelRequirements.modelVariant !== 'CHAT') {
1381
1381
  throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
1382
1382
  }
1383
- _c.label = 2;
1383
+ _d.label = 2;
1384
1384
  case 2:
1385
- _c.trys.push([2, 4, , 5]);
1385
+ _d.trys.push([2, 4, , 5]);
1386
1386
  modelName = prompt.modelRequirements.modelName || this.options.deploymentName;
1387
1387
  modelSettings = {
1388
1388
  maxTokens: modelRequirements.maxTokens,
1389
1389
  // <- TODO: [🌾] Make some global max cap for maxTokens
1390
1390
  temperature: modelRequirements.temperature,
1391
- user: this.options.user,
1391
+ user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
1392
1392
  // <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
1393
1393
  // <- Note: [🧆]
1394
1394
  };
@@ -1419,7 +1419,7 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
1419
1419
  throw error;
1420
1420
  })];
1421
1421
  case 3:
1422
- rawResponse = _c.sent();
1422
+ rawResponse = _d.sent();
1423
1423
  if (this.options.isVerbose) {
1424
1424
  console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
1425
1425
  }
@@ -1438,8 +1438,8 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
1438
1438
  complete = getCurrentIsoDate();
1439
1439
  usage = {
1440
1440
  price: uncertainNumber() /* <- TODO: [🐞] Compute usage */,
1441
- input: __assign({ tokensCount: uncertainNumber((_a = rawResponse.usage) === null || _a === void 0 ? void 0 : _a.promptTokens) }, computeUsageCounts(prompt.content)),
1442
- output: __assign({ tokensCount: uncertainNumber((_b = rawResponse.usage) === null || _b === void 0 ? void 0 : _b.completionTokens) }, computeUsageCounts(prompt.content)),
1441
+ input: __assign({ tokensCount: uncertainNumber((_b = rawResponse.usage) === null || _b === void 0 ? void 0 : _b.promptTokens) }, computeUsageCounts(prompt.content)),
1442
+ output: __assign({ tokensCount: uncertainNumber((_c = rawResponse.usage) === null || _c === void 0 ? void 0 : _c.completionTokens) }, computeUsageCounts(prompt.content)),
1443
1443
  };
1444
1444
  return [2 /*return*/, $asDeeplyFrozenSerializableJson('AzureOpenAiExecutionTools ChatPromptResult', {
1445
1445
  content: resultContent,
@@ -1455,7 +1455,7 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
1455
1455
  // <- [🗯]
1456
1456
  })];
1457
1457
  case 4:
1458
- error_1 = _c.sent();
1458
+ error_1 = _d.sent();
1459
1459
  throw this.transformAzureError(error_1);
1460
1460
  case 5: return [2 /*return*/];
1461
1461
  }
@@ -1466,12 +1466,12 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
1466
1466
  * Calls Azure OpenAI API to use a complete model.
1467
1467
  */
1468
1468
  AzureOpenAiExecutionTools.prototype.callCompletionModel = function (prompt) {
1469
- var _a, _b;
1469
+ var _a, _b, _c;
1470
1470
  return __awaiter(this, void 0, void 0, function () {
1471
1471
  var content, parameters, modelRequirements, client, modelName, modelSettings, start, complete, rawPromptContent, rawRequest, rawResponse, resultContent, usage, error_2;
1472
1472
  var _this = this;
1473
- return __generator(this, function (_c) {
1474
- switch (_c.label) {
1473
+ return __generator(this, function (_d) {
1474
+ switch (_d.label) {
1475
1475
  case 0:
1476
1476
  if (this.options.isVerbose) {
1477
1477
  console.info('🖋 OpenAI callCompletionModel call');
@@ -1479,20 +1479,20 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
1479
1479
  content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
1480
1480
  return [4 /*yield*/, this.getClient()];
1481
1481
  case 1:
1482
- client = _c.sent();
1482
+ client = _d.sent();
1483
1483
  // TODO: [☂] Use here more modelRequirements
1484
1484
  if (modelRequirements.modelVariant !== 'COMPLETION') {
1485
1485
  throw new PipelineExecutionError('Use callCompletionModel only for COMPLETION variant');
1486
1486
  }
1487
- _c.label = 2;
1487
+ _d.label = 2;
1488
1488
  case 2:
1489
- _c.trys.push([2, 4, , 5]);
1489
+ _d.trys.push([2, 4, , 5]);
1490
1490
  modelName = prompt.modelRequirements.modelName || this.options.deploymentName;
1491
1491
  modelSettings = {
1492
1492
  maxTokens: modelRequirements.maxTokens || 2000,
1493
1493
  // <- TODO: [🌾] Make some global max cap for maxTokens
1494
1494
  temperature: modelRequirements.temperature,
1495
- user: this.options.user,
1495
+ user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
1496
1496
  // <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
1497
1497
  // <- Note: [🧆]
1498
1498
  };
@@ -1515,7 +1515,7 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
1515
1515
  throw error;
1516
1516
  })];
1517
1517
  case 3:
1518
- rawResponse = _c.sent();
1518
+ rawResponse = _d.sent();
1519
1519
  if (this.options.isVerbose) {
1520
1520
  console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
1521
1521
  }
@@ -1531,8 +1531,8 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
1531
1531
  complete = getCurrentIsoDate();
1532
1532
  usage = {
1533
1533
  price: uncertainNumber() /* <- TODO: [🐞] Compute usage */,
1534
- input: __assign({ tokensCount: uncertainNumber((_a = rawResponse.usage) === null || _a === void 0 ? void 0 : _a.promptTokens) }, computeUsageCounts(prompt.content)),
1535
- output: __assign({ tokensCount: uncertainNumber((_b = rawResponse.usage) === null || _b === void 0 ? void 0 : _b.completionTokens) }, computeUsageCounts(prompt.content)),
1534
+ input: __assign({ tokensCount: uncertainNumber((_b = rawResponse.usage) === null || _b === void 0 ? void 0 : _b.promptTokens) }, computeUsageCounts(prompt.content)),
1535
+ output: __assign({ tokensCount: uncertainNumber((_c = rawResponse.usage) === null || _c === void 0 ? void 0 : _c.completionTokens) }, computeUsageCounts(prompt.content)),
1536
1536
  };
1537
1537
  return [2 /*return*/, $asDeeplyFrozenSerializableJson('AzureOpenAiExecutionTools CompletionPromptResult', {
1538
1538
  content: resultContent,
@@ -1548,7 +1548,7 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
1548
1548
  // <- [🗯]
1549
1549
  })];
1550
1550
  case 4:
1551
- error_2 = _c.sent();
1551
+ error_2 = _d.sent();
1552
1552
  throw this.transformAzureError(error_2);
1553
1553
  case 5: return [2 /*return*/];
1554
1554
  }
@@ -1737,7 +1737,7 @@ var $Register = /** @class */ (function () {
1737
1737
  this.storage = globalScope[storageName];
1738
1738
  }
1739
1739
  $Register.prototype.list = function () {
1740
- // <- TODO: ReadonlyDeep<Array<TRegistered>>
1740
+ // <- TODO: ReadonlyDeep<ReadonlyArray<TRegistered>>
1741
1741
  return this.storage;
1742
1742
  };
1743
1743
  $Register.prototype.register = function (registered) {