@promptbook/editable 0.92.0-9 → 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 +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 +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/umd/index.umd.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* @generated
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
* Returns the same value that is passed as argument.
|
|
34
34
|
* No side effects.
|
|
35
35
|
*
|
|
36
|
-
* Note: It can be
|
|
36
|
+
* Note: It can be useful for:
|
|
37
37
|
*
|
|
38
38
|
* 1) Leveling indentation
|
|
39
39
|
* 2) Putting always-true or always-false conditions without getting eslint errors
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
const LOOP_LIMIT = 1000;
|
|
92
92
|
// <- TODO: [🧜♂️]
|
|
93
93
|
/**
|
|
94
|
-
*
|
|
94
|
+
* Default settings for parsing and generating CSV files in Promptbook.
|
|
95
95
|
*
|
|
96
96
|
* @public exported from `@promptbook/core`
|
|
97
97
|
*/
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
${block(message)}
|
|
162
162
|
|
|
163
163
|
Note: This error should not happen.
|
|
164
|
-
It's
|
|
164
|
+
It's probably a bug in the pipeline collection
|
|
165
165
|
|
|
166
166
|
Please report issue:
|
|
167
167
|
${block(getErrorReportUrl(new Error(message)).href)}
|
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
/**
|
|
194
194
|
* Parses the boilerplate command
|
|
195
195
|
*
|
|
196
|
-
* Note:
|
|
196
|
+
* Note: @@ This command is used as boilerplate for new commands - it should NOT be used in any `.book` file
|
|
197
197
|
*
|
|
198
198
|
* @see `documentationUrl` for more details
|
|
199
199
|
* @private within the commands folder
|
|
@@ -309,7 +309,7 @@
|
|
|
309
309
|
/**
|
|
310
310
|
* Tests if given string is valid semantic version
|
|
311
311
|
*
|
|
312
|
-
* Note: There are two
|
|
312
|
+
* Note: There are two similar functions:
|
|
313
313
|
* - `isValidSemanticVersion` which tests any semantic version
|
|
314
314
|
* - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
|
|
315
315
|
*
|
|
@@ -331,7 +331,7 @@
|
|
|
331
331
|
*
|
|
332
332
|
* @see https://www.npmjs.com/package/promptbook?activeTab=versions
|
|
333
333
|
* 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.
|
|
334
|
-
* Note: There are two
|
|
334
|
+
* Note: There are two similar functions:
|
|
335
335
|
* - `isValidSemanticVersion` which tests any semantic version
|
|
336
336
|
* - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
|
|
337
337
|
*
|
|
@@ -724,7 +724,7 @@
|
|
|
724
724
|
}
|
|
725
725
|
|
|
726
726
|
/**
|
|
727
|
-
*
|
|
727
|
+
* Contains configuration options for parsing and generating CSV files, such as delimiters and quoting rules.
|
|
728
728
|
*
|
|
729
729
|
* @public exported from `@promptbook/core`
|
|
730
730
|
*/
|
|
@@ -733,11 +733,29 @@
|
|
|
733
733
|
// encoding: 'utf-8',
|
|
734
734
|
});
|
|
735
735
|
|
|
736
|
+
/**
|
|
737
|
+
* Converts a CSV string into an object
|
|
738
|
+
*
|
|
739
|
+
* Note: This is wrapper around `papaparse.parse()` with better autohealing
|
|
740
|
+
*
|
|
741
|
+
* @private - for now until `@promptbook/csv` is released
|
|
742
|
+
*/
|
|
743
|
+
function csvParse(value /* <- TODO: string_csv */, settings, schema /* <- TODO: Make CSV Schemas */) {
|
|
744
|
+
settings = { ...settings, ...MANDATORY_CSV_SETTINGS };
|
|
745
|
+
// Note: Autoheal invalid '\n' characters
|
|
746
|
+
if (settings.newline && !settings.newline.includes('\r') && value.includes('\r')) {
|
|
747
|
+
console.warn('CSV string contains carriage return characters, but in the CSV settings the `newline` setting does not include them. Autohealing the CSV string.');
|
|
748
|
+
value = value.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
749
|
+
}
|
|
750
|
+
const csv = papaparse.parse(value, settings);
|
|
751
|
+
return csv;
|
|
752
|
+
}
|
|
753
|
+
|
|
736
754
|
/**
|
|
737
755
|
* Function to check if a string is valid CSV
|
|
738
756
|
*
|
|
739
757
|
* @param value The string to check
|
|
740
|
-
* @returns
|
|
758
|
+
* @returns `true` if the string is a valid CSV string, false otherwise
|
|
741
759
|
*
|
|
742
760
|
* @public exported from `@promptbook/utils`
|
|
743
761
|
*/
|
|
@@ -761,7 +779,7 @@
|
|
|
761
779
|
* @public exported from `@promptbook/core`
|
|
762
780
|
* <- TODO: [🏢] Export from package `@promptbook/csv`
|
|
763
781
|
*/
|
|
764
|
-
const
|
|
782
|
+
const CsvFormatParser = {
|
|
765
783
|
formatName: 'CSV',
|
|
766
784
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
767
785
|
isValid(value, settings, schema) {
|
|
@@ -773,12 +791,12 @@
|
|
|
773
791
|
heal(value, settings, schema) {
|
|
774
792
|
throw new Error('Not implemented');
|
|
775
793
|
},
|
|
776
|
-
|
|
794
|
+
subvalueParsers: [
|
|
777
795
|
{
|
|
778
796
|
subvalueName: 'ROW',
|
|
779
|
-
async mapValues(
|
|
780
|
-
|
|
781
|
-
const csv =
|
|
797
|
+
async mapValues(options) {
|
|
798
|
+
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
799
|
+
const csv = csvParse(value, settings);
|
|
782
800
|
if (csv.errors.length !== 0) {
|
|
783
801
|
throw new CsvFormatError(spaceTrim__default["default"]((block) => `
|
|
784
802
|
CSV parsing error
|
|
@@ -793,23 +811,37 @@
|
|
|
793
811
|
${block(value)}
|
|
794
812
|
`));
|
|
795
813
|
}
|
|
796
|
-
const mappedData =
|
|
814
|
+
const mappedData = [];
|
|
815
|
+
const length = csv.data.length;
|
|
816
|
+
for (let index = 0; index < length; index++) {
|
|
817
|
+
const row = csv.data[index];
|
|
797
818
|
if (row[outputParameterName]) {
|
|
798
819
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
799
820
|
}
|
|
800
|
-
|
|
821
|
+
const mappedRow = {
|
|
801
822
|
...row,
|
|
802
|
-
[outputParameterName]: await mapCallback(row, index),
|
|
823
|
+
[outputParameterName]: await mapCallback(row, index, length),
|
|
803
824
|
};
|
|
804
|
-
|
|
825
|
+
mappedData.push(mappedRow);
|
|
826
|
+
if (onProgress) {
|
|
827
|
+
// Note: Report the CSV with all rows mapped so far
|
|
828
|
+
/*
|
|
829
|
+
// TODO: [🛕] Report progress with all the rows including the pending ones
|
|
830
|
+
const progressData = mappedData.map((row, i) =>
|
|
831
|
+
i > index ? { ...row, [outputParameterName]: PENDING_VALUE_PLACEHOLDER } : row,
|
|
832
|
+
);
|
|
833
|
+
*/
|
|
834
|
+
await onProgress(papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
835
|
+
}
|
|
836
|
+
}
|
|
805
837
|
return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
806
838
|
},
|
|
807
839
|
},
|
|
808
840
|
{
|
|
809
841
|
subvalueName: 'CELL',
|
|
810
|
-
async mapValues(
|
|
811
|
-
|
|
812
|
-
const csv =
|
|
842
|
+
async mapValues(options) {
|
|
843
|
+
const { value, settings, mapCallback, onProgress } = options;
|
|
844
|
+
const csv = csvParse(value, settings);
|
|
813
845
|
if (csv.errors.length !== 0) {
|
|
814
846
|
throw new CsvFormatError(spaceTrim__default["default"]((block) => `
|
|
815
847
|
CSV parsing error
|
|
@@ -825,9 +857,9 @@
|
|
|
825
857
|
`));
|
|
826
858
|
}
|
|
827
859
|
const mappedData = await Promise.all(csv.data.map(async (row, rowIndex) => {
|
|
828
|
-
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex) => {
|
|
860
|
+
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex, array) => {
|
|
829
861
|
const index = rowIndex * Object.keys(row).length + columnIndex;
|
|
830
|
-
return /* not await */ mapCallback({ [key]: value }, index);
|
|
862
|
+
return /* not await */ mapCallback({ [key]: value }, index, array.length);
|
|
831
863
|
}));
|
|
832
864
|
}));
|
|
833
865
|
return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
@@ -836,10 +868,10 @@
|
|
|
836
868
|
],
|
|
837
869
|
};
|
|
838
870
|
/**
|
|
839
|
-
* TODO: [🍓] In `
|
|
840
|
-
* TODO: [🍓] In `
|
|
841
|
-
* TODO: [🍓] In `
|
|
842
|
-
* TODO: [🍓] In `
|
|
871
|
+
* TODO: [🍓] In `CsvFormatParser` implement simple `isValid`
|
|
872
|
+
* TODO: [🍓] In `CsvFormatParser` implement partial `canBeValid`
|
|
873
|
+
* TODO: [🍓] In `CsvFormatParser` implement `heal
|
|
874
|
+
* TODO: [🍓] In `CsvFormatParser` implement `subvalueParsers`
|
|
843
875
|
* TODO: [🏢] Allow to expect something inside CSV objects and other formats
|
|
844
876
|
*/
|
|
845
877
|
|
|
@@ -847,7 +879,7 @@
|
|
|
847
879
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
848
880
|
*
|
|
849
881
|
* @param value The string to check
|
|
850
|
-
* @returns
|
|
882
|
+
* @returns `true` if the string is a valid JSON string, false otherwise
|
|
851
883
|
*
|
|
852
884
|
* @public exported from `@promptbook/utils`
|
|
853
885
|
*/
|
|
@@ -870,7 +902,7 @@
|
|
|
870
902
|
*
|
|
871
903
|
* @private still in development [🏢]
|
|
872
904
|
*/
|
|
873
|
-
const
|
|
905
|
+
const JsonFormatParser = {
|
|
874
906
|
formatName: 'JSON',
|
|
875
907
|
mimeType: 'application/json',
|
|
876
908
|
isValid(value, settings, schema) {
|
|
@@ -882,28 +914,28 @@
|
|
|
882
914
|
heal(value, settings, schema) {
|
|
883
915
|
throw new Error('Not implemented');
|
|
884
916
|
},
|
|
885
|
-
|
|
917
|
+
subvalueParsers: [],
|
|
886
918
|
};
|
|
887
919
|
/**
|
|
888
|
-
* TODO: [🧠] Maybe
|
|
920
|
+
* TODO: [🧠] Maybe proper instance of object
|
|
889
921
|
* TODO: [0] Make string_serialized_json
|
|
890
922
|
* TODO: [1] Make type for JSON Settings and Schema
|
|
891
923
|
* TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
|
|
892
|
-
* TODO: [🍓] In `
|
|
893
|
-
* TODO: [🍓] In `
|
|
894
|
-
* TODO: [🍓] In `
|
|
895
|
-
* TODO: [🍓] In `
|
|
924
|
+
* TODO: [🍓] In `JsonFormatParser` implement simple `isValid`
|
|
925
|
+
* TODO: [🍓] In `JsonFormatParser` implement partial `canBeValid`
|
|
926
|
+
* TODO: [🍓] In `JsonFormatParser` implement `heal
|
|
927
|
+
* TODO: [🍓] In `JsonFormatParser` implement `subvalueParsers`
|
|
896
928
|
* TODO: [🏢] Allow to expect something inside JSON objects and other formats
|
|
897
929
|
*/
|
|
898
930
|
|
|
899
931
|
/**
|
|
900
932
|
* Definition for any text - this will be always valid
|
|
901
933
|
*
|
|
902
|
-
* Note: This is not useful for validation, but for splitting and mapping with `
|
|
934
|
+
* Note: This is not useful for validation, but for splitting and mapping with `subvalueParsers`
|
|
903
935
|
*
|
|
904
936
|
* @public exported from `@promptbook/core`
|
|
905
937
|
*/
|
|
906
|
-
const
|
|
938
|
+
const TextFormatParser = {
|
|
907
939
|
formatName: 'TEXT',
|
|
908
940
|
isValid(value) {
|
|
909
941
|
return typeof value === 'string';
|
|
@@ -912,19 +944,20 @@
|
|
|
912
944
|
return typeof partialValue === 'string';
|
|
913
945
|
},
|
|
914
946
|
heal() {
|
|
915
|
-
throw new UnexpectedError('It does not make sense to call `
|
|
947
|
+
throw new UnexpectedError('It does not make sense to call `TextFormatParser.heal`');
|
|
916
948
|
},
|
|
917
|
-
|
|
949
|
+
subvalueParsers: [
|
|
918
950
|
{
|
|
919
951
|
subvalueName: 'LINE',
|
|
920
|
-
async mapValues(
|
|
952
|
+
async mapValues(options) {
|
|
953
|
+
const { value, mapCallback, onProgress } = options;
|
|
921
954
|
const lines = value.split('\n');
|
|
922
|
-
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
955
|
+
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
|
|
923
956
|
// TODO: [🧠] Maybe option to skip empty line
|
|
924
957
|
/* not await */ mapCallback({
|
|
925
958
|
lineContent,
|
|
926
959
|
// TODO: [🧠] Maybe also put here `lineNumber`
|
|
927
|
-
}, lineNumber)));
|
|
960
|
+
}, lineNumber, array.length)));
|
|
928
961
|
return mappedLines.join('\n');
|
|
929
962
|
},
|
|
930
963
|
},
|
|
@@ -934,10 +967,10 @@
|
|
|
934
967
|
/**
|
|
935
968
|
* TODO: [1] Make type for XML Text and Schema
|
|
936
969
|
* TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages available as subvalues
|
|
937
|
-
* TODO: [🍓] In `
|
|
938
|
-
* TODO: [🍓] In `
|
|
939
|
-
* TODO: [🍓] In `
|
|
940
|
-
* TODO: [🍓] In `
|
|
970
|
+
* TODO: [🍓] In `TextFormatParser` implement simple `isValid`
|
|
971
|
+
* TODO: [🍓] In `TextFormatParser` implement partial `canBeValid`
|
|
972
|
+
* TODO: [🍓] In `TextFormatParser` implement `heal
|
|
973
|
+
* TODO: [🍓] In `TextFormatParser` implement `subvalueParsers`
|
|
941
974
|
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
942
975
|
*/
|
|
943
976
|
|
|
@@ -945,7 +978,7 @@
|
|
|
945
978
|
* Function to check if a string is valid XML
|
|
946
979
|
*
|
|
947
980
|
* @param value
|
|
948
|
-
* @returns
|
|
981
|
+
* @returns `true` if the string is a valid XML string, false otherwise
|
|
949
982
|
*
|
|
950
983
|
* @public exported from `@promptbook/utils`
|
|
951
984
|
*/
|
|
@@ -970,7 +1003,7 @@
|
|
|
970
1003
|
*
|
|
971
1004
|
* @private still in development [🏢]
|
|
972
1005
|
*/
|
|
973
|
-
const
|
|
1006
|
+
const XmlFormatParser = {
|
|
974
1007
|
formatName: 'XML',
|
|
975
1008
|
mimeType: 'application/xml',
|
|
976
1009
|
isValid(value, settings, schema) {
|
|
@@ -982,17 +1015,17 @@
|
|
|
982
1015
|
heal(value, settings, schema) {
|
|
983
1016
|
throw new Error('Not implemented');
|
|
984
1017
|
},
|
|
985
|
-
|
|
1018
|
+
subvalueParsers: [],
|
|
986
1019
|
};
|
|
987
1020
|
/**
|
|
988
|
-
* TODO: [🧠] Maybe
|
|
1021
|
+
* TODO: [🧠] Maybe proper instance of object
|
|
989
1022
|
* TODO: [0] Make string_serialized_xml
|
|
990
1023
|
* TODO: [1] Make type for XML Settings and Schema
|
|
991
1024
|
* TODO: [🧠] What to use for validating XMLs - XSD,...
|
|
992
|
-
* TODO: [🍓] In `
|
|
993
|
-
* TODO: [🍓] In `
|
|
994
|
-
* TODO: [🍓] In `
|
|
995
|
-
* TODO: [🍓] In `
|
|
1025
|
+
* TODO: [🍓] In `XmlFormatParser` implement simple `isValid`
|
|
1026
|
+
* TODO: [🍓] In `XmlFormatParser` implement partial `canBeValid`
|
|
1027
|
+
* TODO: [🍓] In `XmlFormatParser` implement `heal
|
|
1028
|
+
* TODO: [🍓] In `XmlFormatParser` implement `subvalueParsers`
|
|
996
1029
|
* TODO: [🏢] Allow to expect something inside XML and other formats
|
|
997
1030
|
*/
|
|
998
1031
|
|
|
@@ -1001,21 +1034,16 @@
|
|
|
1001
1034
|
*
|
|
1002
1035
|
* @private internal index of `...` <- TODO [🏢]
|
|
1003
1036
|
*/
|
|
1004
|
-
const FORMAT_DEFINITIONS = [
|
|
1005
|
-
JsonFormatDefinition,
|
|
1006
|
-
XmlFormatDefinition,
|
|
1007
|
-
TextFormatDefinition,
|
|
1008
|
-
CsvFormatDefinition,
|
|
1009
|
-
];
|
|
1037
|
+
const FORMAT_DEFINITIONS = [JsonFormatParser, XmlFormatParser, TextFormatParser, CsvFormatParser];
|
|
1010
1038
|
/**
|
|
1011
1039
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
1012
1040
|
*/
|
|
1013
1041
|
|
|
1014
1042
|
/**
|
|
1015
|
-
*
|
|
1043
|
+
* Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
|
|
1016
1044
|
*
|
|
1017
|
-
* @param text
|
|
1018
|
-
* @returns
|
|
1045
|
+
* @param text The text string to be converted to SCREAMING_CASE format.
|
|
1046
|
+
* @returns The normalized text in SCREAMING_CASE format.
|
|
1019
1047
|
* @example 'HELLO_WORLD'
|
|
1020
1048
|
* @example 'I_LOVE_PROMPTBOOK'
|
|
1021
1049
|
* @public exported from `@promptbook/utils`
|
|
@@ -1247,8 +1275,12 @@
|
|
|
1247
1275
|
*/
|
|
1248
1276
|
|
|
1249
1277
|
/**
|
|
1250
|
-
*
|
|
1278
|
+
* Creates a deep clone of the given object
|
|
1251
1279
|
*
|
|
1280
|
+
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
1281
|
+
*
|
|
1282
|
+
* @param objectValue The object to clone.
|
|
1283
|
+
* @returns A deep, writable clone of the input object.
|
|
1252
1284
|
* @public exported from `@promptbook/utils`
|
|
1253
1285
|
*/
|
|
1254
1286
|
function deepClone(objectValue) {
|
|
@@ -1334,11 +1366,11 @@
|
|
|
1334
1366
|
*/
|
|
1335
1367
|
|
|
1336
1368
|
/**
|
|
1337
|
-
*
|
|
1369
|
+
* Normalizes a given text to camelCase format.
|
|
1338
1370
|
*
|
|
1339
|
-
* @param text
|
|
1340
|
-
* @param _isFirstLetterCapital
|
|
1341
|
-
* @returns
|
|
1371
|
+
* @param text The text to be normalized.
|
|
1372
|
+
* @param _isFirstLetterCapital Whether the first letter should be capitalized.
|
|
1373
|
+
* @returns The camelCase formatted string.
|
|
1342
1374
|
* @example 'helloWorld'
|
|
1343
1375
|
* @example 'iLovePromptbook'
|
|
1344
1376
|
* @public exported from `@promptbook/utils`
|
|
@@ -1630,10 +1662,10 @@
|
|
|
1630
1662
|
*/
|
|
1631
1663
|
|
|
1632
1664
|
/**
|
|
1633
|
-
*
|
|
1665
|
+
* Removes diacritic marks (accents) from characters in a string.
|
|
1634
1666
|
*
|
|
1635
|
-
* @param input
|
|
1636
|
-
* @returns
|
|
1667
|
+
* @param input The string containing diacritics to be normalized.
|
|
1668
|
+
* @returns The string with diacritics removed or normalized.
|
|
1637
1669
|
* @public exported from `@promptbook/utils`
|
|
1638
1670
|
*/
|
|
1639
1671
|
function removeDiacritics(input) {
|
|
@@ -1665,9 +1697,9 @@
|
|
|
1665
1697
|
/**
|
|
1666
1698
|
* Removes quotes from a string
|
|
1667
1699
|
*
|
|
1668
|
-
* Tip: This is very
|
|
1700
|
+
* Tip: This is very useful for post-processing of the result of the LLM model
|
|
1669
1701
|
* Note: This function removes only the same quotes from the beginning and the end of the string
|
|
1670
|
-
* Note: There are two
|
|
1702
|
+
* Note: There are two similar functions:
|
|
1671
1703
|
* - `removeQuotes` which removes only bounding quotes
|
|
1672
1704
|
* - `unwrapResult` which removes whole introduce sentence
|
|
1673
1705
|
*
|
|
@@ -1679,18 +1711,19 @@
|
|
|
1679
1711
|
if (text.startsWith('"') && text.endsWith('"')) {
|
|
1680
1712
|
return text.slice(1, -1);
|
|
1681
1713
|
}
|
|
1682
|
-
if (text.startsWith('
|
|
1714
|
+
if (text.startsWith("'") && text.endsWith("'")) {
|
|
1683
1715
|
return text.slice(1, -1);
|
|
1684
1716
|
}
|
|
1685
1717
|
return text;
|
|
1686
1718
|
}
|
|
1687
1719
|
|
|
1688
1720
|
/**
|
|
1689
|
-
* Function `validateParameterName` will
|
|
1721
|
+
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
1722
|
+
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
1690
1723
|
*
|
|
1691
|
-
* @param parameterName
|
|
1692
|
-
* @returns
|
|
1693
|
-
* @throws {ParseError}
|
|
1724
|
+
* @param parameterName The parameter name to validate and normalize.
|
|
1725
|
+
* @returns The validated and normalized parameter name.
|
|
1726
|
+
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
1694
1727
|
* @private within the repository
|
|
1695
1728
|
*/
|
|
1696
1729
|
function validateParameterName(parameterName) {
|
|
@@ -1760,8 +1793,6 @@
|
|
|
1760
1793
|
/**
|
|
1761
1794
|
* Parses the foreach command
|
|
1762
1795
|
*
|
|
1763
|
-
* Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book` file
|
|
1764
|
-
*
|
|
1765
1796
|
* @see `documentationUrl` for more details
|
|
1766
1797
|
* @public exported from `@promptbook/editable`
|
|
1767
1798
|
*/
|
|
@@ -1818,14 +1849,14 @@
|
|
|
1818
1849
|
`));
|
|
1819
1850
|
// <- TODO: [🏢] List all supported format names
|
|
1820
1851
|
}
|
|
1821
|
-
const
|
|
1822
|
-
if (
|
|
1852
|
+
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
1853
|
+
if (subvalueParser === undefined) {
|
|
1823
1854
|
throw new ParseError(spaceTrim__default["default"]((block) => `
|
|
1824
1855
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
1825
1856
|
|
|
1826
1857
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
1827
|
-
${block(formatDefinition.
|
|
1828
|
-
.map((
|
|
1858
|
+
${block(formatDefinition.subvalueParsers
|
|
1859
|
+
.map((subvalueParser) => subvalueParser.subvalueName)
|
|
1829
1860
|
.map((subvalueName) => `- ${subvalueName}`)
|
|
1830
1861
|
.join('\n'))}
|
|
1831
1862
|
`));
|
|
@@ -2002,14 +2033,14 @@
|
|
|
2002
2033
|
};
|
|
2003
2034
|
|
|
2004
2035
|
/**
|
|
2005
|
-
*
|
|
2036
|
+
* Chatbot form factor definition for conversational interfaces that interact with users in a chat-like manner.
|
|
2006
2037
|
*
|
|
2007
2038
|
* @public exported from `@promptbook/core`
|
|
2008
2039
|
*/
|
|
2009
2040
|
const ChatbotFormfactorDefinition = {
|
|
2010
2041
|
name: 'CHATBOT',
|
|
2011
2042
|
aliasNames: ['CHAT'],
|
|
2012
|
-
description:
|
|
2043
|
+
description: `A chatbot form factor for conversational user interfaces.`,
|
|
2013
2044
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/174`,
|
|
2014
2045
|
pipelineInterface: {
|
|
2015
2046
|
inputParameters: [
|
|
@@ -2036,7 +2067,45 @@
|
|
|
2036
2067
|
};
|
|
2037
2068
|
|
|
2038
2069
|
/**
|
|
2039
|
-
*
|
|
2070
|
+
* Completion is formfactor that emulates completion models
|
|
2071
|
+
*
|
|
2072
|
+
* @public exported from `@promptbook/core`
|
|
2073
|
+
*/
|
|
2074
|
+
const CompletionFormfactorDefinition = {
|
|
2075
|
+
name: 'COMPLETION',
|
|
2076
|
+
description: `Completion is formfactor that emulates completion models`,
|
|
2077
|
+
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/@@`,
|
|
2078
|
+
// <- TODO: https://github.com/webgptorg/promptbook/discussions/new?category=concepts
|
|
2079
|
+
// "🔠 Completion Formfactor"
|
|
2080
|
+
pipelineInterface: {
|
|
2081
|
+
inputParameters: [
|
|
2082
|
+
{
|
|
2083
|
+
name: 'inputText',
|
|
2084
|
+
description: `Input text to be completed`,
|
|
2085
|
+
isInput: true,
|
|
2086
|
+
isOutput: false,
|
|
2087
|
+
},
|
|
2088
|
+
{
|
|
2089
|
+
name: 'instructions',
|
|
2090
|
+
description: `Additional instructions for the model, for example the required length, empty by default`,
|
|
2091
|
+
isInput: true,
|
|
2092
|
+
isOutput: false,
|
|
2093
|
+
},
|
|
2094
|
+
],
|
|
2095
|
+
outputParameters: [
|
|
2096
|
+
{
|
|
2097
|
+
name: 'followingText',
|
|
2098
|
+
description: `Text that follows the input text`,
|
|
2099
|
+
isInput: false,
|
|
2100
|
+
isOutput: true,
|
|
2101
|
+
},
|
|
2102
|
+
],
|
|
2103
|
+
},
|
|
2104
|
+
};
|
|
2105
|
+
|
|
2106
|
+
/**
|
|
2107
|
+
* Generator form factor represents an application that generates content or data based on user input or predefined rules.
|
|
2108
|
+
* This form factor is used for apps that produce outputs, such as text, images, or other media, based on provided input.
|
|
2040
2109
|
*
|
|
2041
2110
|
* @public exported from `@promptbook/core`
|
|
2042
2111
|
*/
|
|
@@ -2065,7 +2134,7 @@
|
|
|
2065
2134
|
};
|
|
2066
2135
|
|
|
2067
2136
|
/**
|
|
2068
|
-
*
|
|
2137
|
+
* Pipeline interface which is equivalent to `any`
|
|
2069
2138
|
*
|
|
2070
2139
|
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
2071
2140
|
*
|
|
@@ -2080,13 +2149,13 @@
|
|
|
2080
2149
|
*/
|
|
2081
2150
|
|
|
2082
2151
|
/**
|
|
2083
|
-
*
|
|
2152
|
+
* A generic pipeline
|
|
2084
2153
|
*
|
|
2085
2154
|
* @public exported from `@promptbook/core`
|
|
2086
2155
|
*/
|
|
2087
2156
|
const GenericFormfactorDefinition = {
|
|
2088
2157
|
name: 'GENERIC',
|
|
2089
|
-
description:
|
|
2158
|
+
description: `A generic pipeline`,
|
|
2090
2159
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/173`,
|
|
2091
2160
|
pipelineInterface: GENERIC_PIPELINE_INTERFACE,
|
|
2092
2161
|
};
|
|
@@ -2121,17 +2190,20 @@
|
|
|
2121
2190
|
};
|
|
2122
2191
|
|
|
2123
2192
|
/**
|
|
2124
|
-
* Matcher is form of app that
|
|
2193
|
+
* Matcher is form of app that evaluates (spreadsheet) content against defined criteria or patterns,
|
|
2194
|
+
* determining if it matches or meets specific requirements. Used for classification,
|
|
2195
|
+
* validation, filtering, and quality assessment of inputs.
|
|
2125
2196
|
*
|
|
2126
2197
|
* @public exported from `@promptbook/core`
|
|
2127
2198
|
*/
|
|
2128
2199
|
const MatcherFormfactorDefinition = {
|
|
2129
2200
|
name: 'EXPERIMENTAL_MATCHER',
|
|
2130
|
-
description:
|
|
2201
|
+
description: `An evaluation system that determines whether content meets specific criteria or patterns.
|
|
2202
|
+
Used for content validation, quality assessment, and intelligent filtering tasks. Currently in experimental phase.`,
|
|
2131
2203
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/177`,
|
|
2132
2204
|
pipelineInterface: {
|
|
2133
2205
|
inputParameters: [
|
|
2134
|
-
/*
|
|
2206
|
+
/* Input parameters for content to be matched and criteria to match against */
|
|
2135
2207
|
{
|
|
2136
2208
|
name: 'nonce',
|
|
2137
2209
|
description: 'Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor',
|
|
@@ -2140,20 +2212,21 @@
|
|
|
2140
2212
|
},
|
|
2141
2213
|
],
|
|
2142
2214
|
outputParameters: [
|
|
2143
|
-
/*
|
|
2215
|
+
/* Output parameters containing match results, confidence scores, and relevant metadata */
|
|
2144
2216
|
],
|
|
2145
2217
|
},
|
|
2146
2218
|
};
|
|
2147
2219
|
|
|
2148
2220
|
/**
|
|
2149
|
-
* Sheets is form of app that
|
|
2221
|
+
* Sheets is form of app that processes tabular data in CSV format, allowing transformation
|
|
2222
|
+
* and analysis of structured data through AI-powered operations
|
|
2150
2223
|
*
|
|
2151
2224
|
* @public exported from `@promptbook/core`
|
|
2152
2225
|
*/
|
|
2153
2226
|
const SheetsFormfactorDefinition = {
|
|
2154
2227
|
name: 'SHEETS',
|
|
2155
2228
|
aliasNames: ['SHEETS', 'SHEET'],
|
|
2156
|
-
description:
|
|
2229
|
+
description: `A formfactor for processing spreadsheet-like data in CSV format, enabling AI transformations on tabular data`,
|
|
2157
2230
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/176`,
|
|
2158
2231
|
pipelineInterface: {
|
|
2159
2232
|
inputParameters: [
|
|
@@ -2176,13 +2249,16 @@
|
|
|
2176
2249
|
};
|
|
2177
2250
|
|
|
2178
2251
|
/**
|
|
2179
|
-
* Translator is form of app that
|
|
2252
|
+
* Translator is form of app that transforms input text from one form to another,
|
|
2253
|
+
* such as language translation, style conversion, tone modification, or other text transformations.
|
|
2180
2254
|
*
|
|
2181
2255
|
* @public exported from `@promptbook/core`
|
|
2182
2256
|
*/
|
|
2183
2257
|
const TranslatorFormfactorDefinition = {
|
|
2184
2258
|
name: 'TRANSLATOR',
|
|
2185
|
-
description:
|
|
2259
|
+
description: `A text transformation system that converts input content into different forms,
|
|
2260
|
+
including language translations, paraphrasing, style conversions, and tone adjustments.
|
|
2261
|
+
This form factor takes one input and produces one transformed output.`,
|
|
2186
2262
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/175`,
|
|
2187
2263
|
pipelineInterface: {
|
|
2188
2264
|
inputParameters: [
|
|
@@ -2219,6 +2295,8 @@
|
|
|
2219
2295
|
MatcherFormfactorDefinition,
|
|
2220
2296
|
GeneratorFormfactorDefinition,
|
|
2221
2297
|
ImageGeneratorFormfactorDefinition,
|
|
2298
|
+
CompletionFormfactorDefinition,
|
|
2299
|
+
// <- [🛬] When making new formfactor, copy the _boilerplate and link it here
|
|
2222
2300
|
];
|
|
2223
2301
|
/**
|
|
2224
2302
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2227,7 +2305,7 @@
|
|
|
2227
2305
|
/**
|
|
2228
2306
|
* Parses the formfactor command
|
|
2229
2307
|
*
|
|
2230
|
-
* Note:
|
|
2308
|
+
* 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
|
|
2231
2309
|
*
|
|
2232
2310
|
* @see `documentationUrl` for more details
|
|
2233
2311
|
* @public exported from `@promptbook/editable`
|
|
@@ -2249,7 +2327,7 @@
|
|
|
2249
2327
|
/**
|
|
2250
2328
|
* Description of the FORMFACTOR command
|
|
2251
2329
|
*/
|
|
2252
|
-
description:
|
|
2330
|
+
description: `Specifies the application type and interface requirements that this promptbook should conform to`,
|
|
2253
2331
|
/**
|
|
2254
2332
|
* Link to documentation
|
|
2255
2333
|
*/
|
|
@@ -2444,7 +2522,7 @@
|
|
|
2444
2522
|
* Tests if given string is valid URL.
|
|
2445
2523
|
*
|
|
2446
2524
|
* Note: Dataurl are considered perfectly valid.
|
|
2447
|
-
* Note: There are two
|
|
2525
|
+
* Note: There are two similar functions:
|
|
2448
2526
|
* - `isValidUrl` which tests any URL
|
|
2449
2527
|
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
2450
2528
|
*
|
|
@@ -2470,10 +2548,10 @@
|
|
|
2470
2548
|
}
|
|
2471
2549
|
|
|
2472
2550
|
/**
|
|
2473
|
-
*
|
|
2551
|
+
* Converts a given text to kebab-case format.
|
|
2474
2552
|
*
|
|
2475
|
-
* @param text
|
|
2476
|
-
* @returns
|
|
2553
|
+
* @param text The text to be converted.
|
|
2554
|
+
* @returns The kebab-case formatted string.
|
|
2477
2555
|
* @example 'hello-world'
|
|
2478
2556
|
* @example 'i-love-promptbook'
|
|
2479
2557
|
* @public exported from `@promptbook/utils`
|
|
@@ -2636,8 +2714,7 @@
|
|
|
2636
2714
|
*/
|
|
2637
2715
|
|
|
2638
2716
|
/**
|
|
2639
|
-
*
|
|
2640
|
-
*
|
|
2717
|
+
* @see {@link ModelVariant}
|
|
2641
2718
|
* @public exported from `@promptbook/core`
|
|
2642
2719
|
*/
|
|
2643
2720
|
const MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
|
|
@@ -3069,10 +3146,10 @@
|
|
|
3069
3146
|
}
|
|
3070
3147
|
|
|
3071
3148
|
/**
|
|
3072
|
-
*
|
|
3149
|
+
* Checks if the given value is a valid JavaScript identifier name.
|
|
3073
3150
|
*
|
|
3074
|
-
* @param javascriptName
|
|
3075
|
-
* @returns
|
|
3151
|
+
* @param javascriptName The value to check for JavaScript identifier validity.
|
|
3152
|
+
* @returns `true` if the value is a valid JavaScript name, false otherwise.
|
|
3076
3153
|
* @public exported from `@promptbook/utils`
|
|
3077
3154
|
*/
|
|
3078
3155
|
function isValidJavascriptName(javascriptName) {
|
|
@@ -3321,7 +3398,7 @@
|
|
|
3321
3398
|
throw new ParseError(`Task section and example section must end with return statement -> {parameterName}`);
|
|
3322
3399
|
};
|
|
3323
3400
|
if ($taskJson.content === undefined) {
|
|
3324
|
-
throw new UnexpectedError(`Content is missing in the taskJson -
|
|
3401
|
+
throw new UnexpectedError(`Content is missing in the taskJson - probably commands are applied in wrong order`);
|
|
3325
3402
|
}
|
|
3326
3403
|
if (command.taskType === 'EXAMPLE') {
|
|
3327
3404
|
expectResultingParameterName();
|
|
@@ -3389,7 +3466,7 @@
|
|
|
3389
3466
|
/**
|
|
3390
3467
|
* Tests if given string is valid pipeline URL URL.
|
|
3391
3468
|
*
|
|
3392
|
-
* Note: There are two
|
|
3469
|
+
* Note: There are two similar functions:
|
|
3393
3470
|
* - `isValidUrl` which tests any URL
|
|
3394
3471
|
* - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
|
|
3395
3472
|
*
|
|
@@ -3791,7 +3868,7 @@
|
|
|
3791
3868
|
// Arg1 Arg2 Arg3 | FOO
|
|
3792
3869
|
{
|
|
3793
3870
|
const commandNameRaw = items.slice(-1).join('_');
|
|
3794
|
-
const args = items.slice(0, -1); // <- Note: This is
|
|
3871
|
+
const args = items.slice(0, -1); // <- Note: This is probably not correct
|
|
3795
3872
|
const rawArgs = raw
|
|
3796
3873
|
.substring(0, raw.length - commandNameRaw.length)
|
|
3797
3874
|
.trim();
|
|
@@ -3810,7 +3887,10 @@
|
|
|
3810
3887
|
`));
|
|
3811
3888
|
}
|
|
3812
3889
|
/**
|
|
3813
|
-
*
|
|
3890
|
+
* Generates a markdown-formatted message listing all supported commands
|
|
3891
|
+
* with their descriptions and documentation links
|
|
3892
|
+
*
|
|
3893
|
+
* @returns A formatted markdown string containing all available commands and their details
|
|
3814
3894
|
*/
|
|
3815
3895
|
function getSupportedCommandsMessage() {
|
|
3816
3896
|
return COMMANDS.flatMap(({ name, aliasNames, description, documentationUrl }) =>
|
|
@@ -3821,7 +3901,10 @@
|
|
|
3821
3901
|
]).join('\n');
|
|
3822
3902
|
}
|
|
3823
3903
|
/**
|
|
3824
|
-
*
|
|
3904
|
+
* Attempts to parse a command variant using the provided input parameters
|
|
3905
|
+
*
|
|
3906
|
+
* @param input Object containing command parsing information including raw command text and normalized values
|
|
3907
|
+
* @returns A parsed Command object if successful, or null if the command cannot be parsed
|
|
3825
3908
|
*/
|
|
3826
3909
|
function parseCommandVariant(input) {
|
|
3827
3910
|
const { commandNameRaw, usagePlace, normalized, args, raw, rawArgs } = input;
|
|
@@ -3923,7 +4006,8 @@
|
|
|
3923
4006
|
}
|
|
3924
4007
|
|
|
3925
4008
|
/**
|
|
3926
|
-
*
|
|
4009
|
+
* Utility to determine if a pipeline string is in flat format.
|
|
4010
|
+
* A flat pipeline is a simple text without proper structure (headers, blocks, etc).
|
|
3927
4011
|
*
|
|
3928
4012
|
* @public exported from `@promptbook/editable`
|
|
3929
4013
|
*/
|
|
@@ -3944,7 +4028,10 @@
|
|
|
3944
4028
|
}
|
|
3945
4029
|
|
|
3946
4030
|
/**
|
|
3947
|
-
*
|
|
4031
|
+
* Converts a pipeline structure to its string representation.
|
|
4032
|
+
*
|
|
4033
|
+
* Transforms a flat, simple pipeline into a properly formatted pipeline string
|
|
4034
|
+
* with sections for title, prompt, and return statement.
|
|
3948
4035
|
*
|
|
3949
4036
|
* @public exported from `@promptbook/editable`
|
|
3950
4037
|
*/
|
|
@@ -3993,7 +4080,7 @@
|
|
|
3993
4080
|
*/
|
|
3994
4081
|
|
|
3995
4082
|
/**
|
|
3996
|
-
*
|
|
4083
|
+
* Adds a new command to a pipeline string in the correct format.
|
|
3997
4084
|
*
|
|
3998
4085
|
* @public exported from `@promptbook/editable`
|
|
3999
4086
|
*/
|
|
@@ -4206,7 +4293,7 @@
|
|
|
4206
4293
|
return pipelineJsonStringified;
|
|
4207
4294
|
}
|
|
4208
4295
|
/**
|
|
4209
|
-
* TODO: [🐝] Not Working
|
|
4296
|
+
* TODO: [🐝] Not Working properly @see https://promptbook.studio/examples/mixed-knowledge.book
|
|
4210
4297
|
* TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
|
|
4211
4298
|
* TODO: [🧠] Maybe more elegant solution than replacing via regex
|
|
4212
4299
|
* TODO: [🍙] Make some standard order of json properties
|