@promptbook/browser 0.92.0-9 → 0.93.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -88
- package/esm/index.es.js +134 -28
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/browser.index.d.ts +2 -0
- package/esm/typings/src/_packages/core.index.d.ts +26 -14
- package/esm/typings/src/_packages/types.index.d.ts +6 -2
- package/esm/typings/src/collection/PipelineCollection.d.ts +0 -2
- package/esm/typings/src/collection/SimplePipelineCollection.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +6 -6
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +0 -2
- package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +36 -28
- package/esm/typings/src/config.d.ts +41 -11
- package/esm/typings/src/constants.d.ts +43 -2
- package/esm/typings/src/conversion/parsePipeline.d.ts +2 -2
- package/esm/typings/src/errors/0-BoilerplateError.d.ts +2 -2
- package/esm/typings/src/errors/CollectionError.d.ts +1 -1
- package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +1 -1
- package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +2 -1
- package/esm/typings/src/executables/apps/locatePandoc.d.ts +2 -1
- package/esm/typings/src/executables/locateApp.d.ts +2 -2
- package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +2 -1
- package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +2 -1
- package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +2 -1
- package/esm/typings/src/execution/AbstractTaskResult.d.ts +1 -1
- package/esm/typings/src/execution/CommonToolsOptions.d.ts +3 -3
- package/esm/typings/src/execution/ExecutionTask.d.ts +19 -1
- package/esm/typings/src/execution/LlmExecutionToolsConstructor.d.ts +2 -1
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +4 -2
- package/esm/typings/src/execution/PromptbookFetch.d.ts +1 -1
- package/esm/typings/src/execution/ScriptExecutionTools.d.ts +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/$OngoingTaskResult.d.ts +12 -9
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +13 -10
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +12 -9
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +15 -3
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +21 -15
- package/esm/typings/src/execution/createPipelineExecutor/computeCosineSimilarity.d.ts +13 -0
- package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +7 -6
- package/esm/typings/src/execution/createPipelineExecutor/getContextForTask.d.ts +5 -1
- package/esm/typings/src/execution/createPipelineExecutor/getExamplesForTask.d.ts +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +12 -9
- package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +18 -5
- package/esm/typings/src/execution/createPipelineExecutor/knowledgePiecesToString.d.ts +9 -0
- package/esm/typings/src/execution/execution-report/ExecutionReportJson.d.ts +1 -1
- package/esm/typings/src/execution/execution-report/ExecutionReportString.d.ts +1 -1
- package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +4 -4
- package/esm/typings/src/execution/utils/checkExpectations.d.ts +3 -3
- package/esm/typings/src/execution/utils/uncertainNumber.d.ts +3 -2
- package/esm/typings/src/execution/utils/usageToWorktime.d.ts +1 -1
- package/esm/typings/src/formats/_common/{FormatDefinition.d.ts → FormatParser.d.ts} +8 -6
- package/esm/typings/src/formats/_common/FormatSubvalueParser.d.ts +66 -0
- package/esm/typings/src/formats/csv/CsvFormatParser.d.ts +17 -0
- package/esm/typings/src/formats/csv/CsvSettings.d.ts +2 -2
- package/esm/typings/src/formats/csv/utils/csvParse.d.ts +12 -0
- package/esm/typings/src/formats/csv/utils/isValidCsvString.d.ts +1 -1
- package/esm/typings/src/formats/index.d.ts +2 -2
- package/esm/typings/src/formats/json/JsonFormatParser.d.ts +19 -0
- package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +1 -1
- package/esm/typings/src/formats/json/utils/jsonParse.d.ts +0 -3
- package/esm/typings/src/formats/text/{TextFormatDefinition.d.ts → TextFormatParser.d.ts} +7 -7
- package/esm/typings/src/formats/xml/XmlFormatParser.d.ts +19 -0
- package/esm/typings/src/formats/xml/utils/isValidXmlString.d.ts +1 -1
- package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +3 -2
- package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +16 -7
- package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +3 -1
- package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +2 -1
- package/esm/typings/src/formfactors/chatbot/ChatbotFormfactorDefinition.d.ts +2 -2
- package/esm/typings/src/formfactors/completion/CompletionFormfactorDefinition.d.ts +29 -0
- package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +2 -1
- package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +2 -2
- package/esm/typings/src/formfactors/index.d.ts +33 -8
- package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +4 -2
- package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +3 -2
- package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +3 -2
- package/esm/typings/src/high-level-abstractions/index.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/$llmToolsMetadataRegister.d.ts +3 -3
- package/esm/typings/src/llm-providers/_common/register/$llmToolsRegister.d.ts +3 -3
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +4 -4
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +4 -3
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +18 -5
- package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +11 -4
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +21 -42
- package/esm/typings/src/llm-providers/_common/register/LlmToolsOptions.d.ts +9 -2
- package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +13 -4
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +10 -5
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +11 -3
- package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +3 -3
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +5 -5
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +6 -0
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +4 -4
- package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +2 -2
- package/esm/typings/src/migrations/migratePipeline.d.ts +9 -0
- package/esm/typings/src/other/templates/getBookTemplates.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineInterface/PipelineInterface.d.ts +3 -3
- package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineInterface/getPipelineInterface.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineInterface/isPipelineImplementingInterface.d.ts +5 -4
- package/esm/typings/src/pipeline/PipelineInterface/isPipelineInterfacesEqual.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineJson/CommonTaskJson.d.ts +10 -7
- package/esm/typings/src/pipeline/PipelineJson/ParameterJson.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +3 -2
- package/esm/typings/src/pipeline/PipelineString.d.ts +3 -1
- package/esm/typings/src/pipeline/book-notation.d.ts +2 -2
- package/esm/typings/src/postprocessing/utils/extractBlock.d.ts +1 -1
- package/esm/typings/src/postprocessing/utils/extractJsonBlock.d.ts +2 -2
- package/esm/typings/src/prepare/prepareTasks.d.ts +8 -5
- package/esm/typings/src/remote-server/openapi.d.ts +1 -1
- package/esm/typings/src/remote-server/socket-types/listModels/PromptbookServer_ListModels_Response.d.ts +1 -1
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -1
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +7 -6
- package/esm/typings/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +3 -3
- package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/Converter.d.ts +3 -1
- package/esm/typings/src/scrapers/_common/Scraper.d.ts +4 -3
- package/esm/typings/src/scrapers/_common/ScraperIntermediateSource.d.ts +4 -2
- package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +2 -2
- package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +2 -1
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +6 -3
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +3 -5
- package/esm/typings/src/scrapers/_common/register/$scrapersMetadataRegister.d.ts +3 -3
- package/esm/typings/src/scrapers/_common/register/$scrapersRegister.d.ts +3 -2
- package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +8 -5
- package/esm/typings/src/scrapers/_common/register/ScraperConstructor.d.ts +2 -1
- package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +6 -5
- package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +3 -1
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +2 -1
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +4 -1
- package/esm/typings/src/scrapers/markitdown/MarkitdownScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +2 -1
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +3 -4
- package/esm/typings/src/scripting/javascript/JavascriptExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +5 -1
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -1
- package/esm/typings/src/storage/file-cache-storage/FileCacheStorage.d.ts +12 -5
- package/esm/typings/src/storage/file-cache-storage/FileCacheStorageOptions.d.ts +4 -2
- package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +2 -1
- package/esm/typings/src/storage/local-storage/getIndexedDbStorage.d.ts +11 -0
- package/esm/typings/src/storage/local-storage/utils/IndexedDbStorageOptions.d.ts +14 -0
- package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.d.ts +8 -0
- package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.d.ts +2 -1
- package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +2 -1
- package/esm/typings/src/types/ModelRequirements.d.ts +2 -2
- package/esm/typings/src/types/ModelVariant.d.ts +5 -5
- package/esm/typings/src/types/typeAliases.d.ts +22 -19
- package/esm/typings/src/utils/$Register.d.ts +8 -7
- package/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +2 -2
- package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.d.ts +4 -1
- package/esm/typings/src/utils/editable/utils/isFlatPipeline.d.ts +2 -1
- package/esm/typings/src/utils/editable/utils/stringifyPipelineJson.d.ts +1 -1
- package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -1
- package/esm/typings/src/utils/expectation-counters/index.d.ts +1 -1
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
- package/esm/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +1 -1
- package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
- package/esm/typings/src/utils/normalization/nameToUriPart.d.ts +4 -4
- package/esm/typings/src/utils/normalization/nameToUriParts.d.ts +4 -4
- package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +3 -3
- package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +3 -3
- package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +4 -4
- package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +3 -3
- package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +3 -3
- package/esm/typings/src/utils/normalization/searchKeywords.d.ts +4 -1
- package/esm/typings/src/utils/normalization/titleToName.d.ts +4 -4
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +1 -1
- package/esm/typings/src/utils/organization/empty_object.d.ts +2 -2
- package/esm/typings/src/utils/organization/just.d.ts +1 -1
- package/esm/typings/src/utils/organization/just_empty_object.d.ts +4 -4
- package/esm/typings/src/utils/organization/keepUnused.d.ts +1 -1
- package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +7 -7
- package/esm/typings/src/utils/removeQuotes.d.ts +2 -2
- package/esm/typings/src/utils/serialization/clonePipeline.d.ts +4 -3
- package/esm/typings/src/utils/serialization/deepClone.d.ts +5 -1
- package/esm/typings/src/utils/trimCodeBlock.d.ts +1 -1
- package/esm/typings/src/utils/trimEndOfCodeBlock.d.ts +1 -1
- package/esm/typings/src/utils/unwrapResult.d.ts +2 -2
- package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +3 -3
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +5 -4
- package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +1 -1
- package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +1 -1
- package/esm/typings/src/utils/validators/url/isHostnameOnPrivateNetwork.d.ts +1 -1
- package/esm/typings/src/utils/validators/url/isUrlOnPrivateNetwork.d.ts +1 -1
- package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +1 -1
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +1 -1
- package/esm/typings/src/version.d.ts +2 -1
- package/esm/typings/src/wizzard/wizzard.d.ts +1 -1
- package/package.json +15 -3
- package/umd/index.umd.js +134 -27
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +0 -31
- package/esm/typings/src/formats/csv/CsvFormatDefinition.d.ts +0 -17
- package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +0 -19
- package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +0 -19
- /package/esm/typings/src/llm-providers/{multiple → _multiple}/MultipleLlmExecutionTools.d.ts +0 -0
- /package/esm/typings/src/llm-providers/{multiple → _multiple}/joinLlmExecutionTools.d.ts +0 -0
- /package/esm/typings/src/llm-providers/{multiple → _multiple}/playground/playground.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<!-- ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten -->
|
|
2
2
|
|
|
3
|
-
# ✨ Promptbook
|
|
3
|
+
# ✨ Promptbook: AI apps in plain Language
|
|
4
|
+
|
|
5
|
+
Write AI applications using plain human language across multiple models and platforms.
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
|
|
@@ -8,24 +10,20 @@
|
|
|
8
10
|
[ Promptbook](https://badge.fury.io/js/promptbook.svg)](https://www.npmjs.com/package/promptbook)
|
|
9
11
|
[ Promptbook](https://packagequality.com/shield/promptbook.svg)](https://packagequality.com/#?package=promptbook)
|
|
10
12
|
[](https://snyk.io/test/github/webgptorg/promptbook)
|
|
13
|
+
[](https://github.com/webgptorg/promptbook/actions)
|
|
14
|
+
[](https://coveralls.io/github/webgptorg/promptbook?branch=main)
|
|
11
15
|
[](https://github.com/webgptorg/promptbook/issues)
|
|
12
16
|
|
|
13
17
|
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
17
19
|
## 🌟 New Features
|
|
18
20
|
|
|
19
|
-
-
|
|
20
|
-
- 🐳
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
|
|
21
|
+
- 💡 VS Code support for `.book` files with syntax highlighting and IntelliSense
|
|
22
|
+
- 🐳 Official Docker image (`hejny/promptbook`) for seamless containerized usage
|
|
23
|
+
- 🔥 Native support for OpenAI `o3-mini`, GPT-4 and other leading LLMs
|
|
24
|
+
- 🔍 DeepSeek integration for advanced knowledge search
|
|
24
25
|
|
|
25
26
|
|
|
26
|
-
<blockquote style="color: #ff8811">
|
|
27
|
-
<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>.
|
|
28
|
-
</blockquote>
|
|
29
27
|
|
|
30
28
|
## 📦 Package `@promptbook/browser`
|
|
31
29
|
|
|
@@ -131,65 +129,92 @@ Hello world examples:
|
|
|
131
129
|
- [Hello world in Node.js](https://github.com/webgptorg/hello-world-node-js)
|
|
132
130
|
- [Hello world in Next.js](https://github.com/webgptorg/hello-world-next-js)
|
|
133
131
|
|
|
132
|
+
### 🌐 Community & Social Media
|
|
134
133
|
|
|
134
|
+
Join our growing community of developers and users:
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
136
|
+
<table>
|
|
137
|
+
<thead>
|
|
138
|
+
<tr>
|
|
139
|
+
<th>Platform</th>
|
|
140
|
+
<th>Description</th>
|
|
141
|
+
</tr>
|
|
142
|
+
</thead>
|
|
143
|
+
<tbody>
|
|
144
|
+
<tr>
|
|
145
|
+
<td><a href="https://discord.gg/x3QWNaa89N">💬 Discord</a></td>
|
|
146
|
+
<td>Join our active developer community for discussions and support</td>
|
|
147
|
+
</tr>
|
|
148
|
+
<tr>
|
|
149
|
+
<td><a href="https://github.com/webgptorg/promptbook/discussions">🗣️ GitHub Discussions</a></td>
|
|
150
|
+
<td>Technical discussions, feature requests, and community Q&A</td>
|
|
151
|
+
</tr>
|
|
152
|
+
<tr>
|
|
153
|
+
<td><a href="https://linkedin.com/company/promptbook">👔 LinkedIn</a></td>
|
|
154
|
+
<td>Professional updates and industry insights</td>
|
|
155
|
+
</tr>
|
|
156
|
+
<tr>
|
|
157
|
+
<td><a href="https://www.facebook.com/61560776453536">📱 Facebook</a></td>
|
|
158
|
+
<td>General announcements and community engagement</td>
|
|
159
|
+
</tr>
|
|
160
|
+
<tr>
|
|
161
|
+
<td><a href="https://ptbk.io">🔗 ptbk.io</a></td>
|
|
162
|
+
<td>Official landing page with project information</td>
|
|
163
|
+
</tr>
|
|
164
|
+
</tbody>
|
|
165
|
+
</table>
|
|
155
166
|
|
|
167
|
+
### 🖼️ Product & Brand Channels
|
|
156
168
|
|
|
157
|
-
|
|
158
|
-
- [Facebook `Promptujeme`](https://www.facebook.com/promptujeme/)
|
|
169
|
+
#### Promptbook.studio
|
|
159
170
|
|
|
160
|
-
|
|
171
|
+
<table>
|
|
172
|
+
<tbody>
|
|
173
|
+
<tr>
|
|
174
|
+
<td><a href="https://www.instagram.com/promptbook.studio/">📸 Instagram @promptbook.studio</a></td>
|
|
175
|
+
<td>Visual updates, UI showcases, and design inspiration</td>
|
|
176
|
+
</tr>
|
|
177
|
+
|
|
178
|
+
</tbody>
|
|
179
|
+
</table>
|
|
161
180
|
|
|
162
|
-
_/Sub-brand for images and graphics generated via Promptbook prompting/_
|
|
163
181
|
|
|
164
|
-
- [Instagram `@promptbook.city`](https://www.instagram.com/promptbook.city/)
|
|
165
|
-
- [Facebook `Promptbook City`](https://www.facebook.com/61565718625569)
|
|
166
182
|
|
|
167
183
|
|
|
168
184
|
|
|
169
185
|
|
|
186
|
+
## 📘 Book Language Blueprint
|
|
170
187
|
|
|
188
|
+
_A concise, Markdown-based DSL for crafting AI workflows and automations._
|
|
171
189
|
|
|
172
|
-
|
|
190
|
+
---
|
|
173
191
|
|
|
192
|
+
### 📑 Table of Contents
|
|
174
193
|
|
|
194
|
+
- [Introduction](#introduction)
|
|
195
|
+
- [Example](#example)
|
|
196
|
+
- [1. What: Workflows, Tasks & Parameters](#1-what-workflows-tasks--parameters)
|
|
197
|
+
- [2. Who: Personas](#2-who-personas)
|
|
198
|
+
- [3. How: Knowledge, Instruments & Actions](#3-how-knowledge-instruments-and-actions)
|
|
199
|
+
- [General Principles](#general-principles)
|
|
175
200
|
|
|
176
|
-
|
|
201
|
+
### Introduction
|
|
177
202
|
|
|
178
|
-
Book is a language that
|
|
203
|
+
Book is a Markdown-based language that simplifies the creation of AI applications, workflows, and automations. With human-readable commands, you can define inputs, outputs, personas, knowledge sources, and actions—without needing model-specific details.
|
|
179
204
|
|
|
180
205
|
### Example
|
|
181
206
|
|
|
182
|
-
```
|
|
183
|
-
# 🌟 My
|
|
207
|
+
```book
|
|
208
|
+
# 🌟 My First Book
|
|
184
209
|
|
|
185
210
|
- BOOK VERSION 1.0.0
|
|
186
211
|
- URL https://promptbook.studio/hello.book
|
|
187
212
|
- INPUT PARAMETER {topic}
|
|
188
213
|
- OUTPUT PARAMETER {article}
|
|
189
214
|
|
|
190
|
-
# Write an
|
|
215
|
+
# Write an Article
|
|
191
216
|
|
|
192
|
-
- PERSONA Jane, marketing specialist with prior experience in
|
|
217
|
+
- PERSONA Jane, marketing specialist with prior experience in tech and AI writing
|
|
193
218
|
- KNOWLEDGE https://wikipedia.org/
|
|
194
219
|
- KNOWLEDGE ./journalist-ethics.pdf
|
|
195
220
|
- EXPECT MIN 1 Sentence
|
|
@@ -197,20 +222,20 @@ Book is a language that can be used to write AI applications, agents, workflows,
|
|
|
197
222
|
|
|
198
223
|
> Write an article about {topic}
|
|
199
224
|
|
|
200
|
-
|
|
225
|
+
→ {article}
|
|
201
226
|
```
|
|
202
227
|
|
|
203
228
|
Each part of the book defines one of 3 circles:
|
|
204
229
|
|
|
205
|
-
### **What:** Workflows, Tasks and Parameters
|
|
230
|
+
### **1. What:** Workflows, Tasks and Parameters
|
|
206
231
|
|
|
207
|
-
What work needs to be done. Each book defines a [workflow
|
|
232
|
+
What work needs to be done. Each book defines a [workflow _(scenario or pipeline)_](https://github.com/webgptorg/promptbook/discussions/88), which is one or more tasks. Each workflow has a fixed input and output. For example, you have a book that generates an article from a topic. Once it generates an article about AI, once about marketing, once about cooking. The workflow (= your AI program) is the same, only the input and output change.
|
|
208
233
|
|
|
209
234
|
**Related commands:**
|
|
210
235
|
|
|
211
236
|
- [PARAMETER](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PARAMETER.md)
|
|
212
237
|
|
|
213
|
-
### **Who:** Personas
|
|
238
|
+
### **2. Who:** Personas
|
|
214
239
|
|
|
215
240
|
Who does the work. Each task is performed by a persona. A persona is a description of your virtual employee. It is a higher abstraction than the model, tokens, temperature, top-k, top-p and other model parameters.
|
|
216
241
|
|
|
@@ -224,7 +249,7 @@ Personas can have access to different knowledge, tools and actions. They can als
|
|
|
224
249
|
|
|
225
250
|
|
|
226
251
|
|
|
227
|
-
### **How:** Knowledge, Instruments and Actions
|
|
252
|
+
### **3. How:** Knowledge, Instruments and Actions
|
|
228
253
|
|
|
229
254
|
The resources used by the personas are used to do the work.
|
|
230
255
|
|
|
@@ -234,7 +259,7 @@ The resources used by the personas are used to do the work.
|
|
|
234
259
|
- [INSTRUMENT](https://github.com/webgptorg/promptbook/blob/main/documents/commands/INSTRUMENT.md) for real-time data like time, location, weather, stock prices, searching the internet, calculations, etc.
|
|
235
260
|
- [ACTION](https://github.com/webgptorg/promptbook/blob/main/documents/commands/ACTION.md) for actions like sending emails, creating files, ending a workflow, etc.
|
|
236
261
|
|
|
237
|
-
### General
|
|
262
|
+
### General Principles
|
|
238
263
|
|
|
239
264
|
Book language is based on markdown. It is subset of markdown. It is designed to be easy to read and write. It is designed to be understandable by both humans and machines and without specific knowledge of the language.
|
|
240
265
|
|
|
@@ -248,6 +273,10 @@ But unlike programming languages, it is designed to be understandable by non-pro
|
|
|
248
273
|
|
|
249
274
|
|
|
250
275
|
|
|
276
|
+
## 📚 Documentation
|
|
277
|
+
|
|
278
|
+
See detailed guides and API reference in the [docs](https://github.com/webgptorg/promptbook/discussions/categories/concepts) or [online](https://discord.gg/x3QWNaa89N).
|
|
279
|
+
|
|
251
280
|
## 🔒 Security
|
|
252
281
|
|
|
253
282
|
For information on reporting security vulnerabilities, see our [Security Policy](./SECURITY.md).
|
|
@@ -291,7 +320,7 @@ Or you can install them separately:
|
|
|
291
320
|
- **[@promptbook/legacy-documents](https://www.npmjs.com/package/@promptbook/legacy-documents)** - Read knowledge from legacy documents like `.doc`, `.rtf`,…
|
|
292
321
|
- **[@promptbook/website-crawler](https://www.npmjs.com/package/@promptbook/website-crawler)** - Crawl knowledge from the web
|
|
293
322
|
- **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API
|
|
294
|
-
- **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** -
|
|
323
|
+
- **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Useful templates and examples of books which can be used as a starting point
|
|
295
324
|
- **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
|
|
296
325
|
- ⭐ **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
|
|
297
326
|
- 🐋 **[Docker image](https://hub.docker.com/r/hejny/promptbook/)** - Promptbook server
|
|
@@ -328,25 +357,56 @@ _Note: This section is not complete dictionary, more list of general AI / LLM te
|
|
|
328
357
|
- [🤼 Personas](https://github.com/webgptorg/promptbook/discussions/22)
|
|
329
358
|
- [⭕ Parameters](https://github.com/webgptorg/promptbook/discussions/83)
|
|
330
359
|
- [🚀 Pipeline execution](https://github.com/webgptorg/promptbook/discussions/84)
|
|
331
|
-
- [🧪 Expectations](https://github.com/webgptorg/promptbook/discussions/30)
|
|
332
|
-
- [✂️ Postprocessing](https://github.com/webgptorg/promptbook/discussions/31)
|
|
333
|
-
- [🔣 Words not tokens](https://github.com/webgptorg/promptbook/discussions/29)
|
|
334
|
-
- [☯ Separation of concerns](https://github.com/webgptorg/promptbook/discussions/32)
|
|
360
|
+
- [🧪 Expectations](https://github.com/webgptorg/promptbook/discussions/30) - Define what outputs should look like and how they're validated
|
|
361
|
+
- [✂️ Postprocessing](https://github.com/webgptorg/promptbook/discussions/31) - How outputs are refined after generation
|
|
362
|
+
- [🔣 Words not tokens](https://github.com/webgptorg/promptbook/discussions/29) - The human-friendly way to think about text generation
|
|
363
|
+
- [☯ Separation of concerns](https://github.com/webgptorg/promptbook/discussions/32) - How Book language organizes different aspects of AI workflows
|
|
335
364
|
|
|
336
|
-
|
|
365
|
+
### Advanced concepts
|
|
366
|
+
|
|
367
|
+
<table>
|
|
368
|
+
<tr>
|
|
369
|
+
<th>Data & Knowledge Management</th>
|
|
370
|
+
<th>Pipeline Control</th>
|
|
371
|
+
</tr>
|
|
372
|
+
<tr>
|
|
373
|
+
<td>
|
|
374
|
+
<ul>
|
|
375
|
+
<li><a href="https://github.com/webgptorg/promptbook/discussions/41">📚 Knowledge (RAG)</a> - Retrieve and use external information</li>
|
|
376
|
+
<li><a href="https://github.com/webgptorg/promptbook/discussions/54">📽 Media handling</a> - Working with images, audio, video, spreadsheets</li>
|
|
377
|
+
<li><a href="https://github.com/webgptorg/promptbook/discussions/40">🔴 Anomaly detection</a> - Identifying unusual patterns or outputs</li>
|
|
378
|
+
</ul>
|
|
379
|
+
</td>
|
|
380
|
+
<td>
|
|
381
|
+
<ul>
|
|
382
|
+
<li><a href="https://github.com/webgptorg/promptbook/discussions/89">🌏 Remote server</a> - Executing workflows on remote infrastructure</li>
|
|
383
|
+
<li><a href="https://github.com/webgptorg/promptbook/discussions/66">🃏 Jokers (conditions)</a> - Adding conditional logic to workflows</li>
|
|
384
|
+
<li><a href="https://github.com/webgptorg/promptbook/discussions/35">🔳 Metaprompting</a> - Creating prompts that generate other prompts</li>
|
|
385
|
+
</ul>
|
|
386
|
+
</td>
|
|
387
|
+
</tr>
|
|
388
|
+
<tr>
|
|
389
|
+
<th>Language & Output Control</th>
|
|
390
|
+
<th>Advanced Generation</th>
|
|
391
|
+
</tr>
|
|
392
|
+
<tr>
|
|
393
|
+
<td>
|
|
394
|
+
<ul>
|
|
395
|
+
<li><a href="https://github.com/webgptorg/promptbook/discussions/53">🌏 Linguistically typed languages</a> - Type systems for natural language</li>
|
|
396
|
+
<li><a href="https://github.com/webgptorg/promptbook/discussions/42">🌍 Auto-Translations</a> - Automatic multilingual support</li>
|
|
397
|
+
<li><a href="https://github.com/webgptorg/promptbook/discussions/39">👮 Agent adversary expectations</a> - Safety and control mechanisms</li>
|
|
398
|
+
</ul>
|
|
399
|
+
</td>
|
|
400
|
+
<td>
|
|
401
|
+
<ul>
|
|
402
|
+
<li><a href="https://github.com/webgptorg/promptbook/discussions/37">🔙 Expectation-aware generation</a> - Outputs that meet defined criteria</li>
|
|
403
|
+
<li><a href="https://github.com/webgptorg/promptbook/discussions/33">⏳ Just-in-time fine-tuning</a> - Dynamic model adaptation</li>
|
|
404
|
+
</ul>
|
|
405
|
+
</td>
|
|
406
|
+
</tr>
|
|
407
|
+
</table>
|
|
337
408
|
|
|
338
|
-
|
|
339
|
-
- [🌏 Remote server](https://github.com/webgptorg/promptbook/discussions/89)
|
|
340
|
-
- [🃏 Jokers (conditions)](https://github.com/webgptorg/promptbook/discussions/66)
|
|
341
|
-
- [🔳 Metaprompting](https://github.com/webgptorg/promptbook/discussions/35)
|
|
342
|
-
- [🌏 Linguistically typed languages](https://github.com/webgptorg/promptbook/discussions/53)
|
|
343
|
-
- [🌍 Auto-Translations](https://github.com/webgptorg/promptbook/discussions/42)
|
|
344
|
-
- [📽 Images, audio, video, spreadsheets](https://github.com/webgptorg/promptbook/discussions/54)
|
|
345
|
-
- [🔙 Expectation-aware generation](https://github.com/webgptorg/promptbook/discussions/37)
|
|
346
|
-
- [⏳ Just-in-time fine-tuning](https://github.com/webgptorg/promptbook/discussions/33)
|
|
347
|
-
- [🔴 Anomaly detection](https://github.com/webgptorg/promptbook/discussions/40)
|
|
348
|
-
- [👮 Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)
|
|
349
|
-
- [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)
|
|
409
|
+
<p align="center"><a href="https://github.com/webgptorg/promptbook/discussions/categories/concepts">🔍 View more concepts</a></p>
|
|
350
410
|
|
|
351
411
|
|
|
352
412
|
|
|
@@ -401,36 +461,28 @@ If you have a question [start a discussion](https://github.com/webgptorg/promptb
|
|
|
401
461
|
- [❔ Is Promptbook using RAG _(Retrieval-Augmented Generation)_?](https://github.com/webgptorg/promptbook/discussions/123)
|
|
402
462
|
- [❔ Is Promptbook using function calling?](https://github.com/webgptorg/promptbook/discussions/124)
|
|
403
463
|
|
|
404
|
-
##
|
|
464
|
+
## 📅 Changelog
|
|
405
465
|
|
|
406
466
|
See [CHANGELOG.md](./CHANGELOG.md)
|
|
407
467
|
|
|
408
468
|
## 📜 License
|
|
409
469
|
|
|
410
|
-
|
|
470
|
+
This project is licensed under [BUSL 1.1](./LICENSE.md).
|
|
411
471
|
|
|
412
|
-
##
|
|
472
|
+
## 🤝 Contributing
|
|
413
473
|
|
|
414
|
-
See [
|
|
474
|
+
We welcome contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
415
475
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
<div style="display: flex; align-items: center; gap: 20px;">
|
|
419
|
-
|
|
420
|
-
<a href="https://promptbook.studio/">
|
|
421
|
-
<img src="./design/promptbook-studio-logo.png" alt="Partner 3" height="70">
|
|
422
|
-
</a>
|
|
423
|
-
|
|
424
|
-
<a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
|
|
425
|
-
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="70">
|
|
426
|
-
</a>
|
|
427
|
-
|
|
428
|
-
</div>
|
|
476
|
+
You can also ⭐ star the project, [follow us on GitHub](https://github.com/hejny) or [various other social networks](https://www.pavolhejny.com/contact/).We are open to [pull requests, feedback, and suggestions](./CONTRIBUTING.md).
|
|
429
477
|
|
|
430
|
-
##
|
|
478
|
+
## 🆘 Support & Community
|
|
431
479
|
|
|
432
|
-
|
|
480
|
+
Need help with Book language? We're here for you!
|
|
433
481
|
|
|
434
|
-
|
|
482
|
+
- 💬 [Join our Discord community](https://discord.gg/x3QWNaa89N) for real-time support
|
|
483
|
+
- 📝 [Browse our GitHub discussions](https://github.com/webgptorg/promptbook/discussions) for FAQs and community knowledge
|
|
484
|
+
- 🐛 [Report issues](https://github.com/webgptorg/book/issues) for bugs or feature requests
|
|
485
|
+
- 📚 Visit [ptbk.io](https://ptbk.io) for more resources and documentation
|
|
486
|
+
- 📧 Contact us directly through the channels listed in our [signpost](./SIGNPOST.md)
|
|
435
487
|
|
|
436
|
-
|
|
488
|
+
We welcome contributions and feedback to make Book language better for everyone!
|
package/esm/index.es.js
CHANGED
|
@@ -16,7 +16,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
16
16
|
* @generated
|
|
17
17
|
* @see https://github.com/webgptorg/promptbook
|
|
18
18
|
*/
|
|
19
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
19
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.93.0';
|
|
20
20
|
/**
|
|
21
21
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
22
22
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -48,7 +48,7 @@ class PipelineExecutionError extends Error {
|
|
|
48
48
|
super(message);
|
|
49
49
|
this.name = 'PipelineExecutionError';
|
|
50
50
|
// TODO: [🐙] DRY - Maybe $randomId
|
|
51
|
-
this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid
|
|
51
|
+
this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
|
|
52
52
|
Object.setPrototypeOf(this, PipelineExecutionError.prototype);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -175,7 +175,7 @@ const ADMIN_GITHUB_NAME = 'hejny';
|
|
|
175
175
|
const LOOP_LIMIT = 1000;
|
|
176
176
|
// <- TODO: [🧜♂️]
|
|
177
177
|
/**
|
|
178
|
-
*
|
|
178
|
+
* Default settings for parsing and generating CSV files in Promptbook.
|
|
179
179
|
*
|
|
180
180
|
* @public exported from `@promptbook/core`
|
|
181
181
|
*/
|
|
@@ -268,7 +268,7 @@ class UnexpectedError extends Error {
|
|
|
268
268
|
${block(message)}
|
|
269
269
|
|
|
270
270
|
Note: This error should not happen.
|
|
271
|
-
It's
|
|
271
|
+
It's probably a bug in the pipeline collection
|
|
272
272
|
|
|
273
273
|
Please report issue:
|
|
274
274
|
${block(getErrorReportUrl(new Error(message)).href)}
|
|
@@ -282,7 +282,8 @@ class UnexpectedError extends Error {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
/**
|
|
285
|
-
*
|
|
285
|
+
* Safely retrieves the global scope object (window in browser, global in Node.js)
|
|
286
|
+
* regardless of the JavaScript environment in which the code is running
|
|
286
287
|
*
|
|
287
288
|
* Note: `$` is used to indicate that this function is not a pure function - it access global scope
|
|
288
289
|
*
|
|
@@ -293,10 +294,10 @@ function $getGlobalScope() {
|
|
|
293
294
|
}
|
|
294
295
|
|
|
295
296
|
/**
|
|
296
|
-
*
|
|
297
|
+
* Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
|
|
297
298
|
*
|
|
298
|
-
* @param text
|
|
299
|
-
* @returns
|
|
299
|
+
* @param text The text string to be converted to SCREAMING_CASE format.
|
|
300
|
+
* @returns The normalized text in SCREAMING_CASE format.
|
|
300
301
|
* @example 'HELLO_WORLD'
|
|
301
302
|
* @example 'I_LOVE_PROMPTBOOK'
|
|
302
303
|
* @public exported from `@promptbook/utils`
|
|
@@ -348,10 +349,10 @@ function normalizeTo_SCREAMING_CASE(text) {
|
|
|
348
349
|
*/
|
|
349
350
|
|
|
350
351
|
/**
|
|
351
|
-
*
|
|
352
|
+
* Normalizes a text string to snake_case format.
|
|
352
353
|
*
|
|
353
|
-
* @param text
|
|
354
|
-
* @returns
|
|
354
|
+
* @param text The text string to be converted to snake_case format.
|
|
355
|
+
* @returns The normalized text in snake_case format.
|
|
355
356
|
* @example 'hello_world'
|
|
356
357
|
* @example 'i_love_promptbook'
|
|
357
358
|
* @public exported from `@promptbook/utils`
|
|
@@ -361,11 +362,11 @@ function normalizeTo_snake_case(text) {
|
|
|
361
362
|
}
|
|
362
363
|
|
|
363
364
|
/**
|
|
364
|
-
*
|
|
365
|
+
* Global registry for storing and managing registered entities of a given type.
|
|
365
366
|
*
|
|
366
367
|
* Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope.
|
|
367
368
|
*
|
|
368
|
-
* @private internal utility, exported are only
|
|
369
|
+
* @private internal utility, exported are only singleton instances of this class
|
|
369
370
|
*/
|
|
370
371
|
class $Register {
|
|
371
372
|
constructor(registerName) {
|
|
@@ -409,10 +410,11 @@ class $Register {
|
|
|
409
410
|
}
|
|
410
411
|
|
|
411
412
|
/**
|
|
412
|
-
*
|
|
413
|
+
* Registry for all available scrapers in the system.
|
|
414
|
+
* Central point for registering and accessing different types of content scrapers.
|
|
413
415
|
*
|
|
414
416
|
* Note: `$` is used to indicate that this interacts with the global scope
|
|
415
|
-
* @singleton Only one instance of each register is created per build, but
|
|
417
|
+
* @singleton Only one instance of each register is created per build, but there can be more than one in different build modules
|
|
416
418
|
* @public exported from `@promptbook/core`
|
|
417
419
|
*/
|
|
418
420
|
const $scrapersRegister = new $Register('scraper_constructors');
|
|
@@ -421,10 +423,13 @@ const $scrapersRegister = new $Register('scraper_constructors');
|
|
|
421
423
|
*/
|
|
422
424
|
|
|
423
425
|
/**
|
|
424
|
-
*
|
|
426
|
+
* Provides a collection of scrapers optimized for browser environments.
|
|
427
|
+
* Only includes scrapers that can safely run in a browser context.
|
|
425
428
|
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
429
|
+
* Note: Browser scrapers have limitations compared to Node.js scrapers.
|
|
430
|
+
*
|
|
431
|
+
* 1) `provideScrapersForNode` use as default
|
|
432
|
+
* 2) `provideScrapersForBrowser` use in limited browser environment
|
|
428
433
|
*
|
|
429
434
|
* @public exported from `@promptbook/browser`
|
|
430
435
|
*/
|
|
@@ -444,6 +449,85 @@ async function $provideScrapersForBrowser(tools, options) {
|
|
|
444
449
|
return scrapers;
|
|
445
450
|
}
|
|
446
451
|
|
|
452
|
+
/**
|
|
453
|
+
* Creates a PromptbookStorage backed by IndexedDB.
|
|
454
|
+
* Uses a single object store named 'promptbook'.
|
|
455
|
+
* @private for `getIndexedDbStorage`
|
|
456
|
+
*/
|
|
457
|
+
function makePromptbookStorageFromIndexedDb(options) {
|
|
458
|
+
const { databaseName, storeName } = options;
|
|
459
|
+
function getDatabase() {
|
|
460
|
+
return new Promise((resolve, reject) => {
|
|
461
|
+
const request = indexedDB.open(databaseName, 1);
|
|
462
|
+
request.onupgradeneeded = () => {
|
|
463
|
+
request.result.createObjectStore(storeName);
|
|
464
|
+
};
|
|
465
|
+
request.onsuccess = () => resolve(request.result);
|
|
466
|
+
request.onerror = () => reject(request.error);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
return {
|
|
470
|
+
async getItem(key) {
|
|
471
|
+
const database = await getDatabase();
|
|
472
|
+
return new Promise((resolve, reject) => {
|
|
473
|
+
const transaction = database.transaction(storeName, 'readonly');
|
|
474
|
+
const objectStore = transaction.objectStore(storeName);
|
|
475
|
+
const request = objectStore.get(key);
|
|
476
|
+
request.onsuccess = () => { var _a; return resolve((_a = request.result) !== null && _a !== void 0 ? _a : null); };
|
|
477
|
+
request.onerror = () => reject(request.error);
|
|
478
|
+
});
|
|
479
|
+
},
|
|
480
|
+
async setItem(key, value) {
|
|
481
|
+
const database = await getDatabase();
|
|
482
|
+
return new Promise((resolve, reject) => {
|
|
483
|
+
const transaction = database.transaction(storeName, 'readwrite');
|
|
484
|
+
const objectStore = transaction.objectStore(storeName);
|
|
485
|
+
const request = objectStore.put(value, key);
|
|
486
|
+
request.onsuccess = () => resolve();
|
|
487
|
+
request.onerror = () => reject(request.error);
|
|
488
|
+
});
|
|
489
|
+
},
|
|
490
|
+
async removeItem(key) {
|
|
491
|
+
const database = await getDatabase();
|
|
492
|
+
return new Promise((resolve, reject) => {
|
|
493
|
+
const transaction = database.transaction(storeName, 'readwrite');
|
|
494
|
+
const objectStore = transaction.objectStore(storeName);
|
|
495
|
+
const request = objectStore.delete(key);
|
|
496
|
+
request.onsuccess = () => resolve();
|
|
497
|
+
request.onerror = () => reject(request.error);
|
|
498
|
+
});
|
|
499
|
+
},
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Cache storage
|
|
505
|
+
*
|
|
506
|
+
* @private internal cache for `getIndexedDbStorage`
|
|
507
|
+
*/
|
|
508
|
+
const indexedDbStorageCache = new Map();
|
|
509
|
+
/**
|
|
510
|
+
* Gets wrapper around IndexedDB which can be used as PromptbookStorage
|
|
511
|
+
*
|
|
512
|
+
* @public exported from `@promptbook/browser`
|
|
513
|
+
*/
|
|
514
|
+
function getIndexedDbStorage(options) {
|
|
515
|
+
if (!isRunningInBrowser()) {
|
|
516
|
+
throw new EnvironmentMismatchError(`You can get IndexedDB storage only in browser environment`);
|
|
517
|
+
}
|
|
518
|
+
const { databaseName, storeName } = options;
|
|
519
|
+
const cacheKey = `${databaseName}/${storeName}`;
|
|
520
|
+
if (indexedDbStorageCache.has(cacheKey)) {
|
|
521
|
+
return indexedDbStorageCache.get(cacheKey);
|
|
522
|
+
}
|
|
523
|
+
const storage = makePromptbookStorageFromIndexedDb({ databaseName, storeName });
|
|
524
|
+
indexedDbStorageCache.set(cacheKey, storage);
|
|
525
|
+
return storage;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
|
|
529
|
+
*/
|
|
530
|
+
|
|
447
531
|
/**
|
|
448
532
|
* Converts a JavaScript Object Notation (JSON) string into an object.
|
|
449
533
|
*
|
|
@@ -473,15 +557,12 @@ function jsonParse(value) {
|
|
|
473
557
|
}
|
|
474
558
|
throw new Error(spaceTrim$1((block) => `
|
|
475
559
|
${block(error.message)}
|
|
476
|
-
|
|
560
|
+
|
|
477
561
|
The JSON text:
|
|
478
562
|
${block(value)}
|
|
479
563
|
`));
|
|
480
564
|
}
|
|
481
565
|
}
|
|
482
|
-
/**
|
|
483
|
-
* TODO: !!!! Use in Promptbook.studio
|
|
484
|
-
*/
|
|
485
566
|
|
|
486
567
|
/**
|
|
487
568
|
* Orders JSON object by keys
|
|
@@ -712,8 +793,12 @@ function checkSerializableAsJson(options) {
|
|
|
712
793
|
*/
|
|
713
794
|
|
|
714
795
|
/**
|
|
715
|
-
*
|
|
796
|
+
* Creates a deep clone of the given object
|
|
716
797
|
*
|
|
798
|
+
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
799
|
+
*
|
|
800
|
+
* @param objectValue The object to clone.
|
|
801
|
+
* @returns A deep, writable clone of the input object.
|
|
717
802
|
* @public exported from `@promptbook/utils`
|
|
718
803
|
*/
|
|
719
804
|
function deepClone(objectValue) {
|
|
@@ -859,14 +944,15 @@ function stringifyPipelineJson(pipeline) {
|
|
|
859
944
|
return pipelineJsonStringified;
|
|
860
945
|
}
|
|
861
946
|
/**
|
|
862
|
-
* TODO: [🐝] Not Working
|
|
947
|
+
* TODO: [🐝] Not Working properly @see https://promptbook.studio/examples/mixed-knowledge.book
|
|
863
948
|
* TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
|
|
864
949
|
* TODO: [🧠] Maybe more elegant solution than replacing via regex
|
|
865
950
|
* TODO: [🍙] Make some standard order of json properties
|
|
866
951
|
*/
|
|
867
952
|
|
|
868
953
|
/**
|
|
869
|
-
*
|
|
954
|
+
* Creates a Promptbook storage interface from a web storage object.
|
|
955
|
+
* Facilitates using Web Storage (localStorage/sessionStorage) as a storage backend.
|
|
870
956
|
*
|
|
871
957
|
* @private for `getLocalStorage` and `getSessionStorage`
|
|
872
958
|
*/
|
|
@@ -898,6 +984,12 @@ function makePromptbookStorageFromWebStorage(webStorage) {
|
|
|
898
984
|
* TODO: [🌗] Maybe some checkers, not all valid JSONs are desired and valid values
|
|
899
985
|
*/
|
|
900
986
|
|
|
987
|
+
/**
|
|
988
|
+
* Cache storage
|
|
989
|
+
*
|
|
990
|
+
* @private internal cache for `getLocalStorage`
|
|
991
|
+
*/
|
|
992
|
+
let promptbookLocalStorage = null;
|
|
901
993
|
/**
|
|
902
994
|
* Gets wrapper around `localStorage` object which can be used as `PromptbookStorage`
|
|
903
995
|
*
|
|
@@ -907,12 +999,22 @@ function getLocalStorage() {
|
|
|
907
999
|
if (!isRunningInBrowser()) {
|
|
908
1000
|
throw new EnvironmentMismatchError(`You can get localStorage works only in browser environment`);
|
|
909
1001
|
}
|
|
910
|
-
|
|
1002
|
+
if (promptbookLocalStorage) {
|
|
1003
|
+
return promptbookLocalStorage;
|
|
1004
|
+
}
|
|
1005
|
+
promptbookLocalStorage = makePromptbookStorageFromWebStorage(localStorage);
|
|
1006
|
+
return promptbookLocalStorage;
|
|
911
1007
|
}
|
|
912
1008
|
/**
|
|
913
1009
|
* Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
|
|
914
1010
|
*/
|
|
915
1011
|
|
|
1012
|
+
/**
|
|
1013
|
+
* Cache storage
|
|
1014
|
+
*
|
|
1015
|
+
* @private internal cache for `getSessionStorage`
|
|
1016
|
+
*/
|
|
1017
|
+
let promptbookSessionStorage = null;
|
|
916
1018
|
/**
|
|
917
1019
|
* Gets wrapper around `sessionStorage` object which can be used as `PromptbookStorage`
|
|
918
1020
|
*
|
|
@@ -922,11 +1024,15 @@ function getSessionStorage() {
|
|
|
922
1024
|
if (!isRunningInBrowser()) {
|
|
923
1025
|
throw new EnvironmentMismatchError(`You can get sessionStorage works only in browser environment`);
|
|
924
1026
|
}
|
|
925
|
-
|
|
1027
|
+
if (promptbookSessionStorage) {
|
|
1028
|
+
return promptbookSessionStorage;
|
|
1029
|
+
}
|
|
1030
|
+
promptbookSessionStorage = makePromptbookStorageFromWebStorage(sessionStorage);
|
|
1031
|
+
return promptbookSessionStorage;
|
|
926
1032
|
}
|
|
927
1033
|
/**
|
|
928
1034
|
* Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
|
|
929
1035
|
*/
|
|
930
1036
|
|
|
931
|
-
export { $provideScrapersForBrowser, BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, SimplePromptInterfaceTools, getLocalStorage, getSessionStorage };
|
|
1037
|
+
export { $provideScrapersForBrowser, BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, SimplePromptInterfaceTools, getIndexedDbStorage, getLocalStorage, getSessionStorage };
|
|
932
1038
|
//# sourceMappingURL=index.es.js.map
|