@promptbook/remote-client 0.92.0-3 → 0.92.0-30
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/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 +12 -9
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +11 -8
- 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/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-30';
|
|
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
|
|
@@ -364,7 +364,7 @@
|
|
|
364
364
|
const CONNECTION_RETRIES_LIMIT = 5;
|
|
365
365
|
// <- TODO: [🧜♂️]
|
|
366
366
|
/**
|
|
367
|
-
*
|
|
367
|
+
* Default settings for parsing and generating CSV files in Promptbook.
|
|
368
368
|
*
|
|
369
369
|
* @public exported from `@promptbook/core`
|
|
370
370
|
*/
|
|
@@ -996,10 +996,10 @@
|
|
|
996
996
|
*/
|
|
997
997
|
|
|
998
998
|
/**
|
|
999
|
-
*
|
|
999
|
+
* Removes diacritic marks (accents) from characters in a string.
|
|
1000
1000
|
*
|
|
1001
|
-
* @param input
|
|
1002
|
-
* @returns
|
|
1001
|
+
* @param input The string containing diacritics to be normalized.
|
|
1002
|
+
* @returns The string with diacritics removed or normalized.
|
|
1003
1003
|
* @public exported from `@promptbook/utils`
|
|
1004
1004
|
*/
|
|
1005
1005
|
function removeDiacritics(input) {
|
|
@@ -1013,10 +1013,10 @@
|
|
|
1013
1013
|
*/
|
|
1014
1014
|
|
|
1015
1015
|
/**
|
|
1016
|
-
*
|
|
1016
|
+
* Converts a given text to kebab-case format.
|
|
1017
1017
|
*
|
|
1018
|
-
* @param text
|
|
1019
|
-
* @returns
|
|
1018
|
+
* @param text The text to be converted.
|
|
1019
|
+
* @returns The kebab-case formatted string.
|
|
1020
1020
|
* @example 'hello-world'
|
|
1021
1021
|
* @example 'i-love-promptbook'
|
|
1022
1022
|
* @public exported from `@promptbook/utils`
|
|
@@ -1370,7 +1370,7 @@
|
|
|
1370
1370
|
/**
|
|
1371
1371
|
* Parses the boilerplate command
|
|
1372
1372
|
*
|
|
1373
|
-
* Note:
|
|
1373
|
+
* Note: @@ This command is used as boilerplate for new commands - it should NOT be used in any `.book` file
|
|
1374
1374
|
*
|
|
1375
1375
|
* @see `documentationUrl` for more details
|
|
1376
1376
|
* @private within the commands folder
|
|
@@ -1828,7 +1828,7 @@
|
|
|
1828
1828
|
};
|
|
1829
1829
|
|
|
1830
1830
|
/**
|
|
1831
|
-
*
|
|
1831
|
+
* Contains configuration options for parsing and generating CSV files, such as delimiters and quoting rules.
|
|
1832
1832
|
*
|
|
1833
1833
|
* @public exported from `@promptbook/core`
|
|
1834
1834
|
*/
|
|
@@ -1837,11 +1837,29 @@
|
|
|
1837
1837
|
// encoding: 'utf-8',
|
|
1838
1838
|
});
|
|
1839
1839
|
|
|
1840
|
+
/**
|
|
1841
|
+
* Converts a CSV string into an object
|
|
1842
|
+
*
|
|
1843
|
+
* Note: This is wrapper around `papaparse.parse()` with better autohealing
|
|
1844
|
+
*
|
|
1845
|
+
* @private - for now until `@promptbook/csv` is released
|
|
1846
|
+
*/
|
|
1847
|
+
function csvParse(value /* <- TODO: string_csv */, settings, schema /* <- TODO: Make CSV Schemas */) {
|
|
1848
|
+
settings = { ...settings, ...MANDATORY_CSV_SETTINGS };
|
|
1849
|
+
// Note: Autoheal invalid '\n' characters
|
|
1850
|
+
if (settings.newline && !settings.newline.includes('\r') && value.includes('\r')) {
|
|
1851
|
+
console.warn('CSV string contains carriage return characters, but in the CSV settings the `newline` setting does not include them. Autohealing the CSV string.');
|
|
1852
|
+
value = value.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
1853
|
+
}
|
|
1854
|
+
const csv = papaparse.parse(value, settings);
|
|
1855
|
+
return csv;
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1840
1858
|
/**
|
|
1841
1859
|
* Function to check if a string is valid CSV
|
|
1842
1860
|
*
|
|
1843
1861
|
* @param value The string to check
|
|
1844
|
-
* @returns
|
|
1862
|
+
* @returns `true` if the string is a valid CSV string, false otherwise
|
|
1845
1863
|
*
|
|
1846
1864
|
* @public exported from `@promptbook/utils`
|
|
1847
1865
|
*/
|
|
@@ -1865,7 +1883,7 @@
|
|
|
1865
1883
|
* @public exported from `@promptbook/core`
|
|
1866
1884
|
* <- TODO: [🏢] Export from package `@promptbook/csv`
|
|
1867
1885
|
*/
|
|
1868
|
-
const
|
|
1886
|
+
const CsvFormatParser = {
|
|
1869
1887
|
formatName: 'CSV',
|
|
1870
1888
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
1871
1889
|
isValid(value, settings, schema) {
|
|
@@ -1877,12 +1895,12 @@
|
|
|
1877
1895
|
heal(value, settings, schema) {
|
|
1878
1896
|
throw new Error('Not implemented');
|
|
1879
1897
|
},
|
|
1880
|
-
|
|
1898
|
+
subvalueParsers: [
|
|
1881
1899
|
{
|
|
1882
1900
|
subvalueName: 'ROW',
|
|
1883
|
-
async mapValues(
|
|
1884
|
-
|
|
1885
|
-
const csv =
|
|
1901
|
+
async mapValues(options) {
|
|
1902
|
+
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
1903
|
+
const csv = csvParse(value, settings);
|
|
1886
1904
|
if (csv.errors.length !== 0) {
|
|
1887
1905
|
throw new CsvFormatError(spaceTrim__default["default"]((block) => `
|
|
1888
1906
|
CSV parsing error
|
|
@@ -1897,23 +1915,37 @@
|
|
|
1897
1915
|
${block(value)}
|
|
1898
1916
|
`));
|
|
1899
1917
|
}
|
|
1900
|
-
const mappedData =
|
|
1918
|
+
const mappedData = [];
|
|
1919
|
+
const length = csv.data.length;
|
|
1920
|
+
for (let index = 0; index < length; index++) {
|
|
1921
|
+
const row = csv.data[index];
|
|
1901
1922
|
if (row[outputParameterName]) {
|
|
1902
1923
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
1903
1924
|
}
|
|
1904
|
-
|
|
1925
|
+
const mappedRow = {
|
|
1905
1926
|
...row,
|
|
1906
|
-
[outputParameterName]: await mapCallback(row, index),
|
|
1927
|
+
[outputParameterName]: await mapCallback(row, index, length),
|
|
1907
1928
|
};
|
|
1908
|
-
|
|
1929
|
+
mappedData.push(mappedRow);
|
|
1930
|
+
if (onProgress) {
|
|
1931
|
+
// Note: Report the CSV with all rows mapped so far
|
|
1932
|
+
/*
|
|
1933
|
+
// TODO: [🛕] Report progress with all the rows including the pending ones
|
|
1934
|
+
const progressData = mappedData.map((row, i) =>
|
|
1935
|
+
i > index ? { ...row, [outputParameterName]: PENDING_VALUE_PLACEHOLDER } : row,
|
|
1936
|
+
);
|
|
1937
|
+
*/
|
|
1938
|
+
await onProgress(papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1909
1941
|
return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
1910
1942
|
},
|
|
1911
1943
|
},
|
|
1912
1944
|
{
|
|
1913
1945
|
subvalueName: 'CELL',
|
|
1914
|
-
async mapValues(
|
|
1915
|
-
|
|
1916
|
-
const csv =
|
|
1946
|
+
async mapValues(options) {
|
|
1947
|
+
const { value, settings, mapCallback, onProgress } = options;
|
|
1948
|
+
const csv = csvParse(value, settings);
|
|
1917
1949
|
if (csv.errors.length !== 0) {
|
|
1918
1950
|
throw new CsvFormatError(spaceTrim__default["default"]((block) => `
|
|
1919
1951
|
CSV parsing error
|
|
@@ -1929,9 +1961,9 @@
|
|
|
1929
1961
|
`));
|
|
1930
1962
|
}
|
|
1931
1963
|
const mappedData = await Promise.all(csv.data.map(async (row, rowIndex) => {
|
|
1932
|
-
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex) => {
|
|
1964
|
+
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex, array) => {
|
|
1933
1965
|
const index = rowIndex * Object.keys(row).length + columnIndex;
|
|
1934
|
-
return /* not await */ mapCallback({ [key]: value }, index);
|
|
1966
|
+
return /* not await */ mapCallback({ [key]: value }, index, array.length);
|
|
1935
1967
|
}));
|
|
1936
1968
|
}));
|
|
1937
1969
|
return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
@@ -1940,10 +1972,10 @@
|
|
|
1940
1972
|
],
|
|
1941
1973
|
};
|
|
1942
1974
|
/**
|
|
1943
|
-
* TODO: [🍓] In `
|
|
1944
|
-
* TODO: [🍓] In `
|
|
1945
|
-
* TODO: [🍓] In `
|
|
1946
|
-
* TODO: [🍓] In `
|
|
1975
|
+
* TODO: [🍓] In `CsvFormatParser` implement simple `isValid`
|
|
1976
|
+
* TODO: [🍓] In `CsvFormatParser` implement partial `canBeValid`
|
|
1977
|
+
* TODO: [🍓] In `CsvFormatParser` implement `heal
|
|
1978
|
+
* TODO: [🍓] In `CsvFormatParser` implement `subvalueParsers`
|
|
1947
1979
|
* TODO: [🏢] Allow to expect something inside CSV objects and other formats
|
|
1948
1980
|
*/
|
|
1949
1981
|
|
|
@@ -1951,7 +1983,7 @@
|
|
|
1951
1983
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
1952
1984
|
*
|
|
1953
1985
|
* @param value The string to check
|
|
1954
|
-
* @returns
|
|
1986
|
+
* @returns `true` if the string is a valid JSON string, false otherwise
|
|
1955
1987
|
*
|
|
1956
1988
|
* @public exported from `@promptbook/utils`
|
|
1957
1989
|
*/
|
|
@@ -1974,7 +2006,7 @@
|
|
|
1974
2006
|
*
|
|
1975
2007
|
* @private still in development [🏢]
|
|
1976
2008
|
*/
|
|
1977
|
-
const
|
|
2009
|
+
const JsonFormatParser = {
|
|
1978
2010
|
formatName: 'JSON',
|
|
1979
2011
|
mimeType: 'application/json',
|
|
1980
2012
|
isValid(value, settings, schema) {
|
|
@@ -1986,28 +2018,28 @@
|
|
|
1986
2018
|
heal(value, settings, schema) {
|
|
1987
2019
|
throw new Error('Not implemented');
|
|
1988
2020
|
},
|
|
1989
|
-
|
|
2021
|
+
subvalueParsers: [],
|
|
1990
2022
|
};
|
|
1991
2023
|
/**
|
|
1992
2024
|
* TODO: [🧠] Maybe propper instance of object
|
|
1993
2025
|
* TODO: [0] Make string_serialized_json
|
|
1994
2026
|
* TODO: [1] Make type for JSON Settings and Schema
|
|
1995
2027
|
* TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
|
|
1996
|
-
* TODO: [🍓] In `
|
|
1997
|
-
* TODO: [🍓] In `
|
|
1998
|
-
* TODO: [🍓] In `
|
|
1999
|
-
* TODO: [🍓] In `
|
|
2028
|
+
* TODO: [🍓] In `JsonFormatParser` implement simple `isValid`
|
|
2029
|
+
* TODO: [🍓] In `JsonFormatParser` implement partial `canBeValid`
|
|
2030
|
+
* TODO: [🍓] In `JsonFormatParser` implement `heal
|
|
2031
|
+
* TODO: [🍓] In `JsonFormatParser` implement `subvalueParsers`
|
|
2000
2032
|
* TODO: [🏢] Allow to expect something inside JSON objects and other formats
|
|
2001
2033
|
*/
|
|
2002
2034
|
|
|
2003
2035
|
/**
|
|
2004
2036
|
* Definition for any text - this will be always valid
|
|
2005
2037
|
*
|
|
2006
|
-
* Note: This is not useful for validation, but for splitting and mapping with `
|
|
2038
|
+
* Note: This is not useful for validation, but for splitting and mapping with `subvalueParsers`
|
|
2007
2039
|
*
|
|
2008
2040
|
* @public exported from `@promptbook/core`
|
|
2009
2041
|
*/
|
|
2010
|
-
const
|
|
2042
|
+
const TextFormatParser = {
|
|
2011
2043
|
formatName: 'TEXT',
|
|
2012
2044
|
isValid(value) {
|
|
2013
2045
|
return typeof value === 'string';
|
|
@@ -2016,19 +2048,20 @@
|
|
|
2016
2048
|
return typeof partialValue === 'string';
|
|
2017
2049
|
},
|
|
2018
2050
|
heal() {
|
|
2019
|
-
throw new UnexpectedError('It does not make sense to call `
|
|
2051
|
+
throw new UnexpectedError('It does not make sense to call `TextFormatParser.heal`');
|
|
2020
2052
|
},
|
|
2021
|
-
|
|
2053
|
+
subvalueParsers: [
|
|
2022
2054
|
{
|
|
2023
2055
|
subvalueName: 'LINE',
|
|
2024
|
-
async mapValues(
|
|
2056
|
+
async mapValues(options) {
|
|
2057
|
+
const { value, mapCallback, onProgress } = options;
|
|
2025
2058
|
const lines = value.split('\n');
|
|
2026
|
-
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
2059
|
+
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
|
|
2027
2060
|
// TODO: [🧠] Maybe option to skip empty line
|
|
2028
2061
|
/* not await */ mapCallback({
|
|
2029
2062
|
lineContent,
|
|
2030
2063
|
// TODO: [🧠] Maybe also put here `lineNumber`
|
|
2031
|
-
}, lineNumber)));
|
|
2064
|
+
}, lineNumber, array.length)));
|
|
2032
2065
|
return mappedLines.join('\n');
|
|
2033
2066
|
},
|
|
2034
2067
|
},
|
|
@@ -2038,10 +2071,10 @@
|
|
|
2038
2071
|
/**
|
|
2039
2072
|
* TODO: [1] Make type for XML Text and Schema
|
|
2040
2073
|
* TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages available as subvalues
|
|
2041
|
-
* TODO: [🍓] In `
|
|
2042
|
-
* TODO: [🍓] In `
|
|
2043
|
-
* TODO: [🍓] In `
|
|
2044
|
-
* TODO: [🍓] In `
|
|
2074
|
+
* TODO: [🍓] In `TextFormatParser` implement simple `isValid`
|
|
2075
|
+
* TODO: [🍓] In `TextFormatParser` implement partial `canBeValid`
|
|
2076
|
+
* TODO: [🍓] In `TextFormatParser` implement `heal
|
|
2077
|
+
* TODO: [🍓] In `TextFormatParser` implement `subvalueParsers`
|
|
2045
2078
|
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
2046
2079
|
*/
|
|
2047
2080
|
|
|
@@ -2049,7 +2082,7 @@
|
|
|
2049
2082
|
* Function to check if a string is valid XML
|
|
2050
2083
|
*
|
|
2051
2084
|
* @param value
|
|
2052
|
-
* @returns
|
|
2085
|
+
* @returns `true` if the string is a valid XML string, false otherwise
|
|
2053
2086
|
*
|
|
2054
2087
|
* @public exported from `@promptbook/utils`
|
|
2055
2088
|
*/
|
|
@@ -2074,7 +2107,7 @@
|
|
|
2074
2107
|
*
|
|
2075
2108
|
* @private still in development [🏢]
|
|
2076
2109
|
*/
|
|
2077
|
-
const
|
|
2110
|
+
const XmlFormatParser = {
|
|
2078
2111
|
formatName: 'XML',
|
|
2079
2112
|
mimeType: 'application/xml',
|
|
2080
2113
|
isValid(value, settings, schema) {
|
|
@@ -2086,17 +2119,17 @@
|
|
|
2086
2119
|
heal(value, settings, schema) {
|
|
2087
2120
|
throw new Error('Not implemented');
|
|
2088
2121
|
},
|
|
2089
|
-
|
|
2122
|
+
subvalueParsers: [],
|
|
2090
2123
|
};
|
|
2091
2124
|
/**
|
|
2092
2125
|
* TODO: [🧠] Maybe propper instance of object
|
|
2093
2126
|
* TODO: [0] Make string_serialized_xml
|
|
2094
2127
|
* TODO: [1] Make type for XML Settings and Schema
|
|
2095
2128
|
* TODO: [🧠] What to use for validating XMLs - XSD,...
|
|
2096
|
-
* TODO: [🍓] In `
|
|
2097
|
-
* TODO: [🍓] In `
|
|
2098
|
-
* TODO: [🍓] In `
|
|
2099
|
-
* TODO: [🍓] In `
|
|
2129
|
+
* TODO: [🍓] In `XmlFormatParser` implement simple `isValid`
|
|
2130
|
+
* TODO: [🍓] In `XmlFormatParser` implement partial `canBeValid`
|
|
2131
|
+
* TODO: [🍓] In `XmlFormatParser` implement `heal
|
|
2132
|
+
* TODO: [🍓] In `XmlFormatParser` implement `subvalueParsers`
|
|
2100
2133
|
* TODO: [🏢] Allow to expect something inside XML and other formats
|
|
2101
2134
|
*/
|
|
2102
2135
|
|
|
@@ -2105,21 +2138,16 @@
|
|
|
2105
2138
|
*
|
|
2106
2139
|
* @private internal index of `...` <- TODO [🏢]
|
|
2107
2140
|
*/
|
|
2108
|
-
const FORMAT_DEFINITIONS = [
|
|
2109
|
-
JsonFormatDefinition,
|
|
2110
|
-
XmlFormatDefinition,
|
|
2111
|
-
TextFormatDefinition,
|
|
2112
|
-
CsvFormatDefinition,
|
|
2113
|
-
];
|
|
2141
|
+
const FORMAT_DEFINITIONS = [JsonFormatParser, XmlFormatParser, TextFormatParser, CsvFormatParser];
|
|
2114
2142
|
/**
|
|
2115
2143
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2116
2144
|
*/
|
|
2117
2145
|
|
|
2118
2146
|
/**
|
|
2119
|
-
*
|
|
2147
|
+
* Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
|
|
2120
2148
|
*
|
|
2121
|
-
* @param text
|
|
2122
|
-
* @returns
|
|
2149
|
+
* @param text The text string to be converted to SCREAMING_CASE format.
|
|
2150
|
+
* @returns The normalized text in SCREAMING_CASE format.
|
|
2123
2151
|
* @example 'HELLO_WORLD'
|
|
2124
2152
|
* @example 'I_LOVE_PROMPTBOOK'
|
|
2125
2153
|
* @public exported from `@promptbook/utils`
|
|
@@ -2351,8 +2379,12 @@
|
|
|
2351
2379
|
*/
|
|
2352
2380
|
|
|
2353
2381
|
/**
|
|
2354
|
-
*
|
|
2382
|
+
* Creates a deep clone of the given object
|
|
2355
2383
|
*
|
|
2384
|
+
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
2385
|
+
*
|
|
2386
|
+
* @param objectValue The object to clone.
|
|
2387
|
+
* @returns A deep, writable clone of the input object.
|
|
2356
2388
|
* @public exported from `@promptbook/utils`
|
|
2357
2389
|
*/
|
|
2358
2390
|
function deepClone(objectValue) {
|
|
@@ -2452,11 +2484,11 @@
|
|
|
2452
2484
|
*/
|
|
2453
2485
|
|
|
2454
2486
|
/**
|
|
2455
|
-
*
|
|
2487
|
+
* Normalizes a given text to camelCase format.
|
|
2456
2488
|
*
|
|
2457
|
-
* @param text
|
|
2458
|
-
* @param _isFirstLetterCapital
|
|
2459
|
-
* @returns
|
|
2489
|
+
* @param text The text to be normalized.
|
|
2490
|
+
* @param _isFirstLetterCapital Whether the first letter should be capitalized.
|
|
2491
|
+
* @returns The camelCase formatted string.
|
|
2460
2492
|
* @example 'helloWorld'
|
|
2461
2493
|
* @example 'iLovePromptbook'
|
|
2462
2494
|
* @public exported from `@promptbook/utils`
|
|
@@ -2543,11 +2575,12 @@
|
|
|
2543
2575
|
}
|
|
2544
2576
|
|
|
2545
2577
|
/**
|
|
2546
|
-
* Function `validateParameterName` will
|
|
2578
|
+
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
2579
|
+
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
2547
2580
|
*
|
|
2548
|
-
* @param parameterName
|
|
2549
|
-
* @returns
|
|
2550
|
-
* @throws {ParseError}
|
|
2581
|
+
* @param parameterName The parameter name to validate and normalize.
|
|
2582
|
+
* @returns The validated and normalized parameter name.
|
|
2583
|
+
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
2551
2584
|
* @private within the repository
|
|
2552
2585
|
*/
|
|
2553
2586
|
function validateParameterName(parameterName) {
|
|
@@ -2617,8 +2650,6 @@
|
|
|
2617
2650
|
/**
|
|
2618
2651
|
* Parses the foreach command
|
|
2619
2652
|
*
|
|
2620
|
-
* Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book` file
|
|
2621
|
-
*
|
|
2622
2653
|
* @see `documentationUrl` for more details
|
|
2623
2654
|
* @public exported from `@promptbook/editable`
|
|
2624
2655
|
*/
|
|
@@ -2675,14 +2706,14 @@
|
|
|
2675
2706
|
`));
|
|
2676
2707
|
// <- TODO: [🏢] List all supported format names
|
|
2677
2708
|
}
|
|
2678
|
-
const
|
|
2679
|
-
if (
|
|
2709
|
+
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
2710
|
+
if (subvalueParser === undefined) {
|
|
2680
2711
|
throw new ParseError(spaceTrim__default["default"]((block) => `
|
|
2681
2712
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
2682
2713
|
|
|
2683
2714
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
2684
|
-
${block(formatDefinition.
|
|
2685
|
-
.map((
|
|
2715
|
+
${block(formatDefinition.subvalueParsers
|
|
2716
|
+
.map((subvalueParser) => subvalueParser.subvalueName)
|
|
2686
2717
|
.map((subvalueName) => `- ${subvalueName}`)
|
|
2687
2718
|
.join('\n'))}
|
|
2688
2719
|
`));
|
|
@@ -2859,14 +2890,14 @@
|
|
|
2859
2890
|
};
|
|
2860
2891
|
|
|
2861
2892
|
/**
|
|
2862
|
-
*
|
|
2893
|
+
* Chatbot form factor definition for conversational interfaces that interact with users in a chat-like manner.
|
|
2863
2894
|
*
|
|
2864
2895
|
* @public exported from `@promptbook/core`
|
|
2865
2896
|
*/
|
|
2866
2897
|
const ChatbotFormfactorDefinition = {
|
|
2867
2898
|
name: 'CHATBOT',
|
|
2868
2899
|
aliasNames: ['CHAT'],
|
|
2869
|
-
description:
|
|
2900
|
+
description: `A chatbot form factor for conversational user interfaces.`,
|
|
2870
2901
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/174`,
|
|
2871
2902
|
pipelineInterface: {
|
|
2872
2903
|
inputParameters: [
|
|
@@ -2893,7 +2924,45 @@
|
|
|
2893
2924
|
};
|
|
2894
2925
|
|
|
2895
2926
|
/**
|
|
2896
|
-
*
|
|
2927
|
+
* Completion is formfactor that emulates completion models
|
|
2928
|
+
*
|
|
2929
|
+
* @public exported from `@promptbook/core`
|
|
2930
|
+
*/
|
|
2931
|
+
const CompletionFormfactorDefinition = {
|
|
2932
|
+
name: 'COMPLETION',
|
|
2933
|
+
description: `Completion is formfactor that emulates completion models`,
|
|
2934
|
+
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/@@`,
|
|
2935
|
+
// <- TODO: https://github.com/webgptorg/promptbook/discussions/new?category=concepts
|
|
2936
|
+
// "🔠 Completion Formfactor"
|
|
2937
|
+
pipelineInterface: {
|
|
2938
|
+
inputParameters: [
|
|
2939
|
+
{
|
|
2940
|
+
name: 'inputText',
|
|
2941
|
+
description: `Input text to be completed`,
|
|
2942
|
+
isInput: true,
|
|
2943
|
+
isOutput: false,
|
|
2944
|
+
},
|
|
2945
|
+
{
|
|
2946
|
+
name: 'instructions',
|
|
2947
|
+
description: `Additional instructions for the model, for example the required length, empty by default`,
|
|
2948
|
+
isInput: true,
|
|
2949
|
+
isOutput: false,
|
|
2950
|
+
},
|
|
2951
|
+
],
|
|
2952
|
+
outputParameters: [
|
|
2953
|
+
{
|
|
2954
|
+
name: 'followingText',
|
|
2955
|
+
description: `Text that follows the input text`,
|
|
2956
|
+
isInput: false,
|
|
2957
|
+
isOutput: true,
|
|
2958
|
+
},
|
|
2959
|
+
],
|
|
2960
|
+
},
|
|
2961
|
+
};
|
|
2962
|
+
|
|
2963
|
+
/**
|
|
2964
|
+
* Generator form factor represents an application that generates content or data based on user input or predefined rules.
|
|
2965
|
+
* This form factor is used for apps that produce outputs, such as text, images, or other media, based on provided input.
|
|
2897
2966
|
*
|
|
2898
2967
|
* @public exported from `@promptbook/core`
|
|
2899
2968
|
*/
|
|
@@ -2922,7 +2991,7 @@
|
|
|
2922
2991
|
};
|
|
2923
2992
|
|
|
2924
2993
|
/**
|
|
2925
|
-
*
|
|
2994
|
+
* Pipeline interface which is equivalent to `any`
|
|
2926
2995
|
*
|
|
2927
2996
|
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
2928
2997
|
*
|
|
@@ -2937,13 +3006,13 @@
|
|
|
2937
3006
|
*/
|
|
2938
3007
|
|
|
2939
3008
|
/**
|
|
2940
|
-
*
|
|
3009
|
+
* A generic pipeline
|
|
2941
3010
|
*
|
|
2942
3011
|
* @public exported from `@promptbook/core`
|
|
2943
3012
|
*/
|
|
2944
3013
|
const GenericFormfactorDefinition = {
|
|
2945
3014
|
name: 'GENERIC',
|
|
2946
|
-
description:
|
|
3015
|
+
description: `A generic pipeline`,
|
|
2947
3016
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/173`,
|
|
2948
3017
|
pipelineInterface: GENERIC_PIPELINE_INTERFACE,
|
|
2949
3018
|
};
|
|
@@ -2978,17 +3047,20 @@
|
|
|
2978
3047
|
};
|
|
2979
3048
|
|
|
2980
3049
|
/**
|
|
2981
|
-
* Matcher is form of app that
|
|
3050
|
+
* Matcher is form of app that evaluates (spreadsheet) content against defined criteria or patterns,
|
|
3051
|
+
* determining if it matches or meets specific requirements. Used for classification,
|
|
3052
|
+
* validation, filtering, and quality assessment of inputs.
|
|
2982
3053
|
*
|
|
2983
3054
|
* @public exported from `@promptbook/core`
|
|
2984
3055
|
*/
|
|
2985
3056
|
const MatcherFormfactorDefinition = {
|
|
2986
3057
|
name: 'EXPERIMENTAL_MATCHER',
|
|
2987
|
-
description:
|
|
3058
|
+
description: `An evaluation system that determines whether content meets specific criteria or patterns.
|
|
3059
|
+
Used for content validation, quality assessment, and intelligent filtering tasks. Currently in experimental phase.`,
|
|
2988
3060
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/177`,
|
|
2989
3061
|
pipelineInterface: {
|
|
2990
3062
|
inputParameters: [
|
|
2991
|
-
/*
|
|
3063
|
+
/* Input parameters for content to be matched and criteria to match against */
|
|
2992
3064
|
{
|
|
2993
3065
|
name: 'nonce',
|
|
2994
3066
|
description: 'Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor',
|
|
@@ -2997,20 +3069,21 @@
|
|
|
2997
3069
|
},
|
|
2998
3070
|
],
|
|
2999
3071
|
outputParameters: [
|
|
3000
|
-
/*
|
|
3072
|
+
/* Output parameters containing match results, confidence scores, and relevant metadata */
|
|
3001
3073
|
],
|
|
3002
3074
|
},
|
|
3003
3075
|
};
|
|
3004
3076
|
|
|
3005
3077
|
/**
|
|
3006
|
-
* Sheets is form of app that
|
|
3078
|
+
* Sheets is form of app that processes tabular data in CSV format, allowing transformation
|
|
3079
|
+
* and analysis of structured data through AI-powered operations
|
|
3007
3080
|
*
|
|
3008
3081
|
* @public exported from `@promptbook/core`
|
|
3009
3082
|
*/
|
|
3010
3083
|
const SheetsFormfactorDefinition = {
|
|
3011
3084
|
name: 'SHEETS',
|
|
3012
3085
|
aliasNames: ['SHEETS', 'SHEET'],
|
|
3013
|
-
description:
|
|
3086
|
+
description: `A formfactor for processing spreadsheet-like data in CSV format, enabling AI transformations on tabular data`,
|
|
3014
3087
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/176`,
|
|
3015
3088
|
pipelineInterface: {
|
|
3016
3089
|
inputParameters: [
|
|
@@ -3033,13 +3106,16 @@
|
|
|
3033
3106
|
};
|
|
3034
3107
|
|
|
3035
3108
|
/**
|
|
3036
|
-
* Translator is form of app that
|
|
3109
|
+
* Translator is form of app that transforms input text from one form to another,
|
|
3110
|
+
* such as language translation, style conversion, tone modification, or other text transformations.
|
|
3037
3111
|
*
|
|
3038
3112
|
* @public exported from `@promptbook/core`
|
|
3039
3113
|
*/
|
|
3040
3114
|
const TranslatorFormfactorDefinition = {
|
|
3041
3115
|
name: 'TRANSLATOR',
|
|
3042
|
-
description:
|
|
3116
|
+
description: `A text transformation system that converts input content into different forms,
|
|
3117
|
+
including language translations, paraphrasing, style conversions, and tone adjustments.
|
|
3118
|
+
This form factor takes one input and produces one transformed output.`,
|
|
3043
3119
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/175`,
|
|
3044
3120
|
pipelineInterface: {
|
|
3045
3121
|
inputParameters: [
|
|
@@ -3076,6 +3152,8 @@
|
|
|
3076
3152
|
MatcherFormfactorDefinition,
|
|
3077
3153
|
GeneratorFormfactorDefinition,
|
|
3078
3154
|
ImageGeneratorFormfactorDefinition,
|
|
3155
|
+
CompletionFormfactorDefinition,
|
|
3156
|
+
// <- [🛬] When making new formfactor, copy the _boilerplate and link it here
|
|
3079
3157
|
];
|
|
3080
3158
|
/**
|
|
3081
3159
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -3084,7 +3162,7 @@
|
|
|
3084
3162
|
/**
|
|
3085
3163
|
* Parses the formfactor command
|
|
3086
3164
|
*
|
|
3087
|
-
* Note:
|
|
3165
|
+
* 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
|
|
3088
3166
|
*
|
|
3089
3167
|
* @see `documentationUrl` for more details
|
|
3090
3168
|
* @public exported from `@promptbook/editable`
|
|
@@ -3106,7 +3184,7 @@
|
|
|
3106
3184
|
/**
|
|
3107
3185
|
* Description of the FORMFACTOR command
|
|
3108
3186
|
*/
|
|
3109
|
-
description:
|
|
3187
|
+
description: `Specifies the application type and interface requirements that this promptbook should conform to`,
|
|
3110
3188
|
/**
|
|
3111
3189
|
* Link to documentation
|
|
3112
3190
|
*/
|
|
@@ -3249,8 +3327,7 @@
|
|
|
3249
3327
|
};
|
|
3250
3328
|
|
|
3251
3329
|
/**
|
|
3252
|
-
*
|
|
3253
|
-
*
|
|
3330
|
+
* @see {@link ModelVariant}
|
|
3254
3331
|
* @public exported from `@promptbook/core`
|
|
3255
3332
|
*/
|
|
3256
3333
|
const MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
|
|
@@ -3682,10 +3759,10 @@
|
|
|
3682
3759
|
}
|
|
3683
3760
|
|
|
3684
3761
|
/**
|
|
3685
|
-
*
|
|
3762
|
+
* Checks if the given value is a valid JavaScript identifier name.
|
|
3686
3763
|
*
|
|
3687
|
-
* @param javascriptName
|
|
3688
|
-
* @returns
|
|
3764
|
+
* @param javascriptName The value to check for JavaScript identifier validity.
|
|
3765
|
+
* @returns `true` if the value is a valid JavaScript name, false otherwise.
|
|
3689
3766
|
* @public exported from `@promptbook/utils`
|
|
3690
3767
|
*/
|
|
3691
3768
|
function isValidJavascriptName(javascriptName) {
|
|
@@ -4197,7 +4274,10 @@
|
|
|
4197
4274
|
`));
|
|
4198
4275
|
}
|
|
4199
4276
|
/**
|
|
4200
|
-
*
|
|
4277
|
+
* Generates a markdown-formatted message listing all supported commands
|
|
4278
|
+
* with their descriptions and documentation links
|
|
4279
|
+
*
|
|
4280
|
+
* @returns A formatted markdown string containing all available commands and their details
|
|
4201
4281
|
*/
|
|
4202
4282
|
function getSupportedCommandsMessage() {
|
|
4203
4283
|
return COMMANDS.flatMap(({ name, aliasNames, description, documentationUrl }) =>
|
|
@@ -4208,7 +4288,10 @@
|
|
|
4208
4288
|
]).join('\n');
|
|
4209
4289
|
}
|
|
4210
4290
|
/**
|
|
4211
|
-
*
|
|
4291
|
+
* Attempts to parse a command variant using the provided input parameters
|
|
4292
|
+
*
|
|
4293
|
+
* @param input Object containing command parsing information including raw command text and normalized values
|
|
4294
|
+
* @returns A parsed Command object if successful, or null if the command cannot be parsed
|
|
4212
4295
|
*/
|
|
4213
4296
|
function parseCommandVariant(input) {
|
|
4214
4297
|
const { commandNameRaw, usagePlace, normalized, args, raw, rawArgs } = input;
|
|
@@ -4255,7 +4338,7 @@
|
|
|
4255
4338
|
}
|
|
4256
4339
|
|
|
4257
4340
|
/**
|
|
4258
|
-
*
|
|
4341
|
+
* Extracts the interface (input and output parameters) from a pipeline.
|
|
4259
4342
|
*
|
|
4260
4343
|
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
4261
4344
|
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
@@ -4288,7 +4371,7 @@
|
|
|
4288
4371
|
}
|
|
4289
4372
|
|
|
4290
4373
|
/**
|
|
4291
|
-
*
|
|
4374
|
+
* Checks if two pipeline interfaces are structurally identical.
|
|
4292
4375
|
*
|
|
4293
4376
|
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
4294
4377
|
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
@@ -4320,10 +4403,11 @@
|
|
|
4320
4403
|
}
|
|
4321
4404
|
|
|
4322
4405
|
/**
|
|
4323
|
-
*
|
|
4406
|
+
* Checks if a given pipeline satisfies the requirements of a specified pipeline interface.
|
|
4324
4407
|
*
|
|
4325
4408
|
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
4326
4409
|
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
4410
|
+
* @returns `true` if the pipeline implements the interface, `false` otherwise.
|
|
4327
4411
|
*
|
|
4328
4412
|
* @public exported from `@promptbook/core`
|
|
4329
4413
|
*/
|
|
@@ -4553,7 +4637,8 @@
|
|
|
4553
4637
|
}
|
|
4554
4638
|
|
|
4555
4639
|
/**
|
|
4556
|
-
*
|
|
4640
|
+
* Utility to determine if a pipeline string is in flat format.
|
|
4641
|
+
* A flat pipeline is a simple text without proper structure (headers, blocks, etc).
|
|
4557
4642
|
*
|
|
4558
4643
|
* @public exported from `@promptbook/editable`
|
|
4559
4644
|
*/
|
|
@@ -4574,7 +4659,10 @@
|
|
|
4574
4659
|
}
|
|
4575
4660
|
|
|
4576
4661
|
/**
|
|
4577
|
-
*
|
|
4662
|
+
* Converts a pipeline structure to its string representation.
|
|
4663
|
+
*
|
|
4664
|
+
* Transforms a flat, simple pipeline into a properly formatted pipeline string
|
|
4665
|
+
* with sections for title, prompt, and return statement.
|
|
4578
4666
|
*
|
|
4579
4667
|
* @public exported from `@promptbook/editable`
|
|
4580
4668
|
*/
|
|
@@ -4631,7 +4719,7 @@
|
|
|
4631
4719
|
* Note: It can not work with html syntax and comments
|
|
4632
4720
|
*
|
|
4633
4721
|
* @param markdown any valid markdown
|
|
4634
|
-
* @returns
|
|
4722
|
+
* @returns An array of strings, each representing an individual list item found in the markdown
|
|
4635
4723
|
* @public exported from `@promptbook/markdown-utils`
|
|
4636
4724
|
*/
|
|
4637
4725
|
function extractAllListItemsFromMarkdown(markdown) {
|
|
@@ -4884,11 +4972,11 @@
|
|
|
4884
4972
|
*/
|
|
4885
4973
|
|
|
4886
4974
|
/**
|
|
4887
|
-
*
|
|
4975
|
+
* Converts a title string into a normalized name.
|
|
4888
4976
|
*
|
|
4889
|
-
* @param value
|
|
4890
|
-
* @returns
|
|
4891
|
-
* @example
|
|
4977
|
+
* @param value The title string to be converted to a name.
|
|
4978
|
+
* @returns A normalized name derived from the input title.
|
|
4979
|
+
* @example 'Hello World!' -> 'hello-world'
|
|
4892
4980
|
* @public exported from `@promptbook/utils`
|
|
4893
4981
|
*/
|
|
4894
4982
|
function titleToName(value) {
|