@promptbook/editable 0.92.0-8 → 0.92.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 +1 -5
- package/esm/index.es.js +205 -118
- 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 +5 -1
- 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 +5 -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/OpenAiExecutionTools.d.ts +4 -0
- 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 +14 -2
- package/umd/index.umd.js +205 -118
- 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/esm/index.es.js
CHANGED
|
@@ -17,7 +17,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
17
17
|
* @generated
|
|
18
18
|
* @see https://github.com/webgptorg/promptbook
|
|
19
19
|
*/
|
|
20
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0
|
|
20
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0';
|
|
21
21
|
/**
|
|
22
22
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
23
23
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -27,7 +27,7 @@ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-8';
|
|
|
27
27
|
* Returns the same value that is passed as argument.
|
|
28
28
|
* No side effects.
|
|
29
29
|
*
|
|
30
|
-
* Note: It can be
|
|
30
|
+
* Note: It can be useful for:
|
|
31
31
|
*
|
|
32
32
|
* 1) Leveling indentation
|
|
33
33
|
* 2) Putting always-true or always-false conditions without getting eslint errors
|
|
@@ -85,7 +85,7 @@ const DEFAULT_BOOK_OUTPUT_PARAMETER_NAME = 'result';
|
|
|
85
85
|
const LOOP_LIMIT = 1000;
|
|
86
86
|
// <- TODO: [🧜♂️]
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
88
|
+
* Default settings for parsing and generating CSV files in Promptbook.
|
|
89
89
|
*
|
|
90
90
|
* @public exported from `@promptbook/core`
|
|
91
91
|
*/
|
|
@@ -155,7 +155,7 @@ class UnexpectedError extends Error {
|
|
|
155
155
|
${block(message)}
|
|
156
156
|
|
|
157
157
|
Note: This error should not happen.
|
|
158
|
-
It's
|
|
158
|
+
It's probably a bug in the pipeline collection
|
|
159
159
|
|
|
160
160
|
Please report issue:
|
|
161
161
|
${block(getErrorReportUrl(new Error(message)).href)}
|
|
@@ -187,7 +187,7 @@ class ParseError extends Error {
|
|
|
187
187
|
/**
|
|
188
188
|
* Parses the boilerplate command
|
|
189
189
|
*
|
|
190
|
-
* Note:
|
|
190
|
+
* Note: @@ This command is used as boilerplate for new commands - it should NOT be used in any `.book` file
|
|
191
191
|
*
|
|
192
192
|
* @see `documentationUrl` for more details
|
|
193
193
|
* @private within the commands folder
|
|
@@ -303,7 +303,7 @@ class NotYetImplementedError extends Error {
|
|
|
303
303
|
/**
|
|
304
304
|
* Tests if given string is valid semantic version
|
|
305
305
|
*
|
|
306
|
-
* Note: There are two
|
|
306
|
+
* Note: There are two similar functions:
|
|
307
307
|
* - `isValidSemanticVersion` which tests any semantic version
|
|
308
308
|
* - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
|
|
309
309
|
*
|
|
@@ -325,7 +325,7 @@ function isValidSemanticVersion(version) {
|
|
|
325
325
|
*
|
|
326
326
|
* @see https://www.npmjs.com/package/promptbook?activeTab=versions
|
|
327
327
|
* Note: When you are using for example promptbook 2.0.0 and there already is promptbook 3.0.0 it don`t know about it.
|
|
328
|
-
* Note: There are two
|
|
328
|
+
* Note: There are two similar functions:
|
|
329
329
|
* - `isValidSemanticVersion` which tests any semantic version
|
|
330
330
|
* - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
|
|
331
331
|
*
|
|
@@ -718,7 +718,7 @@ class CsvFormatError extends AbstractFormatError {
|
|
|
718
718
|
}
|
|
719
719
|
|
|
720
720
|
/**
|
|
721
|
-
*
|
|
721
|
+
* Contains configuration options for parsing and generating CSV files, such as delimiters and quoting rules.
|
|
722
722
|
*
|
|
723
723
|
* @public exported from `@promptbook/core`
|
|
724
724
|
*/
|
|
@@ -727,11 +727,29 @@ const MANDATORY_CSV_SETTINGS = Object.freeze({
|
|
|
727
727
|
// encoding: 'utf-8',
|
|
728
728
|
});
|
|
729
729
|
|
|
730
|
+
/**
|
|
731
|
+
* Converts a CSV string into an object
|
|
732
|
+
*
|
|
733
|
+
* Note: This is wrapper around `papaparse.parse()` with better autohealing
|
|
734
|
+
*
|
|
735
|
+
* @private - for now until `@promptbook/csv` is released
|
|
736
|
+
*/
|
|
737
|
+
function csvParse(value /* <- TODO: string_csv */, settings, schema /* <- TODO: Make CSV Schemas */) {
|
|
738
|
+
settings = { ...settings, ...MANDATORY_CSV_SETTINGS };
|
|
739
|
+
// Note: Autoheal invalid '\n' characters
|
|
740
|
+
if (settings.newline && !settings.newline.includes('\r') && value.includes('\r')) {
|
|
741
|
+
console.warn('CSV string contains carriage return characters, but in the CSV settings the `newline` setting does not include them. Autohealing the CSV string.');
|
|
742
|
+
value = value.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
743
|
+
}
|
|
744
|
+
const csv = parse(value, settings);
|
|
745
|
+
return csv;
|
|
746
|
+
}
|
|
747
|
+
|
|
730
748
|
/**
|
|
731
749
|
* Function to check if a string is valid CSV
|
|
732
750
|
*
|
|
733
751
|
* @param value The string to check
|
|
734
|
-
* @returns
|
|
752
|
+
* @returns `true` if the string is a valid CSV string, false otherwise
|
|
735
753
|
*
|
|
736
754
|
* @public exported from `@promptbook/utils`
|
|
737
755
|
*/
|
|
@@ -755,7 +773,7 @@ function isValidCsvString(value) {
|
|
|
755
773
|
* @public exported from `@promptbook/core`
|
|
756
774
|
* <- TODO: [🏢] Export from package `@promptbook/csv`
|
|
757
775
|
*/
|
|
758
|
-
const
|
|
776
|
+
const CsvFormatParser = {
|
|
759
777
|
formatName: 'CSV',
|
|
760
778
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
761
779
|
isValid(value, settings, schema) {
|
|
@@ -767,12 +785,12 @@ const CsvFormatDefinition = {
|
|
|
767
785
|
heal(value, settings, schema) {
|
|
768
786
|
throw new Error('Not implemented');
|
|
769
787
|
},
|
|
770
|
-
|
|
788
|
+
subvalueParsers: [
|
|
771
789
|
{
|
|
772
790
|
subvalueName: 'ROW',
|
|
773
|
-
async mapValues(
|
|
774
|
-
|
|
775
|
-
const csv =
|
|
791
|
+
async mapValues(options) {
|
|
792
|
+
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
793
|
+
const csv = csvParse(value, settings);
|
|
776
794
|
if (csv.errors.length !== 0) {
|
|
777
795
|
throw new CsvFormatError(spaceTrim((block) => `
|
|
778
796
|
CSV parsing error
|
|
@@ -787,23 +805,37 @@ const CsvFormatDefinition = {
|
|
|
787
805
|
${block(value)}
|
|
788
806
|
`));
|
|
789
807
|
}
|
|
790
|
-
const mappedData =
|
|
808
|
+
const mappedData = [];
|
|
809
|
+
const length = csv.data.length;
|
|
810
|
+
for (let index = 0; index < length; index++) {
|
|
811
|
+
const row = csv.data[index];
|
|
791
812
|
if (row[outputParameterName]) {
|
|
792
813
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
793
814
|
}
|
|
794
|
-
|
|
815
|
+
const mappedRow = {
|
|
795
816
|
...row,
|
|
796
|
-
[outputParameterName]: await mapCallback(row, index),
|
|
817
|
+
[outputParameterName]: await mapCallback(row, index, length),
|
|
797
818
|
};
|
|
798
|
-
|
|
819
|
+
mappedData.push(mappedRow);
|
|
820
|
+
if (onProgress) {
|
|
821
|
+
// Note: Report the CSV with all rows mapped so far
|
|
822
|
+
/*
|
|
823
|
+
// TODO: [🛕] Report progress with all the rows including the pending ones
|
|
824
|
+
const progressData = mappedData.map((row, i) =>
|
|
825
|
+
i > index ? { ...row, [outputParameterName]: PENDING_VALUE_PLACEHOLDER } : row,
|
|
826
|
+
);
|
|
827
|
+
*/
|
|
828
|
+
await onProgress(unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
829
|
+
}
|
|
830
|
+
}
|
|
799
831
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
800
832
|
},
|
|
801
833
|
},
|
|
802
834
|
{
|
|
803
835
|
subvalueName: 'CELL',
|
|
804
|
-
async mapValues(
|
|
805
|
-
|
|
806
|
-
const csv =
|
|
836
|
+
async mapValues(options) {
|
|
837
|
+
const { value, settings, mapCallback, onProgress } = options;
|
|
838
|
+
const csv = csvParse(value, settings);
|
|
807
839
|
if (csv.errors.length !== 0) {
|
|
808
840
|
throw new CsvFormatError(spaceTrim((block) => `
|
|
809
841
|
CSV parsing error
|
|
@@ -819,9 +851,9 @@ const CsvFormatDefinition = {
|
|
|
819
851
|
`));
|
|
820
852
|
}
|
|
821
853
|
const mappedData = await Promise.all(csv.data.map(async (row, rowIndex) => {
|
|
822
|
-
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex) => {
|
|
854
|
+
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex, array) => {
|
|
823
855
|
const index = rowIndex * Object.keys(row).length + columnIndex;
|
|
824
|
-
return /* not await */ mapCallback({ [key]: value }, index);
|
|
856
|
+
return /* not await */ mapCallback({ [key]: value }, index, array.length);
|
|
825
857
|
}));
|
|
826
858
|
}));
|
|
827
859
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
@@ -830,10 +862,10 @@ const CsvFormatDefinition = {
|
|
|
830
862
|
],
|
|
831
863
|
};
|
|
832
864
|
/**
|
|
833
|
-
* TODO: [🍓] In `
|
|
834
|
-
* TODO: [🍓] In `
|
|
835
|
-
* TODO: [🍓] In `
|
|
836
|
-
* TODO: [🍓] In `
|
|
865
|
+
* TODO: [🍓] In `CsvFormatParser` implement simple `isValid`
|
|
866
|
+
* TODO: [🍓] In `CsvFormatParser` implement partial `canBeValid`
|
|
867
|
+
* TODO: [🍓] In `CsvFormatParser` implement `heal
|
|
868
|
+
* TODO: [🍓] In `CsvFormatParser` implement `subvalueParsers`
|
|
837
869
|
* TODO: [🏢] Allow to expect something inside CSV objects and other formats
|
|
838
870
|
*/
|
|
839
871
|
|
|
@@ -841,7 +873,7 @@ const CsvFormatDefinition = {
|
|
|
841
873
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
842
874
|
*
|
|
843
875
|
* @param value The string to check
|
|
844
|
-
* @returns
|
|
876
|
+
* @returns `true` if the string is a valid JSON string, false otherwise
|
|
845
877
|
*
|
|
846
878
|
* @public exported from `@promptbook/utils`
|
|
847
879
|
*/
|
|
@@ -864,7 +896,7 @@ function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
|
864
896
|
*
|
|
865
897
|
* @private still in development [🏢]
|
|
866
898
|
*/
|
|
867
|
-
const
|
|
899
|
+
const JsonFormatParser = {
|
|
868
900
|
formatName: 'JSON',
|
|
869
901
|
mimeType: 'application/json',
|
|
870
902
|
isValid(value, settings, schema) {
|
|
@@ -876,28 +908,28 @@ const JsonFormatDefinition = {
|
|
|
876
908
|
heal(value, settings, schema) {
|
|
877
909
|
throw new Error('Not implemented');
|
|
878
910
|
},
|
|
879
|
-
|
|
911
|
+
subvalueParsers: [],
|
|
880
912
|
};
|
|
881
913
|
/**
|
|
882
|
-
* TODO: [🧠] Maybe
|
|
914
|
+
* TODO: [🧠] Maybe proper instance of object
|
|
883
915
|
* TODO: [0] Make string_serialized_json
|
|
884
916
|
* TODO: [1] Make type for JSON Settings and Schema
|
|
885
917
|
* TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
|
|
886
|
-
* TODO: [🍓] In `
|
|
887
|
-
* TODO: [🍓] In `
|
|
888
|
-
* TODO: [🍓] In `
|
|
889
|
-
* TODO: [🍓] In `
|
|
918
|
+
* TODO: [🍓] In `JsonFormatParser` implement simple `isValid`
|
|
919
|
+
* TODO: [🍓] In `JsonFormatParser` implement partial `canBeValid`
|
|
920
|
+
* TODO: [🍓] In `JsonFormatParser` implement `heal
|
|
921
|
+
* TODO: [🍓] In `JsonFormatParser` implement `subvalueParsers`
|
|
890
922
|
* TODO: [🏢] Allow to expect something inside JSON objects and other formats
|
|
891
923
|
*/
|
|
892
924
|
|
|
893
925
|
/**
|
|
894
926
|
* Definition for any text - this will be always valid
|
|
895
927
|
*
|
|
896
|
-
* Note: This is not useful for validation, but for splitting and mapping with `
|
|
928
|
+
* Note: This is not useful for validation, but for splitting and mapping with `subvalueParsers`
|
|
897
929
|
*
|
|
898
930
|
* @public exported from `@promptbook/core`
|
|
899
931
|
*/
|
|
900
|
-
const
|
|
932
|
+
const TextFormatParser = {
|
|
901
933
|
formatName: 'TEXT',
|
|
902
934
|
isValid(value) {
|
|
903
935
|
return typeof value === 'string';
|
|
@@ -906,19 +938,20 @@ const TextFormatDefinition = {
|
|
|
906
938
|
return typeof partialValue === 'string';
|
|
907
939
|
},
|
|
908
940
|
heal() {
|
|
909
|
-
throw new UnexpectedError('It does not make sense to call `
|
|
941
|
+
throw new UnexpectedError('It does not make sense to call `TextFormatParser.heal`');
|
|
910
942
|
},
|
|
911
|
-
|
|
943
|
+
subvalueParsers: [
|
|
912
944
|
{
|
|
913
945
|
subvalueName: 'LINE',
|
|
914
|
-
async mapValues(
|
|
946
|
+
async mapValues(options) {
|
|
947
|
+
const { value, mapCallback, onProgress } = options;
|
|
915
948
|
const lines = value.split('\n');
|
|
916
|
-
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
949
|
+
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
|
|
917
950
|
// TODO: [🧠] Maybe option to skip empty line
|
|
918
951
|
/* not await */ mapCallback({
|
|
919
952
|
lineContent,
|
|
920
953
|
// TODO: [🧠] Maybe also put here `lineNumber`
|
|
921
|
-
}, lineNumber)));
|
|
954
|
+
}, lineNumber, array.length)));
|
|
922
955
|
return mappedLines.join('\n');
|
|
923
956
|
},
|
|
924
957
|
},
|
|
@@ -928,10 +961,10 @@ const TextFormatDefinition = {
|
|
|
928
961
|
/**
|
|
929
962
|
* TODO: [1] Make type for XML Text and Schema
|
|
930
963
|
* TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages available as subvalues
|
|
931
|
-
* TODO: [🍓] In `
|
|
932
|
-
* TODO: [🍓] In `
|
|
933
|
-
* TODO: [🍓] In `
|
|
934
|
-
* TODO: [🍓] In `
|
|
964
|
+
* TODO: [🍓] In `TextFormatParser` implement simple `isValid`
|
|
965
|
+
* TODO: [🍓] In `TextFormatParser` implement partial `canBeValid`
|
|
966
|
+
* TODO: [🍓] In `TextFormatParser` implement `heal
|
|
967
|
+
* TODO: [🍓] In `TextFormatParser` implement `subvalueParsers`
|
|
935
968
|
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
936
969
|
*/
|
|
937
970
|
|
|
@@ -939,7 +972,7 @@ const TextFormatDefinition = {
|
|
|
939
972
|
* Function to check if a string is valid XML
|
|
940
973
|
*
|
|
941
974
|
* @param value
|
|
942
|
-
* @returns
|
|
975
|
+
* @returns `true` if the string is a valid XML string, false otherwise
|
|
943
976
|
*
|
|
944
977
|
* @public exported from `@promptbook/utils`
|
|
945
978
|
*/
|
|
@@ -964,7 +997,7 @@ function isValidXmlString(value) {
|
|
|
964
997
|
*
|
|
965
998
|
* @private still in development [🏢]
|
|
966
999
|
*/
|
|
967
|
-
const
|
|
1000
|
+
const XmlFormatParser = {
|
|
968
1001
|
formatName: 'XML',
|
|
969
1002
|
mimeType: 'application/xml',
|
|
970
1003
|
isValid(value, settings, schema) {
|
|
@@ -976,17 +1009,17 @@ const XmlFormatDefinition = {
|
|
|
976
1009
|
heal(value, settings, schema) {
|
|
977
1010
|
throw new Error('Not implemented');
|
|
978
1011
|
},
|
|
979
|
-
|
|
1012
|
+
subvalueParsers: [],
|
|
980
1013
|
};
|
|
981
1014
|
/**
|
|
982
|
-
* TODO: [🧠] Maybe
|
|
1015
|
+
* TODO: [🧠] Maybe proper instance of object
|
|
983
1016
|
* TODO: [0] Make string_serialized_xml
|
|
984
1017
|
* TODO: [1] Make type for XML Settings and Schema
|
|
985
1018
|
* TODO: [🧠] What to use for validating XMLs - XSD,...
|
|
986
|
-
* TODO: [🍓] In `
|
|
987
|
-
* TODO: [🍓] In `
|
|
988
|
-
* TODO: [🍓] In `
|
|
989
|
-
* TODO: [🍓] In `
|
|
1019
|
+
* TODO: [🍓] In `XmlFormatParser` implement simple `isValid`
|
|
1020
|
+
* TODO: [🍓] In `XmlFormatParser` implement partial `canBeValid`
|
|
1021
|
+
* TODO: [🍓] In `XmlFormatParser` implement `heal
|
|
1022
|
+
* TODO: [🍓] In `XmlFormatParser` implement `subvalueParsers`
|
|
990
1023
|
* TODO: [🏢] Allow to expect something inside XML and other formats
|
|
991
1024
|
*/
|
|
992
1025
|
|
|
@@ -995,21 +1028,16 @@ const XmlFormatDefinition = {
|
|
|
995
1028
|
*
|
|
996
1029
|
* @private internal index of `...` <- TODO [🏢]
|
|
997
1030
|
*/
|
|
998
|
-
const FORMAT_DEFINITIONS = [
|
|
999
|
-
JsonFormatDefinition,
|
|
1000
|
-
XmlFormatDefinition,
|
|
1001
|
-
TextFormatDefinition,
|
|
1002
|
-
CsvFormatDefinition,
|
|
1003
|
-
];
|
|
1031
|
+
const FORMAT_DEFINITIONS = [JsonFormatParser, XmlFormatParser, TextFormatParser, CsvFormatParser];
|
|
1004
1032
|
/**
|
|
1005
1033
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
1006
1034
|
*/
|
|
1007
1035
|
|
|
1008
1036
|
/**
|
|
1009
|
-
*
|
|
1037
|
+
* Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
|
|
1010
1038
|
*
|
|
1011
|
-
* @param text
|
|
1012
|
-
* @returns
|
|
1039
|
+
* @param text The text string to be converted to SCREAMING_CASE format.
|
|
1040
|
+
* @returns The normalized text in SCREAMING_CASE format.
|
|
1013
1041
|
* @example 'HELLO_WORLD'
|
|
1014
1042
|
* @example 'I_LOVE_PROMPTBOOK'
|
|
1015
1043
|
* @public exported from `@promptbook/utils`
|
|
@@ -1241,8 +1269,12 @@ function checkSerializableAsJson(options) {
|
|
|
1241
1269
|
*/
|
|
1242
1270
|
|
|
1243
1271
|
/**
|
|
1244
|
-
*
|
|
1272
|
+
* Creates a deep clone of the given object
|
|
1245
1273
|
*
|
|
1274
|
+
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
1275
|
+
*
|
|
1276
|
+
* @param objectValue The object to clone.
|
|
1277
|
+
* @returns A deep, writable clone of the input object.
|
|
1246
1278
|
* @public exported from `@promptbook/utils`
|
|
1247
1279
|
*/
|
|
1248
1280
|
function deepClone(objectValue) {
|
|
@@ -1328,11 +1360,11 @@ const RESERVED_PARAMETER_NAMES = exportJson({
|
|
|
1328
1360
|
*/
|
|
1329
1361
|
|
|
1330
1362
|
/**
|
|
1331
|
-
*
|
|
1363
|
+
* Normalizes a given text to camelCase format.
|
|
1332
1364
|
*
|
|
1333
|
-
* @param text
|
|
1334
|
-
* @param _isFirstLetterCapital
|
|
1335
|
-
* @returns
|
|
1365
|
+
* @param text The text to be normalized.
|
|
1366
|
+
* @param _isFirstLetterCapital Whether the first letter should be capitalized.
|
|
1367
|
+
* @returns The camelCase formatted string.
|
|
1336
1368
|
* @example 'helloWorld'
|
|
1337
1369
|
* @example 'iLovePromptbook'
|
|
1338
1370
|
* @public exported from `@promptbook/utils`
|
|
@@ -1624,10 +1656,10 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
|
1624
1656
|
*/
|
|
1625
1657
|
|
|
1626
1658
|
/**
|
|
1627
|
-
*
|
|
1659
|
+
* Removes diacritic marks (accents) from characters in a string.
|
|
1628
1660
|
*
|
|
1629
|
-
* @param input
|
|
1630
|
-
* @returns
|
|
1661
|
+
* @param input The string containing diacritics to be normalized.
|
|
1662
|
+
* @returns The string with diacritics removed or normalized.
|
|
1631
1663
|
* @public exported from `@promptbook/utils`
|
|
1632
1664
|
*/
|
|
1633
1665
|
function removeDiacritics(input) {
|
|
@@ -1659,9 +1691,9 @@ function removeEmojis(text) {
|
|
|
1659
1691
|
/**
|
|
1660
1692
|
* Removes quotes from a string
|
|
1661
1693
|
*
|
|
1662
|
-
* Tip: This is very
|
|
1694
|
+
* Tip: This is very useful for post-processing of the result of the LLM model
|
|
1663
1695
|
* Note: This function removes only the same quotes from the beginning and the end of the string
|
|
1664
|
-
* Note: There are two
|
|
1696
|
+
* Note: There are two similar functions:
|
|
1665
1697
|
* - `removeQuotes` which removes only bounding quotes
|
|
1666
1698
|
* - `unwrapResult` which removes whole introduce sentence
|
|
1667
1699
|
*
|
|
@@ -1673,18 +1705,19 @@ function removeQuotes(text) {
|
|
|
1673
1705
|
if (text.startsWith('"') && text.endsWith('"')) {
|
|
1674
1706
|
return text.slice(1, -1);
|
|
1675
1707
|
}
|
|
1676
|
-
if (text.startsWith('
|
|
1708
|
+
if (text.startsWith("'") && text.endsWith("'")) {
|
|
1677
1709
|
return text.slice(1, -1);
|
|
1678
1710
|
}
|
|
1679
1711
|
return text;
|
|
1680
1712
|
}
|
|
1681
1713
|
|
|
1682
1714
|
/**
|
|
1683
|
-
* Function `validateParameterName` will
|
|
1715
|
+
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
1716
|
+
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
1684
1717
|
*
|
|
1685
|
-
* @param parameterName
|
|
1686
|
-
* @returns
|
|
1687
|
-
* @throws {ParseError}
|
|
1718
|
+
* @param parameterName The parameter name to validate and normalize.
|
|
1719
|
+
* @returns The validated and normalized parameter name.
|
|
1720
|
+
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
1688
1721
|
* @private within the repository
|
|
1689
1722
|
*/
|
|
1690
1723
|
function validateParameterName(parameterName) {
|
|
@@ -1754,8 +1787,6 @@ function validateParameterName(parameterName) {
|
|
|
1754
1787
|
/**
|
|
1755
1788
|
* Parses the foreach command
|
|
1756
1789
|
*
|
|
1757
|
-
* Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book` file
|
|
1758
|
-
*
|
|
1759
1790
|
* @see `documentationUrl` for more details
|
|
1760
1791
|
* @public exported from `@promptbook/editable`
|
|
1761
1792
|
*/
|
|
@@ -1812,14 +1843,14 @@ const foreachCommandParser = {
|
|
|
1812
1843
|
`));
|
|
1813
1844
|
// <- TODO: [🏢] List all supported format names
|
|
1814
1845
|
}
|
|
1815
|
-
const
|
|
1816
|
-
if (
|
|
1846
|
+
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
1847
|
+
if (subvalueParser === undefined) {
|
|
1817
1848
|
throw new ParseError(spaceTrim((block) => `
|
|
1818
1849
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
1819
1850
|
|
|
1820
1851
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
1821
|
-
${block(formatDefinition.
|
|
1822
|
-
.map((
|
|
1852
|
+
${block(formatDefinition.subvalueParsers
|
|
1853
|
+
.map((subvalueParser) => subvalueParser.subvalueName)
|
|
1823
1854
|
.map((subvalueName) => `- ${subvalueName}`)
|
|
1824
1855
|
.join('\n'))}
|
|
1825
1856
|
`));
|
|
@@ -1996,14 +2027,14 @@ const formatCommandParser = {
|
|
|
1996
2027
|
};
|
|
1997
2028
|
|
|
1998
2029
|
/**
|
|
1999
|
-
*
|
|
2030
|
+
* Chatbot form factor definition for conversational interfaces that interact with users in a chat-like manner.
|
|
2000
2031
|
*
|
|
2001
2032
|
* @public exported from `@promptbook/core`
|
|
2002
2033
|
*/
|
|
2003
2034
|
const ChatbotFormfactorDefinition = {
|
|
2004
2035
|
name: 'CHATBOT',
|
|
2005
2036
|
aliasNames: ['CHAT'],
|
|
2006
|
-
description:
|
|
2037
|
+
description: `A chatbot form factor for conversational user interfaces.`,
|
|
2007
2038
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/174`,
|
|
2008
2039
|
pipelineInterface: {
|
|
2009
2040
|
inputParameters: [
|
|
@@ -2030,7 +2061,45 @@ const ChatbotFormfactorDefinition = {
|
|
|
2030
2061
|
};
|
|
2031
2062
|
|
|
2032
2063
|
/**
|
|
2033
|
-
*
|
|
2064
|
+
* Completion is formfactor that emulates completion models
|
|
2065
|
+
*
|
|
2066
|
+
* @public exported from `@promptbook/core`
|
|
2067
|
+
*/
|
|
2068
|
+
const CompletionFormfactorDefinition = {
|
|
2069
|
+
name: 'COMPLETION',
|
|
2070
|
+
description: `Completion is formfactor that emulates completion models`,
|
|
2071
|
+
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/@@`,
|
|
2072
|
+
// <- TODO: https://github.com/webgptorg/promptbook/discussions/new?category=concepts
|
|
2073
|
+
// "🔠 Completion Formfactor"
|
|
2074
|
+
pipelineInterface: {
|
|
2075
|
+
inputParameters: [
|
|
2076
|
+
{
|
|
2077
|
+
name: 'inputText',
|
|
2078
|
+
description: `Input text to be completed`,
|
|
2079
|
+
isInput: true,
|
|
2080
|
+
isOutput: false,
|
|
2081
|
+
},
|
|
2082
|
+
{
|
|
2083
|
+
name: 'instructions',
|
|
2084
|
+
description: `Additional instructions for the model, for example the required length, empty by default`,
|
|
2085
|
+
isInput: true,
|
|
2086
|
+
isOutput: false,
|
|
2087
|
+
},
|
|
2088
|
+
],
|
|
2089
|
+
outputParameters: [
|
|
2090
|
+
{
|
|
2091
|
+
name: 'followingText',
|
|
2092
|
+
description: `Text that follows the input text`,
|
|
2093
|
+
isInput: false,
|
|
2094
|
+
isOutput: true,
|
|
2095
|
+
},
|
|
2096
|
+
],
|
|
2097
|
+
},
|
|
2098
|
+
};
|
|
2099
|
+
|
|
2100
|
+
/**
|
|
2101
|
+
* Generator form factor represents an application that generates content or data based on user input or predefined rules.
|
|
2102
|
+
* This form factor is used for apps that produce outputs, such as text, images, or other media, based on provided input.
|
|
2034
2103
|
*
|
|
2035
2104
|
* @public exported from `@promptbook/core`
|
|
2036
2105
|
*/
|
|
@@ -2059,7 +2128,7 @@ const GeneratorFormfactorDefinition = {
|
|
|
2059
2128
|
};
|
|
2060
2129
|
|
|
2061
2130
|
/**
|
|
2062
|
-
*
|
|
2131
|
+
* Pipeline interface which is equivalent to `any`
|
|
2063
2132
|
*
|
|
2064
2133
|
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
2065
2134
|
*
|
|
@@ -2074,13 +2143,13 @@ const GENERIC_PIPELINE_INTERFACE = {
|
|
|
2074
2143
|
*/
|
|
2075
2144
|
|
|
2076
2145
|
/**
|
|
2077
|
-
*
|
|
2146
|
+
* A generic pipeline
|
|
2078
2147
|
*
|
|
2079
2148
|
* @public exported from `@promptbook/core`
|
|
2080
2149
|
*/
|
|
2081
2150
|
const GenericFormfactorDefinition = {
|
|
2082
2151
|
name: 'GENERIC',
|
|
2083
|
-
description:
|
|
2152
|
+
description: `A generic pipeline`,
|
|
2084
2153
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/173`,
|
|
2085
2154
|
pipelineInterface: GENERIC_PIPELINE_INTERFACE,
|
|
2086
2155
|
};
|
|
@@ -2115,17 +2184,20 @@ const ImageGeneratorFormfactorDefinition = {
|
|
|
2115
2184
|
};
|
|
2116
2185
|
|
|
2117
2186
|
/**
|
|
2118
|
-
* Matcher is form of app that
|
|
2187
|
+
* Matcher is form of app that evaluates (spreadsheet) content against defined criteria or patterns,
|
|
2188
|
+
* determining if it matches or meets specific requirements. Used for classification,
|
|
2189
|
+
* validation, filtering, and quality assessment of inputs.
|
|
2119
2190
|
*
|
|
2120
2191
|
* @public exported from `@promptbook/core`
|
|
2121
2192
|
*/
|
|
2122
2193
|
const MatcherFormfactorDefinition = {
|
|
2123
2194
|
name: 'EXPERIMENTAL_MATCHER',
|
|
2124
|
-
description:
|
|
2195
|
+
description: `An evaluation system that determines whether content meets specific criteria or patterns.
|
|
2196
|
+
Used for content validation, quality assessment, and intelligent filtering tasks. Currently in experimental phase.`,
|
|
2125
2197
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/177`,
|
|
2126
2198
|
pipelineInterface: {
|
|
2127
2199
|
inputParameters: [
|
|
2128
|
-
/*
|
|
2200
|
+
/* Input parameters for content to be matched and criteria to match against */
|
|
2129
2201
|
{
|
|
2130
2202
|
name: 'nonce',
|
|
2131
2203
|
description: 'Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor',
|
|
@@ -2134,20 +2206,21 @@ const MatcherFormfactorDefinition = {
|
|
|
2134
2206
|
},
|
|
2135
2207
|
],
|
|
2136
2208
|
outputParameters: [
|
|
2137
|
-
/*
|
|
2209
|
+
/* Output parameters containing match results, confidence scores, and relevant metadata */
|
|
2138
2210
|
],
|
|
2139
2211
|
},
|
|
2140
2212
|
};
|
|
2141
2213
|
|
|
2142
2214
|
/**
|
|
2143
|
-
* Sheets is form of app that
|
|
2215
|
+
* Sheets is form of app that processes tabular data in CSV format, allowing transformation
|
|
2216
|
+
* and analysis of structured data through AI-powered operations
|
|
2144
2217
|
*
|
|
2145
2218
|
* @public exported from `@promptbook/core`
|
|
2146
2219
|
*/
|
|
2147
2220
|
const SheetsFormfactorDefinition = {
|
|
2148
2221
|
name: 'SHEETS',
|
|
2149
2222
|
aliasNames: ['SHEETS', 'SHEET'],
|
|
2150
|
-
description:
|
|
2223
|
+
description: `A formfactor for processing spreadsheet-like data in CSV format, enabling AI transformations on tabular data`,
|
|
2151
2224
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/176`,
|
|
2152
2225
|
pipelineInterface: {
|
|
2153
2226
|
inputParameters: [
|
|
@@ -2170,13 +2243,16 @@ const SheetsFormfactorDefinition = {
|
|
|
2170
2243
|
};
|
|
2171
2244
|
|
|
2172
2245
|
/**
|
|
2173
|
-
* Translator is form of app that
|
|
2246
|
+
* Translator is form of app that transforms input text from one form to another,
|
|
2247
|
+
* such as language translation, style conversion, tone modification, or other text transformations.
|
|
2174
2248
|
*
|
|
2175
2249
|
* @public exported from `@promptbook/core`
|
|
2176
2250
|
*/
|
|
2177
2251
|
const TranslatorFormfactorDefinition = {
|
|
2178
2252
|
name: 'TRANSLATOR',
|
|
2179
|
-
description:
|
|
2253
|
+
description: `A text transformation system that converts input content into different forms,
|
|
2254
|
+
including language translations, paraphrasing, style conversions, and tone adjustments.
|
|
2255
|
+
This form factor takes one input and produces one transformed output.`,
|
|
2180
2256
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/175`,
|
|
2181
2257
|
pipelineInterface: {
|
|
2182
2258
|
inputParameters: [
|
|
@@ -2213,6 +2289,8 @@ const FORMFACTOR_DEFINITIONS = [
|
|
|
2213
2289
|
MatcherFormfactorDefinition,
|
|
2214
2290
|
GeneratorFormfactorDefinition,
|
|
2215
2291
|
ImageGeneratorFormfactorDefinition,
|
|
2292
|
+
CompletionFormfactorDefinition,
|
|
2293
|
+
// <- [🛬] When making new formfactor, copy the _boilerplate and link it here
|
|
2216
2294
|
];
|
|
2217
2295
|
/**
|
|
2218
2296
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2221,7 +2299,7 @@ const FORMFACTOR_DEFINITIONS = [
|
|
|
2221
2299
|
/**
|
|
2222
2300
|
* Parses the formfactor command
|
|
2223
2301
|
*
|
|
2224
|
-
* Note:
|
|
2302
|
+
* Note: This command is used as a formfactor for new commands and defines the app type format - it should NOT be used in any `.book` file
|
|
2225
2303
|
*
|
|
2226
2304
|
* @see `documentationUrl` for more details
|
|
2227
2305
|
* @public exported from `@promptbook/editable`
|
|
@@ -2243,7 +2321,7 @@ const formfactorCommandParser = {
|
|
|
2243
2321
|
/**
|
|
2244
2322
|
* Description of the FORMFACTOR command
|
|
2245
2323
|
*/
|
|
2246
|
-
description:
|
|
2324
|
+
description: `Specifies the application type and interface requirements that this promptbook should conform to`,
|
|
2247
2325
|
/**
|
|
2248
2326
|
* Link to documentation
|
|
2249
2327
|
*/
|
|
@@ -2438,7 +2516,7 @@ function isValidFilePath(filename) {
|
|
|
2438
2516
|
* Tests if given string is valid URL.
|
|
2439
2517
|
*
|
|
2440
2518
|
* Note: Dataurl are considered perfectly valid.
|
|
2441
|
-
* Note: There are two
|
|
2519
|
+
* Note: There are two similar functions:
|
|
2442
2520
|
* - `isValidUrl` which tests any URL
|
|
2443
2521
|
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
2444
2522
|
*
|
|
@@ -2464,10 +2542,10 @@ function isValidUrl(url) {
|
|
|
2464
2542
|
}
|
|
2465
2543
|
|
|
2466
2544
|
/**
|
|
2467
|
-
*
|
|
2545
|
+
* Converts a given text to kebab-case format.
|
|
2468
2546
|
*
|
|
2469
|
-
* @param text
|
|
2470
|
-
* @returns
|
|
2547
|
+
* @param text The text to be converted.
|
|
2548
|
+
* @returns The kebab-case formatted string.
|
|
2471
2549
|
* @example 'hello-world'
|
|
2472
2550
|
* @example 'i-love-promptbook'
|
|
2473
2551
|
* @public exported from `@promptbook/utils`
|
|
@@ -2630,8 +2708,7 @@ const knowledgeCommandParser = {
|
|
|
2630
2708
|
*/
|
|
2631
2709
|
|
|
2632
2710
|
/**
|
|
2633
|
-
*
|
|
2634
|
-
*
|
|
2711
|
+
* @see {@link ModelVariant}
|
|
2635
2712
|
* @public exported from `@promptbook/core`
|
|
2636
2713
|
*/
|
|
2637
2714
|
const MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
|
|
@@ -3063,10 +3140,10 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
3063
3140
|
}
|
|
3064
3141
|
|
|
3065
3142
|
/**
|
|
3066
|
-
*
|
|
3143
|
+
* Checks if the given value is a valid JavaScript identifier name.
|
|
3067
3144
|
*
|
|
3068
|
-
* @param javascriptName
|
|
3069
|
-
* @returns
|
|
3145
|
+
* @param javascriptName The value to check for JavaScript identifier validity.
|
|
3146
|
+
* @returns `true` if the value is a valid JavaScript name, false otherwise.
|
|
3070
3147
|
* @public exported from `@promptbook/utils`
|
|
3071
3148
|
*/
|
|
3072
3149
|
function isValidJavascriptName(javascriptName) {
|
|
@@ -3315,7 +3392,7 @@ const sectionCommandParser = {
|
|
|
3315
3392
|
throw new ParseError(`Task section and example section must end with return statement -> {parameterName}`);
|
|
3316
3393
|
};
|
|
3317
3394
|
if ($taskJson.content === undefined) {
|
|
3318
|
-
throw new UnexpectedError(`Content is missing in the taskJson -
|
|
3395
|
+
throw new UnexpectedError(`Content is missing in the taskJson - probably commands are applied in wrong order`);
|
|
3319
3396
|
}
|
|
3320
3397
|
if (command.taskType === 'EXAMPLE') {
|
|
3321
3398
|
expectResultingParameterName();
|
|
@@ -3383,7 +3460,7 @@ const sectionCommandParser = {
|
|
|
3383
3460
|
/**
|
|
3384
3461
|
* Tests if given string is valid pipeline URL URL.
|
|
3385
3462
|
*
|
|
3386
|
-
* Note: There are two
|
|
3463
|
+
* Note: There are two similar functions:
|
|
3387
3464
|
* - `isValidUrl` which tests any URL
|
|
3388
3465
|
* - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
|
|
3389
3466
|
*
|
|
@@ -3785,7 +3862,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
3785
3862
|
// Arg1 Arg2 Arg3 | FOO
|
|
3786
3863
|
{
|
|
3787
3864
|
const commandNameRaw = items.slice(-1).join('_');
|
|
3788
|
-
const args = items.slice(0, -1); // <- Note: This is
|
|
3865
|
+
const args = items.slice(0, -1); // <- Note: This is probably not correct
|
|
3789
3866
|
const rawArgs = raw
|
|
3790
3867
|
.substring(0, raw.length - commandNameRaw.length)
|
|
3791
3868
|
.trim();
|
|
@@ -3804,7 +3881,10 @@ function parseCommand(raw, usagePlace) {
|
|
|
3804
3881
|
`));
|
|
3805
3882
|
}
|
|
3806
3883
|
/**
|
|
3807
|
-
*
|
|
3884
|
+
* Generates a markdown-formatted message listing all supported commands
|
|
3885
|
+
* with their descriptions and documentation links
|
|
3886
|
+
*
|
|
3887
|
+
* @returns A formatted markdown string containing all available commands and their details
|
|
3808
3888
|
*/
|
|
3809
3889
|
function getSupportedCommandsMessage() {
|
|
3810
3890
|
return COMMANDS.flatMap(({ name, aliasNames, description, documentationUrl }) =>
|
|
@@ -3815,7 +3895,10 @@ function getSupportedCommandsMessage() {
|
|
|
3815
3895
|
]).join('\n');
|
|
3816
3896
|
}
|
|
3817
3897
|
/**
|
|
3818
|
-
*
|
|
3898
|
+
* Attempts to parse a command variant using the provided input parameters
|
|
3899
|
+
*
|
|
3900
|
+
* @param input Object containing command parsing information including raw command text and normalized values
|
|
3901
|
+
* @returns A parsed Command object if successful, or null if the command cannot be parsed
|
|
3819
3902
|
*/
|
|
3820
3903
|
function parseCommandVariant(input) {
|
|
3821
3904
|
const { commandNameRaw, usagePlace, normalized, args, raw, rawArgs } = input;
|
|
@@ -3917,7 +4000,8 @@ function removeMarkdownComments(content) {
|
|
|
3917
4000
|
}
|
|
3918
4001
|
|
|
3919
4002
|
/**
|
|
3920
|
-
*
|
|
4003
|
+
* Utility to determine if a pipeline string is in flat format.
|
|
4004
|
+
* A flat pipeline is a simple text without proper structure (headers, blocks, etc).
|
|
3921
4005
|
*
|
|
3922
4006
|
* @public exported from `@promptbook/editable`
|
|
3923
4007
|
*/
|
|
@@ -3938,7 +4022,10 @@ function isFlatPipeline(pipelineString) {
|
|
|
3938
4022
|
}
|
|
3939
4023
|
|
|
3940
4024
|
/**
|
|
3941
|
-
*
|
|
4025
|
+
* Converts a pipeline structure to its string representation.
|
|
4026
|
+
*
|
|
4027
|
+
* Transforms a flat, simple pipeline into a properly formatted pipeline string
|
|
4028
|
+
* with sections for title, prompt, and return statement.
|
|
3942
4029
|
*
|
|
3943
4030
|
* @public exported from `@promptbook/editable`
|
|
3944
4031
|
*/
|
|
@@ -3987,7 +4074,7 @@ function deflatePipeline(pipelineString) {
|
|
|
3987
4074
|
*/
|
|
3988
4075
|
|
|
3989
4076
|
/**
|
|
3990
|
-
*
|
|
4077
|
+
* Adds a new command to a pipeline string in the correct format.
|
|
3991
4078
|
*
|
|
3992
4079
|
* @public exported from `@promptbook/editable`
|
|
3993
4080
|
*/
|
|
@@ -4200,7 +4287,7 @@ function stringifyPipelineJson(pipeline) {
|
|
|
4200
4287
|
return pipelineJsonStringified;
|
|
4201
4288
|
}
|
|
4202
4289
|
/**
|
|
4203
|
-
* TODO: [🐝] Not Working
|
|
4290
|
+
* TODO: [🐝] Not Working properly @see https://promptbook.studio/examples/mixed-knowledge.book
|
|
4204
4291
|
* TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
|
|
4205
4292
|
* TODO: [🧠] Maybe more elegant solution than replacing via regex
|
|
4206
4293
|
* TODO: [🍙] Make some standard order of json properties
|