@promptbook/remote-client 0.92.0-3 → 0.92.0-31
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/esm/index.es.js +199 -111
- 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 +22 -6
- package/esm/typings/src/_packages/deepseek.index.d.ts +2 -0
- package/esm/typings/src/_packages/google.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +4 -2
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +1 -1
- 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/archive/loadArchive.d.ts +2 -2
- package/esm/typings/src/errors/0-BoilerplateError.d.ts +2 -2
- 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/LlmExecutionToolsConstructor.d.ts +2 -1
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +4 -2
- 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 +20 -14
- 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 +21 -5
- package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +19 -5
- package/esm/typings/src/execution/createPipelineExecutor/knowledgePiecesToString.d.ts +9 -0
- package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +4 -4
- package/esm/typings/src/execution/utils/checkExpectations.d.ts +1 -1
- package/esm/typings/src/execution/utils/uncertainNumber.d.ts +3 -2
- 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/{JsonFormatDefinition.d.ts → JsonFormatParser.d.ts} +6 -6
- package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +1 -1
- package/esm/typings/src/formats/json/utils/jsonParse.d.ts +8 -0
- 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 +17 -4
- package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +11 -4
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +27 -5
- package/esm/typings/src/llm-providers/_common/register/LlmToolsOptions.d.ts +9 -2
- package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +12 -3
- 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 +5 -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/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -0
- package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +23 -0
- package/esm/typings/src/llm-providers/google/google-models.d.ts +23 -0
- 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/personas/preparePersona.d.ts +1 -1
- 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 +9 -6
- package/esm/typings/src/pipeline/PipelineJson/PersonaJson.d.ts +4 -2
- 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/extractJsonBlock.d.ts +1 -1
- package/esm/typings/src/prepare/prepareTasks.d.ts +7 -4
- package/esm/typings/src/remote-server/openapi-types.d.ts +348 -6
- package/esm/typings/src/remote-server/openapi.d.ts +398 -4
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +2 -1
- 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/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/postprocessing-functions.d.ts +5 -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 +10 -0
- package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.d.ts +7 -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/ModelVariant.d.ts +5 -5
- package/esm/typings/src/types/typeAliases.d.ts +17 -13
- 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/environment/$getGlobalScope.d.ts +2 -1
- package/esm/typings/src/utils/expectation-counters/index.d.ts +1 -1
- package/esm/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +1 -1
- 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/empty_object.d.ts +2 -2
- package/esm/typings/src/utils/organization/just_empty_object.d.ts +4 -4
- package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +7 -7
- 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/validators/javascriptName/isValidJavascriptName.d.ts +3 -3
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +5 -4
- package/esm/typings/src/version.d.ts +2 -1
- package/package.json +2 -2
- package/umd/index.umd.js +199 -111
- 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/xml/XmlFormatDefinition.d.ts +0 -19
package/esm/index.es.js
CHANGED
|
@@ -20,7 +20,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
20
20
|
* @generated
|
|
21
21
|
* @see https://github.com/webgptorg/promptbook
|
|
22
22
|
*/
|
|
23
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
23
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-31';
|
|
24
24
|
/**
|
|
25
25
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
26
26
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -361,7 +361,7 @@ const CONNECTION_TIMEOUT_MS = 7 * 1000;
|
|
|
361
361
|
const CONNECTION_RETRIES_LIMIT = 5;
|
|
362
362
|
// <- TODO: [🧜♂️]
|
|
363
363
|
/**
|
|
364
|
-
*
|
|
364
|
+
* Default settings for parsing and generating CSV files in Promptbook.
|
|
365
365
|
*
|
|
366
366
|
* @public exported from `@promptbook/core`
|
|
367
367
|
*/
|
|
@@ -993,10 +993,10 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
|
993
993
|
*/
|
|
994
994
|
|
|
995
995
|
/**
|
|
996
|
-
*
|
|
996
|
+
* Removes diacritic marks (accents) from characters in a string.
|
|
997
997
|
*
|
|
998
|
-
* @param input
|
|
999
|
-
* @returns
|
|
998
|
+
* @param input The string containing diacritics to be normalized.
|
|
999
|
+
* @returns The string with diacritics removed or normalized.
|
|
1000
1000
|
* @public exported from `@promptbook/utils`
|
|
1001
1001
|
*/
|
|
1002
1002
|
function removeDiacritics(input) {
|
|
@@ -1010,10 +1010,10 @@ function removeDiacritics(input) {
|
|
|
1010
1010
|
*/
|
|
1011
1011
|
|
|
1012
1012
|
/**
|
|
1013
|
-
*
|
|
1013
|
+
* Converts a given text to kebab-case format.
|
|
1014
1014
|
*
|
|
1015
|
-
* @param text
|
|
1016
|
-
* @returns
|
|
1015
|
+
* @param text The text to be converted.
|
|
1016
|
+
* @returns The kebab-case formatted string.
|
|
1017
1017
|
* @example 'hello-world'
|
|
1018
1018
|
* @example 'i-love-promptbook'
|
|
1019
1019
|
* @public exported from `@promptbook/utils`
|
|
@@ -1367,7 +1367,7 @@ const sectionCommandParser = {
|
|
|
1367
1367
|
/**
|
|
1368
1368
|
* Parses the boilerplate command
|
|
1369
1369
|
*
|
|
1370
|
-
* Note:
|
|
1370
|
+
* Note: @@ This command is used as boilerplate for new commands - it should NOT be used in any `.book` file
|
|
1371
1371
|
*
|
|
1372
1372
|
* @see `documentationUrl` for more details
|
|
1373
1373
|
* @private within the commands folder
|
|
@@ -1825,7 +1825,7 @@ const expectCommandParser = {
|
|
|
1825
1825
|
};
|
|
1826
1826
|
|
|
1827
1827
|
/**
|
|
1828
|
-
*
|
|
1828
|
+
* Contains configuration options for parsing and generating CSV files, such as delimiters and quoting rules.
|
|
1829
1829
|
*
|
|
1830
1830
|
* @public exported from `@promptbook/core`
|
|
1831
1831
|
*/
|
|
@@ -1834,11 +1834,29 @@ const MANDATORY_CSV_SETTINGS = Object.freeze({
|
|
|
1834
1834
|
// encoding: 'utf-8',
|
|
1835
1835
|
});
|
|
1836
1836
|
|
|
1837
|
+
/**
|
|
1838
|
+
* Converts a CSV string into an object
|
|
1839
|
+
*
|
|
1840
|
+
* Note: This is wrapper around `papaparse.parse()` with better autohealing
|
|
1841
|
+
*
|
|
1842
|
+
* @private - for now until `@promptbook/csv` is released
|
|
1843
|
+
*/
|
|
1844
|
+
function csvParse(value /* <- TODO: string_csv */, settings, schema /* <- TODO: Make CSV Schemas */) {
|
|
1845
|
+
settings = { ...settings, ...MANDATORY_CSV_SETTINGS };
|
|
1846
|
+
// Note: Autoheal invalid '\n' characters
|
|
1847
|
+
if (settings.newline && !settings.newline.includes('\r') && value.includes('\r')) {
|
|
1848
|
+
console.warn('CSV string contains carriage return characters, but in the CSV settings the `newline` setting does not include them. Autohealing the CSV string.');
|
|
1849
|
+
value = value.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
1850
|
+
}
|
|
1851
|
+
const csv = parse(value, settings);
|
|
1852
|
+
return csv;
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1837
1855
|
/**
|
|
1838
1856
|
* Function to check if a string is valid CSV
|
|
1839
1857
|
*
|
|
1840
1858
|
* @param value The string to check
|
|
1841
|
-
* @returns
|
|
1859
|
+
* @returns `true` if the string is a valid CSV string, false otherwise
|
|
1842
1860
|
*
|
|
1843
1861
|
* @public exported from `@promptbook/utils`
|
|
1844
1862
|
*/
|
|
@@ -1862,7 +1880,7 @@ function isValidCsvString(value) {
|
|
|
1862
1880
|
* @public exported from `@promptbook/core`
|
|
1863
1881
|
* <- TODO: [🏢] Export from package `@promptbook/csv`
|
|
1864
1882
|
*/
|
|
1865
|
-
const
|
|
1883
|
+
const CsvFormatParser = {
|
|
1866
1884
|
formatName: 'CSV',
|
|
1867
1885
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
1868
1886
|
isValid(value, settings, schema) {
|
|
@@ -1874,12 +1892,12 @@ const CsvFormatDefinition = {
|
|
|
1874
1892
|
heal(value, settings, schema) {
|
|
1875
1893
|
throw new Error('Not implemented');
|
|
1876
1894
|
},
|
|
1877
|
-
|
|
1895
|
+
subvalueParsers: [
|
|
1878
1896
|
{
|
|
1879
1897
|
subvalueName: 'ROW',
|
|
1880
|
-
async mapValues(
|
|
1881
|
-
|
|
1882
|
-
const csv =
|
|
1898
|
+
async mapValues(options) {
|
|
1899
|
+
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
1900
|
+
const csv = csvParse(value, settings);
|
|
1883
1901
|
if (csv.errors.length !== 0) {
|
|
1884
1902
|
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
1885
1903
|
CSV parsing error
|
|
@@ -1894,23 +1912,37 @@ const CsvFormatDefinition = {
|
|
|
1894
1912
|
${block(value)}
|
|
1895
1913
|
`));
|
|
1896
1914
|
}
|
|
1897
|
-
const mappedData =
|
|
1915
|
+
const mappedData = [];
|
|
1916
|
+
const length = csv.data.length;
|
|
1917
|
+
for (let index = 0; index < length; index++) {
|
|
1918
|
+
const row = csv.data[index];
|
|
1898
1919
|
if (row[outputParameterName]) {
|
|
1899
1920
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
1900
1921
|
}
|
|
1901
|
-
|
|
1922
|
+
const mappedRow = {
|
|
1902
1923
|
...row,
|
|
1903
|
-
[outputParameterName]: await mapCallback(row, index),
|
|
1924
|
+
[outputParameterName]: await mapCallback(row, index, length),
|
|
1904
1925
|
};
|
|
1905
|
-
|
|
1926
|
+
mappedData.push(mappedRow);
|
|
1927
|
+
if (onProgress) {
|
|
1928
|
+
// Note: Report the CSV with all rows mapped so far
|
|
1929
|
+
/*
|
|
1930
|
+
// TODO: [🛕] Report progress with all the rows including the pending ones
|
|
1931
|
+
const progressData = mappedData.map((row, i) =>
|
|
1932
|
+
i > index ? { ...row, [outputParameterName]: PENDING_VALUE_PLACEHOLDER } : row,
|
|
1933
|
+
);
|
|
1934
|
+
*/
|
|
1935
|
+
await onProgress(unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1906
1938
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
1907
1939
|
},
|
|
1908
1940
|
},
|
|
1909
1941
|
{
|
|
1910
1942
|
subvalueName: 'CELL',
|
|
1911
|
-
async mapValues(
|
|
1912
|
-
|
|
1913
|
-
const csv =
|
|
1943
|
+
async mapValues(options) {
|
|
1944
|
+
const { value, settings, mapCallback, onProgress } = options;
|
|
1945
|
+
const csv = csvParse(value, settings);
|
|
1914
1946
|
if (csv.errors.length !== 0) {
|
|
1915
1947
|
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
1916
1948
|
CSV parsing error
|
|
@@ -1926,9 +1958,9 @@ const CsvFormatDefinition = {
|
|
|
1926
1958
|
`));
|
|
1927
1959
|
}
|
|
1928
1960
|
const mappedData = await Promise.all(csv.data.map(async (row, rowIndex) => {
|
|
1929
|
-
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex) => {
|
|
1961
|
+
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex, array) => {
|
|
1930
1962
|
const index = rowIndex * Object.keys(row).length + columnIndex;
|
|
1931
|
-
return /* not await */ mapCallback({ [key]: value }, index);
|
|
1963
|
+
return /* not await */ mapCallback({ [key]: value }, index, array.length);
|
|
1932
1964
|
}));
|
|
1933
1965
|
}));
|
|
1934
1966
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
@@ -1937,10 +1969,10 @@ const CsvFormatDefinition = {
|
|
|
1937
1969
|
],
|
|
1938
1970
|
};
|
|
1939
1971
|
/**
|
|
1940
|
-
* TODO: [🍓] In `
|
|
1941
|
-
* TODO: [🍓] In `
|
|
1942
|
-
* TODO: [🍓] In `
|
|
1943
|
-
* TODO: [🍓] In `
|
|
1972
|
+
* TODO: [🍓] In `CsvFormatParser` implement simple `isValid`
|
|
1973
|
+
* TODO: [🍓] In `CsvFormatParser` implement partial `canBeValid`
|
|
1974
|
+
* TODO: [🍓] In `CsvFormatParser` implement `heal
|
|
1975
|
+
* TODO: [🍓] In `CsvFormatParser` implement `subvalueParsers`
|
|
1944
1976
|
* TODO: [🏢] Allow to expect something inside CSV objects and other formats
|
|
1945
1977
|
*/
|
|
1946
1978
|
|
|
@@ -1948,7 +1980,7 @@ const CsvFormatDefinition = {
|
|
|
1948
1980
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
1949
1981
|
*
|
|
1950
1982
|
* @param value The string to check
|
|
1951
|
-
* @returns
|
|
1983
|
+
* @returns `true` if the string is a valid JSON string, false otherwise
|
|
1952
1984
|
*
|
|
1953
1985
|
* @public exported from `@promptbook/utils`
|
|
1954
1986
|
*/
|
|
@@ -1971,7 +2003,7 @@ function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
|
1971
2003
|
*
|
|
1972
2004
|
* @private still in development [🏢]
|
|
1973
2005
|
*/
|
|
1974
|
-
const
|
|
2006
|
+
const JsonFormatParser = {
|
|
1975
2007
|
formatName: 'JSON',
|
|
1976
2008
|
mimeType: 'application/json',
|
|
1977
2009
|
isValid(value, settings, schema) {
|
|
@@ -1983,28 +2015,28 @@ const JsonFormatDefinition = {
|
|
|
1983
2015
|
heal(value, settings, schema) {
|
|
1984
2016
|
throw new Error('Not implemented');
|
|
1985
2017
|
},
|
|
1986
|
-
|
|
2018
|
+
subvalueParsers: [],
|
|
1987
2019
|
};
|
|
1988
2020
|
/**
|
|
1989
2021
|
* TODO: [🧠] Maybe propper instance of object
|
|
1990
2022
|
* TODO: [0] Make string_serialized_json
|
|
1991
2023
|
* TODO: [1] Make type for JSON Settings and Schema
|
|
1992
2024
|
* TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
|
|
1993
|
-
* TODO: [🍓] In `
|
|
1994
|
-
* TODO: [🍓] In `
|
|
1995
|
-
* TODO: [🍓] In `
|
|
1996
|
-
* TODO: [🍓] In `
|
|
2025
|
+
* TODO: [🍓] In `JsonFormatParser` implement simple `isValid`
|
|
2026
|
+
* TODO: [🍓] In `JsonFormatParser` implement partial `canBeValid`
|
|
2027
|
+
* TODO: [🍓] In `JsonFormatParser` implement `heal
|
|
2028
|
+
* TODO: [🍓] In `JsonFormatParser` implement `subvalueParsers`
|
|
1997
2029
|
* TODO: [🏢] Allow to expect something inside JSON objects and other formats
|
|
1998
2030
|
*/
|
|
1999
2031
|
|
|
2000
2032
|
/**
|
|
2001
2033
|
* Definition for any text - this will be always valid
|
|
2002
2034
|
*
|
|
2003
|
-
* Note: This is not useful for validation, but for splitting and mapping with `
|
|
2035
|
+
* Note: This is not useful for validation, but for splitting and mapping with `subvalueParsers`
|
|
2004
2036
|
*
|
|
2005
2037
|
* @public exported from `@promptbook/core`
|
|
2006
2038
|
*/
|
|
2007
|
-
const
|
|
2039
|
+
const TextFormatParser = {
|
|
2008
2040
|
formatName: 'TEXT',
|
|
2009
2041
|
isValid(value) {
|
|
2010
2042
|
return typeof value === 'string';
|
|
@@ -2013,19 +2045,20 @@ const TextFormatDefinition = {
|
|
|
2013
2045
|
return typeof partialValue === 'string';
|
|
2014
2046
|
},
|
|
2015
2047
|
heal() {
|
|
2016
|
-
throw new UnexpectedError('It does not make sense to call `
|
|
2048
|
+
throw new UnexpectedError('It does not make sense to call `TextFormatParser.heal`');
|
|
2017
2049
|
},
|
|
2018
|
-
|
|
2050
|
+
subvalueParsers: [
|
|
2019
2051
|
{
|
|
2020
2052
|
subvalueName: 'LINE',
|
|
2021
|
-
async mapValues(
|
|
2053
|
+
async mapValues(options) {
|
|
2054
|
+
const { value, mapCallback, onProgress } = options;
|
|
2022
2055
|
const lines = value.split('\n');
|
|
2023
|
-
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
2056
|
+
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
|
|
2024
2057
|
// TODO: [🧠] Maybe option to skip empty line
|
|
2025
2058
|
/* not await */ mapCallback({
|
|
2026
2059
|
lineContent,
|
|
2027
2060
|
// TODO: [🧠] Maybe also put here `lineNumber`
|
|
2028
|
-
}, lineNumber)));
|
|
2061
|
+
}, lineNumber, array.length)));
|
|
2029
2062
|
return mappedLines.join('\n');
|
|
2030
2063
|
},
|
|
2031
2064
|
},
|
|
@@ -2035,10 +2068,10 @@ const TextFormatDefinition = {
|
|
|
2035
2068
|
/**
|
|
2036
2069
|
* TODO: [1] Make type for XML Text and Schema
|
|
2037
2070
|
* TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages available as subvalues
|
|
2038
|
-
* TODO: [🍓] In `
|
|
2039
|
-
* TODO: [🍓] In `
|
|
2040
|
-
* TODO: [🍓] In `
|
|
2041
|
-
* TODO: [🍓] In `
|
|
2071
|
+
* TODO: [🍓] In `TextFormatParser` implement simple `isValid`
|
|
2072
|
+
* TODO: [🍓] In `TextFormatParser` implement partial `canBeValid`
|
|
2073
|
+
* TODO: [🍓] In `TextFormatParser` implement `heal
|
|
2074
|
+
* TODO: [🍓] In `TextFormatParser` implement `subvalueParsers`
|
|
2042
2075
|
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
2043
2076
|
*/
|
|
2044
2077
|
|
|
@@ -2046,7 +2079,7 @@ const TextFormatDefinition = {
|
|
|
2046
2079
|
* Function to check if a string is valid XML
|
|
2047
2080
|
*
|
|
2048
2081
|
* @param value
|
|
2049
|
-
* @returns
|
|
2082
|
+
* @returns `true` if the string is a valid XML string, false otherwise
|
|
2050
2083
|
*
|
|
2051
2084
|
* @public exported from `@promptbook/utils`
|
|
2052
2085
|
*/
|
|
@@ -2071,7 +2104,7 @@ function isValidXmlString(value) {
|
|
|
2071
2104
|
*
|
|
2072
2105
|
* @private still in development [🏢]
|
|
2073
2106
|
*/
|
|
2074
|
-
const
|
|
2107
|
+
const XmlFormatParser = {
|
|
2075
2108
|
formatName: 'XML',
|
|
2076
2109
|
mimeType: 'application/xml',
|
|
2077
2110
|
isValid(value, settings, schema) {
|
|
@@ -2083,17 +2116,17 @@ const XmlFormatDefinition = {
|
|
|
2083
2116
|
heal(value, settings, schema) {
|
|
2084
2117
|
throw new Error('Not implemented');
|
|
2085
2118
|
},
|
|
2086
|
-
|
|
2119
|
+
subvalueParsers: [],
|
|
2087
2120
|
};
|
|
2088
2121
|
/**
|
|
2089
2122
|
* TODO: [🧠] Maybe propper instance of object
|
|
2090
2123
|
* TODO: [0] Make string_serialized_xml
|
|
2091
2124
|
* TODO: [1] Make type for XML Settings and Schema
|
|
2092
2125
|
* TODO: [🧠] What to use for validating XMLs - XSD,...
|
|
2093
|
-
* TODO: [🍓] In `
|
|
2094
|
-
* TODO: [🍓] In `
|
|
2095
|
-
* TODO: [🍓] In `
|
|
2096
|
-
* TODO: [🍓] In `
|
|
2126
|
+
* TODO: [🍓] In `XmlFormatParser` implement simple `isValid`
|
|
2127
|
+
* TODO: [🍓] In `XmlFormatParser` implement partial `canBeValid`
|
|
2128
|
+
* TODO: [🍓] In `XmlFormatParser` implement `heal
|
|
2129
|
+
* TODO: [🍓] In `XmlFormatParser` implement `subvalueParsers`
|
|
2097
2130
|
* TODO: [🏢] Allow to expect something inside XML and other formats
|
|
2098
2131
|
*/
|
|
2099
2132
|
|
|
@@ -2102,21 +2135,16 @@ const XmlFormatDefinition = {
|
|
|
2102
2135
|
*
|
|
2103
2136
|
* @private internal index of `...` <- TODO [🏢]
|
|
2104
2137
|
*/
|
|
2105
|
-
const FORMAT_DEFINITIONS = [
|
|
2106
|
-
JsonFormatDefinition,
|
|
2107
|
-
XmlFormatDefinition,
|
|
2108
|
-
TextFormatDefinition,
|
|
2109
|
-
CsvFormatDefinition,
|
|
2110
|
-
];
|
|
2138
|
+
const FORMAT_DEFINITIONS = [JsonFormatParser, XmlFormatParser, TextFormatParser, CsvFormatParser];
|
|
2111
2139
|
/**
|
|
2112
2140
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2113
2141
|
*/
|
|
2114
2142
|
|
|
2115
2143
|
/**
|
|
2116
|
-
*
|
|
2144
|
+
* Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
|
|
2117
2145
|
*
|
|
2118
|
-
* @param text
|
|
2119
|
-
* @returns
|
|
2146
|
+
* @param text The text string to be converted to SCREAMING_CASE format.
|
|
2147
|
+
* @returns The normalized text in SCREAMING_CASE format.
|
|
2120
2148
|
* @example 'HELLO_WORLD'
|
|
2121
2149
|
* @example 'I_LOVE_PROMPTBOOK'
|
|
2122
2150
|
* @public exported from `@promptbook/utils`
|
|
@@ -2348,8 +2376,12 @@ function checkSerializableAsJson(options) {
|
|
|
2348
2376
|
*/
|
|
2349
2377
|
|
|
2350
2378
|
/**
|
|
2351
|
-
*
|
|
2379
|
+
* Creates a deep clone of the given object
|
|
2352
2380
|
*
|
|
2381
|
+
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
2382
|
+
*
|
|
2383
|
+
* @param objectValue The object to clone.
|
|
2384
|
+
* @returns A deep, writable clone of the input object.
|
|
2353
2385
|
* @public exported from `@promptbook/utils`
|
|
2354
2386
|
*/
|
|
2355
2387
|
function deepClone(objectValue) {
|
|
@@ -2449,11 +2481,11 @@ const RESERVED_PARAMETER_NAMES = exportJson({
|
|
|
2449
2481
|
*/
|
|
2450
2482
|
|
|
2451
2483
|
/**
|
|
2452
|
-
*
|
|
2484
|
+
* Normalizes a given text to camelCase format.
|
|
2453
2485
|
*
|
|
2454
|
-
* @param text
|
|
2455
|
-
* @param _isFirstLetterCapital
|
|
2456
|
-
* @returns
|
|
2486
|
+
* @param text The text to be normalized.
|
|
2487
|
+
* @param _isFirstLetterCapital Whether the first letter should be capitalized.
|
|
2488
|
+
* @returns The camelCase formatted string.
|
|
2457
2489
|
* @example 'helloWorld'
|
|
2458
2490
|
* @example 'iLovePromptbook'
|
|
2459
2491
|
* @public exported from `@promptbook/utils`
|
|
@@ -2540,11 +2572,12 @@ function removeQuotes(text) {
|
|
|
2540
2572
|
}
|
|
2541
2573
|
|
|
2542
2574
|
/**
|
|
2543
|
-
* Function `validateParameterName` will
|
|
2575
|
+
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
2576
|
+
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
2544
2577
|
*
|
|
2545
|
-
* @param parameterName
|
|
2546
|
-
* @returns
|
|
2547
|
-
* @throws {ParseError}
|
|
2578
|
+
* @param parameterName The parameter name to validate and normalize.
|
|
2579
|
+
* @returns The validated and normalized parameter name.
|
|
2580
|
+
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
2548
2581
|
* @private within the repository
|
|
2549
2582
|
*/
|
|
2550
2583
|
function validateParameterName(parameterName) {
|
|
@@ -2614,8 +2647,6 @@ function validateParameterName(parameterName) {
|
|
|
2614
2647
|
/**
|
|
2615
2648
|
* Parses the foreach command
|
|
2616
2649
|
*
|
|
2617
|
-
* Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book` file
|
|
2618
|
-
*
|
|
2619
2650
|
* @see `documentationUrl` for more details
|
|
2620
2651
|
* @public exported from `@promptbook/editable`
|
|
2621
2652
|
*/
|
|
@@ -2672,14 +2703,14 @@ const foreachCommandParser = {
|
|
|
2672
2703
|
`));
|
|
2673
2704
|
// <- TODO: [🏢] List all supported format names
|
|
2674
2705
|
}
|
|
2675
|
-
const
|
|
2676
|
-
if (
|
|
2706
|
+
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
2707
|
+
if (subvalueParser === undefined) {
|
|
2677
2708
|
throw new ParseError(spaceTrim$1((block) => `
|
|
2678
2709
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
2679
2710
|
|
|
2680
2711
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
2681
|
-
${block(formatDefinition.
|
|
2682
|
-
.map((
|
|
2712
|
+
${block(formatDefinition.subvalueParsers
|
|
2713
|
+
.map((subvalueParser) => subvalueParser.subvalueName)
|
|
2683
2714
|
.map((subvalueName) => `- ${subvalueName}`)
|
|
2684
2715
|
.join('\n'))}
|
|
2685
2716
|
`));
|
|
@@ -2856,14 +2887,14 @@ const formatCommandParser = {
|
|
|
2856
2887
|
};
|
|
2857
2888
|
|
|
2858
2889
|
/**
|
|
2859
|
-
*
|
|
2890
|
+
* Chatbot form factor definition for conversational interfaces that interact with users in a chat-like manner.
|
|
2860
2891
|
*
|
|
2861
2892
|
* @public exported from `@promptbook/core`
|
|
2862
2893
|
*/
|
|
2863
2894
|
const ChatbotFormfactorDefinition = {
|
|
2864
2895
|
name: 'CHATBOT',
|
|
2865
2896
|
aliasNames: ['CHAT'],
|
|
2866
|
-
description:
|
|
2897
|
+
description: `A chatbot form factor for conversational user interfaces.`,
|
|
2867
2898
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/174`,
|
|
2868
2899
|
pipelineInterface: {
|
|
2869
2900
|
inputParameters: [
|
|
@@ -2890,7 +2921,45 @@ const ChatbotFormfactorDefinition = {
|
|
|
2890
2921
|
};
|
|
2891
2922
|
|
|
2892
2923
|
/**
|
|
2893
|
-
*
|
|
2924
|
+
* Completion is formfactor that emulates completion models
|
|
2925
|
+
*
|
|
2926
|
+
* @public exported from `@promptbook/core`
|
|
2927
|
+
*/
|
|
2928
|
+
const CompletionFormfactorDefinition = {
|
|
2929
|
+
name: 'COMPLETION',
|
|
2930
|
+
description: `Completion is formfactor that emulates completion models`,
|
|
2931
|
+
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/@@`,
|
|
2932
|
+
// <- TODO: https://github.com/webgptorg/promptbook/discussions/new?category=concepts
|
|
2933
|
+
// "🔠 Completion Formfactor"
|
|
2934
|
+
pipelineInterface: {
|
|
2935
|
+
inputParameters: [
|
|
2936
|
+
{
|
|
2937
|
+
name: 'inputText',
|
|
2938
|
+
description: `Input text to be completed`,
|
|
2939
|
+
isInput: true,
|
|
2940
|
+
isOutput: false,
|
|
2941
|
+
},
|
|
2942
|
+
{
|
|
2943
|
+
name: 'instructions',
|
|
2944
|
+
description: `Additional instructions for the model, for example the required length, empty by default`,
|
|
2945
|
+
isInput: true,
|
|
2946
|
+
isOutput: false,
|
|
2947
|
+
},
|
|
2948
|
+
],
|
|
2949
|
+
outputParameters: [
|
|
2950
|
+
{
|
|
2951
|
+
name: 'followingText',
|
|
2952
|
+
description: `Text that follows the input text`,
|
|
2953
|
+
isInput: false,
|
|
2954
|
+
isOutput: true,
|
|
2955
|
+
},
|
|
2956
|
+
],
|
|
2957
|
+
},
|
|
2958
|
+
};
|
|
2959
|
+
|
|
2960
|
+
/**
|
|
2961
|
+
* Generator form factor represents an application that generates content or data based on user input or predefined rules.
|
|
2962
|
+
* This form factor is used for apps that produce outputs, such as text, images, or other media, based on provided input.
|
|
2894
2963
|
*
|
|
2895
2964
|
* @public exported from `@promptbook/core`
|
|
2896
2965
|
*/
|
|
@@ -2919,7 +2988,7 @@ const GeneratorFormfactorDefinition = {
|
|
|
2919
2988
|
};
|
|
2920
2989
|
|
|
2921
2990
|
/**
|
|
2922
|
-
*
|
|
2991
|
+
* Pipeline interface which is equivalent to `any`
|
|
2923
2992
|
*
|
|
2924
2993
|
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
2925
2994
|
*
|
|
@@ -2934,13 +3003,13 @@ const GENERIC_PIPELINE_INTERFACE = {
|
|
|
2934
3003
|
*/
|
|
2935
3004
|
|
|
2936
3005
|
/**
|
|
2937
|
-
*
|
|
3006
|
+
* A generic pipeline
|
|
2938
3007
|
*
|
|
2939
3008
|
* @public exported from `@promptbook/core`
|
|
2940
3009
|
*/
|
|
2941
3010
|
const GenericFormfactorDefinition = {
|
|
2942
3011
|
name: 'GENERIC',
|
|
2943
|
-
description:
|
|
3012
|
+
description: `A generic pipeline`,
|
|
2944
3013
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/173`,
|
|
2945
3014
|
pipelineInterface: GENERIC_PIPELINE_INTERFACE,
|
|
2946
3015
|
};
|
|
@@ -2975,17 +3044,20 @@ const ImageGeneratorFormfactorDefinition = {
|
|
|
2975
3044
|
};
|
|
2976
3045
|
|
|
2977
3046
|
/**
|
|
2978
|
-
* Matcher is form of app that
|
|
3047
|
+
* Matcher is form of app that evaluates (spreadsheet) content against defined criteria or patterns,
|
|
3048
|
+
* determining if it matches or meets specific requirements. Used for classification,
|
|
3049
|
+
* validation, filtering, and quality assessment of inputs.
|
|
2979
3050
|
*
|
|
2980
3051
|
* @public exported from `@promptbook/core`
|
|
2981
3052
|
*/
|
|
2982
3053
|
const MatcherFormfactorDefinition = {
|
|
2983
3054
|
name: 'EXPERIMENTAL_MATCHER',
|
|
2984
|
-
description:
|
|
3055
|
+
description: `An evaluation system that determines whether content meets specific criteria or patterns.
|
|
3056
|
+
Used for content validation, quality assessment, and intelligent filtering tasks. Currently in experimental phase.`,
|
|
2985
3057
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/177`,
|
|
2986
3058
|
pipelineInterface: {
|
|
2987
3059
|
inputParameters: [
|
|
2988
|
-
/*
|
|
3060
|
+
/* Input parameters for content to be matched and criteria to match against */
|
|
2989
3061
|
{
|
|
2990
3062
|
name: 'nonce',
|
|
2991
3063
|
description: 'Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor',
|
|
@@ -2994,20 +3066,21 @@ const MatcherFormfactorDefinition = {
|
|
|
2994
3066
|
},
|
|
2995
3067
|
],
|
|
2996
3068
|
outputParameters: [
|
|
2997
|
-
/*
|
|
3069
|
+
/* Output parameters containing match results, confidence scores, and relevant metadata */
|
|
2998
3070
|
],
|
|
2999
3071
|
},
|
|
3000
3072
|
};
|
|
3001
3073
|
|
|
3002
3074
|
/**
|
|
3003
|
-
* Sheets is form of app that
|
|
3075
|
+
* Sheets is form of app that processes tabular data in CSV format, allowing transformation
|
|
3076
|
+
* and analysis of structured data through AI-powered operations
|
|
3004
3077
|
*
|
|
3005
3078
|
* @public exported from `@promptbook/core`
|
|
3006
3079
|
*/
|
|
3007
3080
|
const SheetsFormfactorDefinition = {
|
|
3008
3081
|
name: 'SHEETS',
|
|
3009
3082
|
aliasNames: ['SHEETS', 'SHEET'],
|
|
3010
|
-
description:
|
|
3083
|
+
description: `A formfactor for processing spreadsheet-like data in CSV format, enabling AI transformations on tabular data`,
|
|
3011
3084
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/176`,
|
|
3012
3085
|
pipelineInterface: {
|
|
3013
3086
|
inputParameters: [
|
|
@@ -3030,13 +3103,16 @@ const SheetsFormfactorDefinition = {
|
|
|
3030
3103
|
};
|
|
3031
3104
|
|
|
3032
3105
|
/**
|
|
3033
|
-
* Translator is form of app that
|
|
3106
|
+
* Translator is form of app that transforms input text from one form to another,
|
|
3107
|
+
* such as language translation, style conversion, tone modification, or other text transformations.
|
|
3034
3108
|
*
|
|
3035
3109
|
* @public exported from `@promptbook/core`
|
|
3036
3110
|
*/
|
|
3037
3111
|
const TranslatorFormfactorDefinition = {
|
|
3038
3112
|
name: 'TRANSLATOR',
|
|
3039
|
-
description:
|
|
3113
|
+
description: `A text transformation system that converts input content into different forms,
|
|
3114
|
+
including language translations, paraphrasing, style conversions, and tone adjustments.
|
|
3115
|
+
This form factor takes one input and produces one transformed output.`,
|
|
3040
3116
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/175`,
|
|
3041
3117
|
pipelineInterface: {
|
|
3042
3118
|
inputParameters: [
|
|
@@ -3073,6 +3149,8 @@ const FORMFACTOR_DEFINITIONS = [
|
|
|
3073
3149
|
MatcherFormfactorDefinition,
|
|
3074
3150
|
GeneratorFormfactorDefinition,
|
|
3075
3151
|
ImageGeneratorFormfactorDefinition,
|
|
3152
|
+
CompletionFormfactorDefinition,
|
|
3153
|
+
// <- [🛬] When making new formfactor, copy the _boilerplate and link it here
|
|
3076
3154
|
];
|
|
3077
3155
|
/**
|
|
3078
3156
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -3081,7 +3159,7 @@ const FORMFACTOR_DEFINITIONS = [
|
|
|
3081
3159
|
/**
|
|
3082
3160
|
* Parses the formfactor command
|
|
3083
3161
|
*
|
|
3084
|
-
* Note:
|
|
3162
|
+
* 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
|
|
3085
3163
|
*
|
|
3086
3164
|
* @see `documentationUrl` for more details
|
|
3087
3165
|
* @public exported from `@promptbook/editable`
|
|
@@ -3103,7 +3181,7 @@ const formfactorCommandParser = {
|
|
|
3103
3181
|
/**
|
|
3104
3182
|
* Description of the FORMFACTOR command
|
|
3105
3183
|
*/
|
|
3106
|
-
description:
|
|
3184
|
+
description: `Specifies the application type and interface requirements that this promptbook should conform to`,
|
|
3107
3185
|
/**
|
|
3108
3186
|
* Link to documentation
|
|
3109
3187
|
*/
|
|
@@ -3246,8 +3324,7 @@ const jokerCommandParser = {
|
|
|
3246
3324
|
};
|
|
3247
3325
|
|
|
3248
3326
|
/**
|
|
3249
|
-
*
|
|
3250
|
-
*
|
|
3327
|
+
* @see {@link ModelVariant}
|
|
3251
3328
|
* @public exported from `@promptbook/core`
|
|
3252
3329
|
*/
|
|
3253
3330
|
const MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
|
|
@@ -3679,10 +3756,10 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
3679
3756
|
}
|
|
3680
3757
|
|
|
3681
3758
|
/**
|
|
3682
|
-
*
|
|
3759
|
+
* Checks if the given value is a valid JavaScript identifier name.
|
|
3683
3760
|
*
|
|
3684
|
-
* @param javascriptName
|
|
3685
|
-
* @returns
|
|
3761
|
+
* @param javascriptName The value to check for JavaScript identifier validity.
|
|
3762
|
+
* @returns `true` if the value is a valid JavaScript name, false otherwise.
|
|
3686
3763
|
* @public exported from `@promptbook/utils`
|
|
3687
3764
|
*/
|
|
3688
3765
|
function isValidJavascriptName(javascriptName) {
|
|
@@ -4194,7 +4271,10 @@ function parseCommand(raw, usagePlace) {
|
|
|
4194
4271
|
`));
|
|
4195
4272
|
}
|
|
4196
4273
|
/**
|
|
4197
|
-
*
|
|
4274
|
+
* Generates a markdown-formatted message listing all supported commands
|
|
4275
|
+
* with their descriptions and documentation links
|
|
4276
|
+
*
|
|
4277
|
+
* @returns A formatted markdown string containing all available commands and their details
|
|
4198
4278
|
*/
|
|
4199
4279
|
function getSupportedCommandsMessage() {
|
|
4200
4280
|
return COMMANDS.flatMap(({ name, aliasNames, description, documentationUrl }) =>
|
|
@@ -4205,7 +4285,10 @@ function getSupportedCommandsMessage() {
|
|
|
4205
4285
|
]).join('\n');
|
|
4206
4286
|
}
|
|
4207
4287
|
/**
|
|
4208
|
-
*
|
|
4288
|
+
* Attempts to parse a command variant using the provided input parameters
|
|
4289
|
+
*
|
|
4290
|
+
* @param input Object containing command parsing information including raw command text and normalized values
|
|
4291
|
+
* @returns A parsed Command object if successful, or null if the command cannot be parsed
|
|
4209
4292
|
*/
|
|
4210
4293
|
function parseCommandVariant(input) {
|
|
4211
4294
|
const { commandNameRaw, usagePlace, normalized, args, raw, rawArgs } = input;
|
|
@@ -4252,7 +4335,7 @@ function parseCommandVariant(input) {
|
|
|
4252
4335
|
}
|
|
4253
4336
|
|
|
4254
4337
|
/**
|
|
4255
|
-
*
|
|
4338
|
+
* Extracts the interface (input and output parameters) from a pipeline.
|
|
4256
4339
|
*
|
|
4257
4340
|
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
4258
4341
|
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
@@ -4285,7 +4368,7 @@ function getPipelineInterface(pipeline) {
|
|
|
4285
4368
|
}
|
|
4286
4369
|
|
|
4287
4370
|
/**
|
|
4288
|
-
*
|
|
4371
|
+
* Checks if two pipeline interfaces are structurally identical.
|
|
4289
4372
|
*
|
|
4290
4373
|
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
4291
4374
|
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
@@ -4317,10 +4400,11 @@ function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
|
|
|
4317
4400
|
}
|
|
4318
4401
|
|
|
4319
4402
|
/**
|
|
4320
|
-
*
|
|
4403
|
+
* Checks if a given pipeline satisfies the requirements of a specified pipeline interface.
|
|
4321
4404
|
*
|
|
4322
4405
|
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
4323
4406
|
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
4407
|
+
* @returns `true` if the pipeline implements the interface, `false` otherwise.
|
|
4324
4408
|
*
|
|
4325
4409
|
* @public exported from `@promptbook/core`
|
|
4326
4410
|
*/
|
|
@@ -4550,7 +4634,8 @@ function removeMarkdownComments(content) {
|
|
|
4550
4634
|
}
|
|
4551
4635
|
|
|
4552
4636
|
/**
|
|
4553
|
-
*
|
|
4637
|
+
* Utility to determine if a pipeline string is in flat format.
|
|
4638
|
+
* A flat pipeline is a simple text without proper structure (headers, blocks, etc).
|
|
4554
4639
|
*
|
|
4555
4640
|
* @public exported from `@promptbook/editable`
|
|
4556
4641
|
*/
|
|
@@ -4571,7 +4656,10 @@ function isFlatPipeline(pipelineString) {
|
|
|
4571
4656
|
}
|
|
4572
4657
|
|
|
4573
4658
|
/**
|
|
4574
|
-
*
|
|
4659
|
+
* Converts a pipeline structure to its string representation.
|
|
4660
|
+
*
|
|
4661
|
+
* Transforms a flat, simple pipeline into a properly formatted pipeline string
|
|
4662
|
+
* with sections for title, prompt, and return statement.
|
|
4575
4663
|
*
|
|
4576
4664
|
* @public exported from `@promptbook/editable`
|
|
4577
4665
|
*/
|
|
@@ -4628,7 +4716,7 @@ function deflatePipeline(pipelineString) {
|
|
|
4628
4716
|
* Note: It can not work with html syntax and comments
|
|
4629
4717
|
*
|
|
4630
4718
|
* @param markdown any valid markdown
|
|
4631
|
-
* @returns
|
|
4719
|
+
* @returns An array of strings, each representing an individual list item found in the markdown
|
|
4632
4720
|
* @public exported from `@promptbook/markdown-utils`
|
|
4633
4721
|
*/
|
|
4634
4722
|
function extractAllListItemsFromMarkdown(markdown) {
|
|
@@ -4881,11 +4969,11 @@ function flattenMarkdown(markdown) {
|
|
|
4881
4969
|
*/
|
|
4882
4970
|
|
|
4883
4971
|
/**
|
|
4884
|
-
*
|
|
4972
|
+
* Converts a title string into a normalized name.
|
|
4885
4973
|
*
|
|
4886
|
-
* @param value
|
|
4887
|
-
* @returns
|
|
4888
|
-
* @example
|
|
4974
|
+
* @param value The title string to be converted to a name.
|
|
4975
|
+
* @returns A normalized name derived from the input title.
|
|
4976
|
+
* @example 'Hello World!' -> 'hello-world'
|
|
4889
4977
|
* @public exported from `@promptbook/utils`
|
|
4890
4978
|
*/
|
|
4891
4979
|
function titleToName(value) {
|