{"name":"@promptbook/utils","version":"0.63.2","keywords":["autogpt","openai","gpt-3","gpt-4","chatgpt","ai","machine-learning","natural-language-processing","nlp","prompt","template","pipeline","automation","text-generation","language-model"],"license":"CC-BY-4.0","_id":"@promptbook/utils@0.63.2","contributors":[{"url":"https://www.pavolhejny.com/","name":"Pavol Hejný","email":"me@pavolhejny.com"}],"homepage":"https://www.npmjs.com/package/@promptbook/core","bugs":{"url":"https://github.com/webgptorg/promptbook/issues"},"dist":{"shasum":"2772574aa12b3a95ff67e73bd6a1177b549d5371","tarball":"http://registry-npm.ywwl.com/@promptbook/utils/download/@promptbook/utils-0.63.2.tgz","fileCount":434,"integrity":"sha512-9mKxJRvx3DV1A1OnHPWZ9/TLzmxIGVMlO4WCv4XdFw2deg6kcpnsQrLv2mZ6NTuAE2e/Upm8jph9qQ7UNryYlA==","signatures":[{"sig":"MEQCIBMBUlAriY9QhZID1ZO+vaebCcX++gLycWqPb4jPCwOdAiB4i3VkKLC+PkiaPW9nH2fqDp18cZdhvjdij4bDXG3jYA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@promptbook%2futils@0.63.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":652621,"size":157366,"noattachment":false,"key":"/@promptbook/utils/-/@promptbook/utils-0.63.2.tgz"},"main":"./umd/index.umd.js","module":"./esm/index.es.js","funding":[{"url":"https://buymeacoffee.com/hejny","type":"individual"},{"url":"https://github.com/webgptorg/promptbook/blob/main/README.md#%EF%B8%8F-contributing","type":"github"}],"gitHead":"556789698b3ea76d2cb2f1b912c0eec36c2e7037","private":false,"typings":"./esm/typings/src/_packages/utils.index.d.ts","_npmUser":{"name":"hejny","email":"pavol@hejny.org"},"repository":{"url":"git+https://github.com/webgptorg/promptbook.git","type":"git"},"_npmVersion":"10.7.0","description":"Supercharge your use of large language models","directories":{},"sideEffects":false,"_nodeVersion":"18.20.4","dependencies":{"spacetrim":"0.11.39"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/utils_0.63.2_1723565641947_0.7560670115039925","host":"s3://npm-registry-packages"},"readme":"<!-- ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten -->\n\n# ![Promptbook logo - cube with letters P and B](./other/design/logo-h1.png) Promptbook\n\nSupercharge your use of large language models\n\n\n\n\n[![NPM Version of ![Promptbook logo - cube with letters P and B](./other/design/logo-h1.png) Promptbook](https://badge.fury.io/js/promptbook.svg)](https://www.npmjs.com/package/promptbook)\n[![Quality of package ![Promptbook logo - cube with letters P and B](./other/design/logo-h1.png) Promptbook](https://packagequality.com/shield/promptbook.svg)](https://packagequality.com/#?package=promptbook)\n[![Known Vulnerabilities](https://snyk.io/test/github/webgptorg/promptbook/badge.svg)](https://snyk.io/test/github/webgptorg/promptbook)\n[![Issues](https://img.shields.io/github/issues/webgptorg/promptbook.svg?style=flat)](https://github.com/webgptorg/promptbook/issues)\n\n\n\n\n\n## 📦 Package `@promptbook/utils`\n\n- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).\n- This package `@promptbook/utils` is one part of the promptbook ecosystem.\n\nTo install this package, run:\n\n```bash\n# Install entire promptbook ecosystem\nnpm i ptbk\n\n# Install just this package to save space\nnpm i @promptbook/utils\n```\n\nUtility functions used in the library but also useful for individual use in preprocessing and postprocessing LLM inputs and outputs\n\nHere is a overview of the functions which are exported from the `@promptbook/utils` package and can be used in your own projects:\n\n## Postprocessing\n\nSometimes you need to postprocess the output of the LLM model, every postprocessing function that is available through `POSTPROCESS` command in promptbook is exported from `@promptbook/utils`. You can use:\n\n-   `spaceTrim`\n-   `extractAllBlocksFromMarkdown`, _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_\n-   `extractAllListItemsFromMarkdown` _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_\n-   `extractBlock`\n-   `extractOneBlockFromMarkdown `_<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_\n-   `prettifyPipelineString`\n-   `removeContentComments`\n-   `removeEmojis`\n-   `removeMarkdownFormatting` _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_\n-   `removeQuotes`\n-   `trimCodeBlock`\n-   `trimEndOfCodeBlock`\n-   `unwrapResult`\n\nVery often you will use `unwrapResult`, which is used to extract the result you need from output with some additional information:\n\n```typescript\nimport { unwrapResult } from '@promptbook/utils';\n\nunwrapResult('Best greeting for the user is \"Hi Pavol!\"'); // 'Hi Pavol!'\n```\n\n## Templating\n\nThere is a function `replaceParameters` which is used to replace the parameters in given template optimized to LLM prompt templates.\n\n```typescript\nimport { replaceParameters } from '@promptbook/utils';\n\nreplaceParameters('Hello, {name}!', { name: 'world' }); // 'Hello, world!'\n```\n\nAnd also multiline templates with blockquotes\n\n```typescript\nimport { replaceParameters, spaceTrim } from '@promptbook/utils';\n\nreplaceParameters(\n    spaceTrim(`\n        Hello, {name}!\n\n        > {answer}\n    `),\n    {\n        name: 'world',\n        answer: spaceTrim(`\n            I'm fine,\n            thank you!\n\n            And you?\n        `),\n    },\n);\n\n// Hello, world!\n//\n// > I'm fine,\n// > thank you!\n// >\n// > And you?\n```\n\n## Counting\n\nTheese functions are usefull to count stats about the input/output in human-like terms not tokens and bytes, you can use\n`countCharacters`, `countLines`, `countPages`, `countParagraphs`, `countSentences`, `countWords`\n\n```typescript\nimport { countWords } from '@promptbook/utils';\n\nconsole.log(countWords('Hello, world!')); // 2\n```\n\n## Splitting\n\nSplitting functions are similar to counting but they return the splitted parts of the input/output, you can use\n`splitIntoCharacters`, `splitIntoLines`, `splitIntoPages`, `splitIntoParagraphs`, `splitIntoSentences`, `splitIntoWords`\n\n```typescript\nimport { splitIntoWords } from '@promptbook/utils';\n\nconsole.log(splitIntoWords('Hello, world!')); // ['Hello', 'world']\n```\n\n## Normalization\n\nNormalization functions are used to put the string into a normalized form, you can use\n`kebab-case`\n`PascalCase`\n`SCREAMING_CASE`\n`snake_case`\n`kebab-case`\n\n```typescript\nimport { normalizeTo } from '@promptbook/utils';\n\nconsole.log(normalizeTo['kebab-case']('Hello, world!')); // 'hello-world'\n```\n\n-   There are more normalization functions like `capitalize`, `decapitalize`, `removeDiacritics`,...\n-   Theese can be also used as postprocessing functions in the `POSTPROCESS` command in promptbook\n\n## Misc\n\nSee also the documentation for all the functions in the `@promptbook/utils` package, every function is documented by jsdoc, typed by typescript and tested by jest.\n\n\n\n`assertsExecutionSuccessful`,\n`checkExpectations`,\n`executionReportJsonToString`,\n`isPassingExpectations`,\n`isValidJsonString`,\n`parseNumber` \n\n\n---\n\nRest of the documentation is common for **entire promptbook ecosystem**:\n\n## 🤍 The Promptbook Whitepaper\n\nIf 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.\n\nBut 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:\n\n1. **Fine-tune** the model to your specifications or even train your own.\n2. **Prompt-engineer** the prompt to the best shape you can achieve.\n3. Use **multiple prompts** in a [pipeline](https://github.com/webgptorg/promptbook/discussions/64) to get the best result.\n\nIn all of these situations, but especially in 3., the Promptbook library can make your life easier.\n\n-   [**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.\n-   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.\n-   **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.\n-   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.\n-   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.\n-   Promptbook has built in versioning. You can test multiple **A/B versions** of pipelines and see which one works best.\n-   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.\n\n## 🧔 Promptbook _(for prompt-engeneers)_\n\n**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.\n\n-   Multiple pipelines forms a **collection** which will handle core **know-how of your LLM application**.\n-   Theese pipelines are designed such as they **can be written by non-programmers**.\n\n\n\n### Sample:\n\nFile `write-website-content.ptbk.md`:\n\n\n\n\n\n> # 🌍 Create website content\n>\n> Instructions for creating web page content.\n>\n> -   PIPELINE URL https://promptbook.studio/webgpt/write-website-content.ptbk.md\n> -   PROMPTBOOK VERSION 0.0.1\n> -   INPUT  PARAM `{rawTitle}` Automatically suggested a site name or empty text\n> -   INPUT  PARAM `{rawAssigment}` Automatically generated site entry from image recognition\n> -   OUTPUT PARAM `{websiteContent}` Web content\n> -   OUTPUT PARAM `{keywords}` Keywords\n>\n> ## 👤 Specifying the assigment\n>\n> What is your web about?\n>\n> -   PROMPT DIALOG\n>\n> ```\n> {rawAssigment}\n> ```\n>\n> `-> {assigment}` Website assignment and specification\n>\n> ## ✨ Improving the title\n>\n> -   PERSONA Jane, Copywriter and Marketing Specialist.\n>\n> ```\n> As an experienced marketing specialist, you have been entrusted with improving the name of your client's business.\n>\n> A suggested name from a client:\n> \"{rawTitle}\"\n>\n> Assignment from customer:\n>\n> > {assigment}\n>\n> ## Instructions:\n>\n> -   Write only one name suggestion\n> -   The name will be used on the website, business cards, visuals, etc.\n> ```\n>\n> `-> {enhancedTitle}` Enhanced title\n>\n> ## 👤 Website title approval\n>\n> Is the title for your website okay?\n>\n> -   PROMPT DIALOG\n>\n> ```\n> {enhancedTitle}\n> ```\n>\n> `-> {title}` Title for the website\n>\n> ## 🐰 Cunning subtitle\n>\n> -   PERSONA Josh, a copywriter, tasked with creating a claim for the website.\n>\n> ```\n> As an experienced copywriter, you have been entrusted with creating a claim for the \"{title}\" web page.\n>\n> A website assignment from a customer:\n>\n> > {assigment}\n>\n> ## Instructions:\n>\n> -   Write only one name suggestion\n> -   Claim will be used on website, business cards, visuals, etc.\n> -   Claim should be punchy, funny, original\n> ```\n>\n> `-> {claim}` Claim for the web\n>\n> ## 🚦 Keyword analysis\n>\n> -   PERSONA Paul, extremely creative SEO specialist.\n>\n> ```\n> As an experienced SEO specialist, you have been entrusted with creating keywords for the website \"{title}\".\n>\n> Website assignment from the customer:\n>\n> > {assigment}\n>\n> ## Instructions:\n>\n> -   Write a list of keywords\n> -   Keywords are in basic form\n>\n> ## Example:\n>\n> -   Ice cream\n> -   Olomouc\n> -   Quality\n> -   Family\n> -   Tradition\n> -   Italy\n> -   Craft\n>\n> ```\n>\n> `-> {keywords}` Keywords\n>\n> ## 🔗 Combine the beginning\n>\n> -   SIMPLE TEMPLATE\n>\n> ```\n>\n> # {title}\n>\n> > {claim}\n>\n> ```\n>\n> `-> {contentBeginning}` Beginning of web content\n>\n> ## 🖋 Write the content\n>\n> -   PERSONA Jane\n>\n> ```\n> As an experienced copywriter and web designer, you have been entrusted with creating text for a new website {title}.\n>\n> A website assignment from a customer:\n>\n> > {assigment}\n>\n> ## Instructions:\n>\n> -   Text formatting is in Markdown\n> -   Be concise and to the point\n> -   Use keywords, but they should be naturally in the text\n> -   This is the complete content of the page, so don't forget all the important information and elements the page should contain\n> -   Use headings, bullets, text formatting\n>\n> ## Keywords:\n>\n> {keywords}\n>\n> ## Web Content:\n>\n> {contentBeginning}\n> ```\n>\n> `-> {contentBody}` Middle of the web content\n>\n> ## 🔗 Combine the content\n>\n> -   SIMPLE TEMPLATE\n>\n> ```markdown\n> {contentBeginning}\n>\n> {contentBody}\n> ```\n>\n> `-> {websiteContent}`\n\n\n\nFollowing is the scheme how the promptbook above is executed:\n\n```mermaid\n%% 🔮 Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\nflowchart LR\n  subgraph \"🌍 Create website content\"\n\n      direction TB\n\n      input((Input)):::input\n      templateSpecifyingTheAssigment(👤 Specifying the assigment)\n      input--\"{rawAssigment}\"-->templateSpecifyingTheAssigment\n      templateImprovingTheTitle(✨ Improving the title)\n      input--\"{rawTitle}\"-->templateImprovingTheTitle\n      templateSpecifyingTheAssigment--\"{assigment}\"-->templateImprovingTheTitle\n      templateWebsiteTitleApproval(👤 Website title approval)\n      templateImprovingTheTitle--\"{enhancedTitle}\"-->templateWebsiteTitleApproval\n      templateCunningSubtitle(🐰 Cunning subtitle)\n      templateWebsiteTitleApproval--\"{title}\"-->templateCunningSubtitle\n      templateSpecifyingTheAssigment--\"{assigment}\"-->templateCunningSubtitle\n      templateKeywordAnalysis(🚦 Keyword analysis)\n      templateWebsiteTitleApproval--\"{title}\"-->templateKeywordAnalysis\n      templateSpecifyingTheAssigment--\"{assigment}\"-->templateKeywordAnalysis\n      templateCombineTheBeginning(🔗 Combine the beginning)\n      templateWebsiteTitleApproval--\"{title}\"-->templateCombineTheBeginning\n      templateCunningSubtitle--\"{claim}\"-->templateCombineTheBeginning\n      templateWriteTheContent(🖋 Write the content)\n      templateWebsiteTitleApproval--\"{title}\"-->templateWriteTheContent\n      templateSpecifyingTheAssigment--\"{assigment}\"-->templateWriteTheContent\n      templateKeywordAnalysis--\"{keywords}\"-->templateWriteTheContent\n      templateCombineTheBeginning--\"{contentBeginning}\"-->templateWriteTheContent\n      templateCombineTheContent(🔗 Combine the content)\n      templateCombineTheBeginning--\"{contentBeginning}\"-->templateCombineTheContent\n      templateWriteTheContent--\"{contentBody}\"-->templateCombineTheContent\n\n      templateCombineTheContent--\"{websiteContent}\"-->output\n      output((Output)):::output\n\n      classDef input color: grey;\n      classDef output color: grey;\n\n  end;\n```\n\n-   [More template samples](./samples/templates/)\n-   [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)\n\n_Note: We are using [postprocessing functions](#postprocessing-functions) like `unwrapResult` that can be used to postprocess the result._\n\n## 📦 Packages\n\nThis library is divided into several packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).\nYou can install all of them at once:\n\n```bash\nnpm i ptbk\n```\n\nOr you can install them separately:\n\n> ⭐ Marked packages are worth to try first\n\n-   ⭐ **[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\n-   **[promptbook](https://www.npmjs.com/package/promptbook)** - Same as `ptbk`\n-   **[@promptbook/core](https://www.npmjs.com/package/@promptbook/core)** - Core of the library, it contains the main logic for promptbooks\n-   **[@promptbook/node](https://www.npmjs.com/package/@promptbook/node)** - Core of the library for Node.js environment\n-   **[@promptbook/browser](https://www.npmjs.com/package/@promptbook/browser)** - Core of the library for browser environment\n-   ⭐ **[@promptbook/utils](https://www.npmjs.com/package/@promptbook/utils)** - Utility functions used in the library but also useful for individual use in preprocessing and postprocessing LLM inputs and outputs\n-   **[@promptbook/markdown-utils](https://www.npmjs.com/package/@promptbook/markdown-utils)** - Utility functions used for processing markdown\n-   _(Not finished)_ **[@promptbook/wizzard](https://www.npmjs.com/package/@promptbook/wizzard)** - Wizard for creating+running promptbooks in single line\n-   **[@promptbook/execute-javascript](https://www.npmjs.com/package/@promptbook/execute-javascript)** - Execution tools for javascript inside promptbooks\n-   **[@promptbook/openai](https://www.npmjs.com/package/@promptbook/openai)** - Execution tools for OpenAI API, wrapper around OpenAI SDK\n-   **[@promptbook/anthropic-claude](https://www.npmjs.com/package/@promptbook/anthropic-claude)** - Execution tools for Anthropic Claude API, wrapper around Anthropic Claude SDK \n-   **[@promptbook/azure-openai](https://www.npmjs.com/package/@promptbook/azure-openai)** - Execution tools for Azure OpenAI API\n-   **[@promptbook/langtail](https://www.npmjs.com/package/@promptbook/langtail)** - Execution tools for Langtail API, wrapper around Langtail SDK\n-   **[@promptbook/fake-llm](https://www.npmjs.com/package/@promptbook/fake-llm)** - Mocked execution tools for testing the library and saving the tokens\n-   **[@promptbook/remote-client](https://www.npmjs.com/package/@promptbook/remote-client)** - Remote client for remote execution of promptbooks\n-   **[@promptbook/remote-server](https://www.npmjs.com/package/@promptbook/remote-server)** - Remote server for remote execution of promptbooks\n-   **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library\n-   **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks\n\n\n\n## 📚 Dictionary\n\nThe following glossary is used to clarify certain concepts:\n\n\n\n### Core concepts\n\n-   [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)\n-   [📯 Pipeline](https://github.com/webgptorg/promptbook/discussions/64)\n-   [🎺 Pipeline templates](https://github.com/webgptorg/promptbook/discussions/88)\n-   [🤼 Personas](https://github.com/webgptorg/promptbook/discussions/22)\n-   [⭕ Parameters](https://github.com/webgptorg/promptbook/discussions/83)\n-   [🚀 Pipeline execution](https://github.com/webgptorg/promptbook/discussions/84)\n-   [🧪 Expectations](https://github.com/webgptorg/promptbook/discussions/30)\n-   [✂️ Postprocessing](https://github.com/webgptorg/promptbook/discussions/31)\n-   [🔣 Words not tokens](https://github.com/webgptorg/promptbook/discussions/29)\n-   [☯ Separation of concerns](https://github.com/webgptorg/promptbook/discussions/32)\n\n### Advanced concepts\n\n-   [📚 Knowledge (Retrieval-augmented generation)](https://github.com/webgptorg/promptbook/discussions/41)\n-   [🌏 Remote server](https://github.com/webgptorg/promptbook/discussions/89)\n-   [🃏 Jokers (conditions)](https://github.com/webgptorg/promptbook/discussions/66)\n-   [🔳 Metaprompting](https://github.com/webgptorg/promptbook/discussions/35)\n-   [🌏 Linguistically typed languages](https://github.com/webgptorg/promptbook/discussions/53)\n-   [🌍 Auto-Translations](https://github.com/webgptorg/promptbook/discussions/42)\n-   [📽 Images, audio, video, spreadsheets](https://github.com/webgptorg/promptbook/discussions/54)\n-   [🔙 Expectation-aware generation](https://github.com/webgptorg/promptbook/discussions/37)\n-   [⏳ Just-in-time fine-tuning](https://github.com/webgptorg/promptbook/discussions/33)\n-   [🔴 Anomaly detection](https://github.com/webgptorg/promptbook/discussions/40)\n-   [👮 Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)\n-   [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)\n\n## 🔌 Usage in Typescript / Javascript\n\n-   [Simple usage](./samples/usage/simple-script)\n-   [Usage with client and remote server](./samples/usage/remote)\n\n## ➕➖ When to use Promptbook?\n\n### ➕ When to use\n\n-   When you are writing app that generates complex things via LLM - like **websites, articles, presentations, code, stories, songs**,...\n-   When you want to **separate code from text prompts**\n-   When you want to describe **complex prompt pipelines** and don't want to do it in the code\n-   When you want to **orchestrate multiple prompts** together\n-   When you want to **reuse** parts of prompts in multiple places\n-   When you want to **version** your prompts and **test multiple versions**\n-   When you want to **log** the execution of prompts and backtrace the issues\n\n### ➖ When not to use\n\n-   When you have already implemented single simple prompt and it works fine for your job\n-   When [OpenAI Assistant (GPTs)](https://help.openai.com/en/articles/8673914-gpts-vs-assistants) is enough for you\n-   When you need streaming _(this may be implemented in the future, [see discussion](https://github.com/webgptorg/promptbook/discussions/102))_.\n-   When you need to use something other than JavaScript or TypeScript _(other languages are on the way, [see the discussion](https://github.com/webgptorg/promptbook/discussions/101))_\n-   When your main focus is on something other than text - like images, audio, video, spreadsheets _(other media types may be added in the future, [see discussion](https://github.com/webgptorg/promptbook/discussions/103))_\n-   When you need to use recursion _([see the discussion](https://github.com/webgptorg/promptbook/discussions/38))_\n\n## 🐜 Known issues\n\n-   [🤸‍♂️ Iterations not working yet](https://github.com/webgptorg/promptbook/discussions/55)\n-   [⤵️ Imports not working yet](https://github.com/webgptorg/promptbook/discussions/34)\n\n## 🧼 Intentionally not implemented features\n\n-   [➿ No recursion](https://github.com/webgptorg/promptbook/discussions/38)\n-   [🏳 There are no types, just strings](https://github.com/webgptorg/promptbook/discussions/52)\n\n## ❔ FAQ\n\n\n\nIf 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).\n\n### Why not just use the OpenAI SDK / Anthropic Claude SDK / ...?\n\nDifferent levels of abstraction. OpenAI library is for direct use of OpenAI API. This library is for a higher level of abstraction. It is for creating prompt templates and promptbooks that are independent of the underlying library, LLM model, or even LLM provider.\n\n### How is it different from the Langchain library?\n\nLangchain is primarily aimed at ML developers working in Python. This library is for developers working in javascript/typescript and creating applications for end users.\n\nWe are considering creating a bridge/converter between these two libraries.\n\n\n\n### Promptbooks vs. OpenAI`s GPTs\n\nGPTs are chat assistants that can be assigned to specific tasks and materials. But they are still chat assistants. Promptbooks are a way to orchestrate many more predefined tasks to have much tighter control over the process. Promptbooks are not a good technology for creating human-like chatbots, GPTs are not a good technology for creating outputs with specific requirements.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### Where should I store my promptbooks?\n\nIf you use raw SDKs, you just put prompts in the sourcecode, mixed in with typescript, javascript, python or whatever programming language you use.\n\nIf you use promptbooks, you can store them in several places, each with its own advantages and disadvantages:\n\n1. As **source code**, typically git-committed. In this case you can use the versioning system and the promptbooks will be tightly coupled with the version of the application. You still get the power of promptbooks, as you separate the concerns of the prompt-engineer and the programmer.\n\n2. As data in a **database** In this case, promptbooks are like posts / articles on the blog. They can be modified independently of the application. You don't need to redeploy the application to change the promptbooks. You can have multiple versions of promptbooks for each user. You can have a web interface for non-programmers to create and modify promptbooks. But you lose the versioning system and you still have to consider the interface between the promptbooks and the application _(= input and output parameters)_.\n\n3. In a **configuration** in environment variables. This is a good way to store promptbooks if you have an application with multiple deployments and you want to have different but simple promptbooks for each deployment and you don't need to change them often.\n\n### What should I do when I need same promptbook in multiple human languages?\n\nA single promptbook can be written for several _(human)_ languages at once. However, we recommend that you have separate promptbooks for each language.\n\nIn large language models, you will get better results if you have prompts in the same language as the user input.\n\nThe best way to manage this is to have suffixed promptbooks like `write-website-content.en.ptbk.md` and `write-website-content.cs.ptbk.md` for each supported language.\n\n\n\n\n\n## ⌚ Changelog\n\nSee [CHANGELOG.md](./CHANGELOG.md)\n\n## 📜 License\n\n<p xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dct=\"http://purl.org/dc/terms/\"><a property=\"dct:title\" rel=\"cc:attributionURL\" href=\"https://github.com/webgptorg/promptbook\">Promptbook</a> by <a rel=\"cc:attributionURL dct:creator\" property=\"cc:attributionName\" href=\"https://github.com/hejny/\">Pavol Hejný</a> is licensed under <a href=\"https://creativecommons.org/licenses/by/4.0/?ref=chooser-v1\" target=\"_blank\" rel=\"license noopener noreferrer\" style=\"display:inline-block;\">CC BY 4.0</a></p>\n\n## 🎯 Todos\n\nSee [TODO.md](./TODO.md)\n\n\n\n\n## 🖋️ Contributing\n\nI am open to pull requests, feedback, and suggestions. Or if you like this utility, you can [☕ buy me a coffee](https://www.buymeacoffee.com/hejny) or [donate via cryptocurrencies](https://github.com/hejny/hejny/blob/main/documents/crypto.md).\n\nYou can also ⭐ star the promptbook package, [follow me on GitHub](https://github.com/hejny) or [various other social networks](https://www.pavolhejny.com/contact/).","publish_time":1723565642297,"maintainers":[{"name":"hejny","email":"pavol@hejny.org"}],"_cnpm_publish_time":1723565642297,"dist-tags":{"latest":"0.114.0-50","legacy":"0.114.0-51"}}