@promptbook/legacy-documents 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 +557 -276
- 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 +557 -276
- 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
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-30';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -104,6 +104,21 @@ const DEFAULT_BOOK_TITLE = `✨ Untitled Book`;
|
|
|
104
104
|
* @public exported from `@promptbook/core`
|
|
105
105
|
*/
|
|
106
106
|
const DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
|
|
107
|
+
/**
|
|
108
|
+
* Threshold value that determines when a dataset is considered "big"
|
|
109
|
+
* and may require special handling or optimizations
|
|
110
|
+
*
|
|
111
|
+
* For example, when error occurs in one item of the big dataset, it will not fail the whole pipeline
|
|
112
|
+
*
|
|
113
|
+
* @public exported from `@promptbook/core`
|
|
114
|
+
*/
|
|
115
|
+
const BIG_DATASET_TRESHOLD = 50;
|
|
116
|
+
/**
|
|
117
|
+
* Placeholder text used to represent a placeholder value of failed operation
|
|
118
|
+
*
|
|
119
|
+
* @public exported from `@promptbook/core`
|
|
120
|
+
*/
|
|
121
|
+
const FAILED_VALUE_PLACEHOLDER = '!?';
|
|
107
122
|
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
108
123
|
/**
|
|
109
124
|
* The maximum number of iterations for a loops
|
|
@@ -183,7 +198,7 @@ const DEFAULT_DOWNLOAD_CACHE_DIRNAME = './.promptbook/download-cache';
|
|
|
183
198
|
const DEFAULT_SCRAPE_CACHE_DIRNAME = './.promptbook/scrape-cache';
|
|
184
199
|
// <- TODO: [🧜♂️]
|
|
185
200
|
/**
|
|
186
|
-
*
|
|
201
|
+
* Default settings for parsing and generating CSV files in Promptbook.
|
|
187
202
|
*
|
|
188
203
|
* @public exported from `@promptbook/core`
|
|
189
204
|
*/
|
|
@@ -194,19 +209,19 @@ const DEFAULT_CSV_SETTINGS = Object.freeze({
|
|
|
194
209
|
skipEmptyLines: true,
|
|
195
210
|
});
|
|
196
211
|
/**
|
|
197
|
-
*
|
|
212
|
+
* Controls whether verbose logging is enabled by default throughout the application.
|
|
198
213
|
*
|
|
199
214
|
* @public exported from `@promptbook/core`
|
|
200
215
|
*/
|
|
201
216
|
let DEFAULT_IS_VERBOSE = false;
|
|
202
217
|
/**
|
|
203
|
-
*
|
|
218
|
+
* Controls whether auto-installation of dependencies is enabled by default.
|
|
204
219
|
*
|
|
205
220
|
* @public exported from `@promptbook/core`
|
|
206
221
|
*/
|
|
207
222
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
208
223
|
/**
|
|
209
|
-
*
|
|
224
|
+
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
210
225
|
*
|
|
211
226
|
* @private within the repository
|
|
212
227
|
*/
|
|
@@ -547,7 +562,8 @@ async function isFileExisting(filename, fs) {
|
|
|
547
562
|
*/
|
|
548
563
|
|
|
549
564
|
/**
|
|
550
|
-
*
|
|
565
|
+
* Converts a name to a properly formatted subfolder path for cache storage.
|
|
566
|
+
* Handles normalization and path formatting to create consistent cache directory structures.
|
|
551
567
|
*
|
|
552
568
|
* @private for `FileCacheStorage`
|
|
553
569
|
*/
|
|
@@ -800,10 +816,10 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
|
800
816
|
*/
|
|
801
817
|
|
|
802
818
|
/**
|
|
803
|
-
*
|
|
819
|
+
* Removes diacritic marks (accents) from characters in a string.
|
|
804
820
|
*
|
|
805
|
-
* @param input
|
|
806
|
-
* @returns
|
|
821
|
+
* @param input The string containing diacritics to be normalized.
|
|
822
|
+
* @returns The string with diacritics removed or normalized.
|
|
807
823
|
* @public exported from `@promptbook/utils`
|
|
808
824
|
*/
|
|
809
825
|
function removeDiacritics(input) {
|
|
@@ -817,10 +833,10 @@ function removeDiacritics(input) {
|
|
|
817
833
|
*/
|
|
818
834
|
|
|
819
835
|
/**
|
|
820
|
-
*
|
|
836
|
+
* Converts a given text to kebab-case format.
|
|
821
837
|
*
|
|
822
|
-
* @param text
|
|
823
|
-
* @returns
|
|
838
|
+
* @param text The text to be converted.
|
|
839
|
+
* @returns The kebab-case formatted string.
|
|
824
840
|
* @example 'hello-world'
|
|
825
841
|
* @example 'i-love-promptbook'
|
|
826
842
|
* @public exported from `@promptbook/utils`
|
|
@@ -962,11 +978,11 @@ function isValidUrl(url) {
|
|
|
962
978
|
}
|
|
963
979
|
|
|
964
980
|
/**
|
|
965
|
-
*
|
|
981
|
+
* Converts a title string into a normalized name.
|
|
966
982
|
*
|
|
967
|
-
* @param value
|
|
968
|
-
* @returns
|
|
969
|
-
* @example
|
|
983
|
+
* @param value The title string to be converted to a name.
|
|
984
|
+
* @returns A normalized name derived from the input title.
|
|
985
|
+
* @example 'Hello World!' -> 'hello-world'
|
|
970
986
|
* @public exported from `@promptbook/utils`
|
|
971
987
|
*/
|
|
972
988
|
function titleToName(value) {
|
|
@@ -986,9 +1002,8 @@ function titleToName(value) {
|
|
|
986
1002
|
}
|
|
987
1003
|
|
|
988
1004
|
/**
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
* Note: It also checks if directory exists and creates it if not
|
|
1005
|
+
* Retrieves an intermediate source for a scraper based on the knowledge source.
|
|
1006
|
+
* Manages the caching and retrieval of intermediate scraper results for optimized performance.
|
|
992
1007
|
*
|
|
993
1008
|
* @private as internal utility for scrapers
|
|
994
1009
|
*/
|
|
@@ -1039,7 +1054,7 @@ async function getScraperIntermediateSource(source, options) {
|
|
|
1039
1054
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
1040
1055
|
*/
|
|
1041
1056
|
|
|
1042
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModelNames}` List of available model names separated by comma (,)\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n\\`\\`\\`json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"}];
|
|
1057
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n```json\n{availableModels}\n```\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"}];
|
|
1043
1058
|
|
|
1044
1059
|
/**
|
|
1045
1060
|
* Checks if value is valid email
|
|
@@ -1124,7 +1139,7 @@ function assertsError(whatWasThrown) {
|
|
|
1124
1139
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
1125
1140
|
*
|
|
1126
1141
|
* @param value The string to check
|
|
1127
|
-
* @returns
|
|
1142
|
+
* @returns `true` if the string is a valid JSON string, false otherwise
|
|
1128
1143
|
*
|
|
1129
1144
|
* @public exported from `@promptbook/utils`
|
|
1130
1145
|
*/
|
|
@@ -1535,8 +1550,12 @@ function checkSerializableAsJson(options) {
|
|
|
1535
1550
|
*/
|
|
1536
1551
|
|
|
1537
1552
|
/**
|
|
1538
|
-
*
|
|
1553
|
+
* Creates a deep clone of the given object
|
|
1554
|
+
*
|
|
1555
|
+
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
1539
1556
|
*
|
|
1557
|
+
* @param objectValue The object to clone.
|
|
1558
|
+
* @returns A deep, writable clone of the input object.
|
|
1540
1559
|
* @public exported from `@promptbook/utils`
|
|
1541
1560
|
*/
|
|
1542
1561
|
function deepClone(objectValue) {
|
|
@@ -1618,13 +1637,13 @@ const ORDER_OF_PIPELINE_JSON = [
|
|
|
1618
1637
|
*/
|
|
1619
1638
|
const REPLACING_NONCE = 'ptbkauk42kV2dzao34faw7FudQUHYPtW';
|
|
1620
1639
|
/**
|
|
1621
|
-
*
|
|
1640
|
+
* Placeholder value indicating a parameter is missing its value.
|
|
1622
1641
|
*
|
|
1623
1642
|
* @private within the repository
|
|
1624
1643
|
*/
|
|
1625
1644
|
const RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
1626
1645
|
/**
|
|
1627
|
-
*
|
|
1646
|
+
* Placeholder value indicating a parameter is restricted and cannot be used directly.
|
|
1628
1647
|
*
|
|
1629
1648
|
* @private within the repository
|
|
1630
1649
|
*/
|
|
@@ -2082,7 +2101,7 @@ function extractParameterNames(template) {
|
|
|
2082
2101
|
*/
|
|
2083
2102
|
function unpreparePipeline(pipeline) {
|
|
2084
2103
|
let { personas, knowledgeSources, tasks } = pipeline;
|
|
2085
|
-
personas = personas.map((persona) => ({ ...persona,
|
|
2104
|
+
personas = personas.map((persona) => ({ ...persona, modelsRequirements: undefined, preparationIds: undefined }));
|
|
2086
2105
|
knowledgeSources = knowledgeSources.map((knowledgeSource) => ({ ...knowledgeSource, preparationIds: undefined }));
|
|
2087
2106
|
tasks = tasks.map((task) => {
|
|
2088
2107
|
let { dependentParameterNames } = task;
|
|
@@ -2123,7 +2142,7 @@ class SimplePipelineCollection {
|
|
|
2123
2142
|
/**
|
|
2124
2143
|
* Constructs a pipeline collection from pipelines
|
|
2125
2144
|
*
|
|
2126
|
-
* @param pipelines
|
|
2145
|
+
* @param pipelines Array of pipeline JSON objects to include in the collection
|
|
2127
2146
|
*
|
|
2128
2147
|
* Note: During the construction logic of all pipelines are validated
|
|
2129
2148
|
* Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
|
|
@@ -2269,15 +2288,21 @@ class PipelineExecutionError extends Error {
|
|
|
2269
2288
|
* @public exported from `@promptbook/core`
|
|
2270
2289
|
*/
|
|
2271
2290
|
function isPipelinePrepared(pipeline) {
|
|
2272
|
-
// Note: Ignoring `pipeline.preparations`
|
|
2273
|
-
// Note: Ignoring `pipeline.knowledgePieces`
|
|
2291
|
+
// Note: Ignoring `pipeline.preparations`
|
|
2292
|
+
// Note: Ignoring `pipeline.knowledgePieces`
|
|
2274
2293
|
if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
|
|
2294
|
+
// TODO: !!! Comment this out
|
|
2295
|
+
console.log('Pipeline is not prepared because title is undefined or empty', pipeline);
|
|
2275
2296
|
return false;
|
|
2276
2297
|
}
|
|
2277
|
-
if (!pipeline.personas.every((persona) => persona.
|
|
2298
|
+
if (!pipeline.personas.every((persona) => persona.modelsRequirements !== undefined)) {
|
|
2299
|
+
// TODO: !!! Comment this out
|
|
2300
|
+
console.log('Pipeline is not prepared because personas are not prepared', pipeline.personas);
|
|
2278
2301
|
return false;
|
|
2279
2302
|
}
|
|
2280
2303
|
if (!pipeline.knowledgeSources.every((knowledgeSource) => knowledgeSource.preparationIds !== undefined)) {
|
|
2304
|
+
// TODO: !!! Comment this out
|
|
2305
|
+
console.log('Pipeline is not prepared because knowledge sources are not prepared', pipeline.knowledgeSources);
|
|
2281
2306
|
return false;
|
|
2282
2307
|
}
|
|
2283
2308
|
/*
|
|
@@ -2298,36 +2323,6 @@ function isPipelinePrepared(pipeline) {
|
|
|
2298
2323
|
* - [♨] Are tasks prepared
|
|
2299
2324
|
*/
|
|
2300
2325
|
|
|
2301
|
-
/**
|
|
2302
|
-
* Recursively converts JSON strings to JSON objects
|
|
2303
|
-
|
|
2304
|
-
* @public exported from `@promptbook/utils`
|
|
2305
|
-
*/
|
|
2306
|
-
function jsonStringsToJsons(object) {
|
|
2307
|
-
if (object === null) {
|
|
2308
|
-
return object;
|
|
2309
|
-
}
|
|
2310
|
-
if (Array.isArray(object)) {
|
|
2311
|
-
return object.map(jsonStringsToJsons);
|
|
2312
|
-
}
|
|
2313
|
-
if (typeof object !== 'object') {
|
|
2314
|
-
return object;
|
|
2315
|
-
}
|
|
2316
|
-
const newObject = { ...object };
|
|
2317
|
-
for (const [key, value] of Object.entries(object)) {
|
|
2318
|
-
if (typeof value === 'string' && isValidJsonString(value)) {
|
|
2319
|
-
newObject[key] = JSON.parse(value);
|
|
2320
|
-
}
|
|
2321
|
-
else {
|
|
2322
|
-
newObject[key] = jsonStringsToJsons(value);
|
|
2323
|
-
}
|
|
2324
|
-
}
|
|
2325
|
-
return newObject;
|
|
2326
|
-
}
|
|
2327
|
-
/**
|
|
2328
|
-
* TODO: Type the return type correctly
|
|
2329
|
-
*/
|
|
2330
|
-
|
|
2331
2326
|
/**
|
|
2332
2327
|
* This error indicates problems parsing the format value
|
|
2333
2328
|
*
|
|
@@ -2511,6 +2506,101 @@ const ALL_ERRORS = {
|
|
|
2511
2506
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2512
2507
|
*/
|
|
2513
2508
|
|
|
2509
|
+
/**
|
|
2510
|
+
* Serializes an error into a [🚉] JSON-serializable object
|
|
2511
|
+
*
|
|
2512
|
+
* @public exported from `@promptbook/utils`
|
|
2513
|
+
*/
|
|
2514
|
+
function serializeError(error) {
|
|
2515
|
+
const { name, message, stack } = error;
|
|
2516
|
+
const { id } = error;
|
|
2517
|
+
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2518
|
+
console.error(spaceTrim$1((block) => `
|
|
2519
|
+
|
|
2520
|
+
Cannot serialize error with name "${name}"
|
|
2521
|
+
|
|
2522
|
+
Authors of Promptbook probably forgot to add this error into the list of errors:
|
|
2523
|
+
https://github.com/webgptorg/promptbook/blob/main/src/errors/0-index.ts
|
|
2524
|
+
|
|
2525
|
+
|
|
2526
|
+
${block(stack || message)}
|
|
2527
|
+
|
|
2528
|
+
`));
|
|
2529
|
+
}
|
|
2530
|
+
return {
|
|
2531
|
+
name: name,
|
|
2532
|
+
message,
|
|
2533
|
+
stack,
|
|
2534
|
+
id, // Include id in the serialized object
|
|
2535
|
+
};
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2538
|
+
/**
|
|
2539
|
+
* Converts a JavaScript Object Notation (JSON) string into an object.
|
|
2540
|
+
*
|
|
2541
|
+
* Note: This is wrapper around `JSON.parse()` with better error and type handling
|
|
2542
|
+
*
|
|
2543
|
+
* @public exported from `@promptbook/utils`
|
|
2544
|
+
*/
|
|
2545
|
+
function jsonParse(value) {
|
|
2546
|
+
if (value === undefined) {
|
|
2547
|
+
throw new Error(`Can not parse JSON from undefined value.`);
|
|
2548
|
+
}
|
|
2549
|
+
else if (typeof value !== 'string') {
|
|
2550
|
+
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
2551
|
+
throw new Error(spaceTrim$1(`
|
|
2552
|
+
Can not parse JSON from non-string value.
|
|
2553
|
+
|
|
2554
|
+
The value type: ${typeof value}
|
|
2555
|
+
See more in console.
|
|
2556
|
+
`));
|
|
2557
|
+
}
|
|
2558
|
+
try {
|
|
2559
|
+
return JSON.parse(value);
|
|
2560
|
+
}
|
|
2561
|
+
catch (error) {
|
|
2562
|
+
if (!(error instanceof Error)) {
|
|
2563
|
+
throw error;
|
|
2564
|
+
}
|
|
2565
|
+
throw new Error(spaceTrim$1((block) => `
|
|
2566
|
+
${block(error.message)}
|
|
2567
|
+
|
|
2568
|
+
The JSON text:
|
|
2569
|
+
${block(value)}
|
|
2570
|
+
`));
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
/**
|
|
2575
|
+
* Recursively converts JSON strings to JSON objects
|
|
2576
|
+
|
|
2577
|
+
* @public exported from `@promptbook/utils`
|
|
2578
|
+
*/
|
|
2579
|
+
function jsonStringsToJsons(object) {
|
|
2580
|
+
if (object === null) {
|
|
2581
|
+
return object;
|
|
2582
|
+
}
|
|
2583
|
+
if (Array.isArray(object)) {
|
|
2584
|
+
return object.map(jsonStringsToJsons);
|
|
2585
|
+
}
|
|
2586
|
+
if (typeof object !== 'object') {
|
|
2587
|
+
return object;
|
|
2588
|
+
}
|
|
2589
|
+
const newObject = { ...object };
|
|
2590
|
+
for (const [key, value] of Object.entries(object)) {
|
|
2591
|
+
if (typeof value === 'string' && isValidJsonString(value)) {
|
|
2592
|
+
newObject[key] = jsonParse(value);
|
|
2593
|
+
}
|
|
2594
|
+
else {
|
|
2595
|
+
newObject[key] = jsonStringsToJsons(value);
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
return newObject;
|
|
2599
|
+
}
|
|
2600
|
+
/**
|
|
2601
|
+
* TODO: Type the return type correctly
|
|
2602
|
+
*/
|
|
2603
|
+
|
|
2514
2604
|
/**
|
|
2515
2605
|
* Deserializes the error object
|
|
2516
2606
|
*
|
|
@@ -2676,64 +2766,6 @@ function createTask(options) {
|
|
|
2676
2766
|
* TODO: [🐚] Split into more files and make `PrepareTask` & `RemoteTask` + split the function
|
|
2677
2767
|
*/
|
|
2678
2768
|
|
|
2679
|
-
/**
|
|
2680
|
-
* Serializes an error into a [🚉] JSON-serializable object
|
|
2681
|
-
*
|
|
2682
|
-
* @public exported from `@promptbook/utils`
|
|
2683
|
-
*/
|
|
2684
|
-
function serializeError(error) {
|
|
2685
|
-
const { name, message, stack } = error;
|
|
2686
|
-
const { id } = error;
|
|
2687
|
-
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2688
|
-
console.error(spaceTrim$1((block) => `
|
|
2689
|
-
|
|
2690
|
-
Cannot serialize error with name "${name}"
|
|
2691
|
-
|
|
2692
|
-
Authors of Promptbook probably forgot to add this error into the list of errors:
|
|
2693
|
-
https://github.com/webgptorg/promptbook/blob/main/src/errors/0-index.ts
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
${block(stack || message)}
|
|
2697
|
-
|
|
2698
|
-
`));
|
|
2699
|
-
}
|
|
2700
|
-
return {
|
|
2701
|
-
name: name,
|
|
2702
|
-
message,
|
|
2703
|
-
stack,
|
|
2704
|
-
id, // Include id in the serialized object
|
|
2705
|
-
};
|
|
2706
|
-
}
|
|
2707
|
-
|
|
2708
|
-
/**
|
|
2709
|
-
* Async version of Array.forEach
|
|
2710
|
-
*
|
|
2711
|
-
* @param array - Array to iterate over
|
|
2712
|
-
* @param options - Options for the function
|
|
2713
|
-
* @param callbackfunction - Function to call for each item
|
|
2714
|
-
* @public exported from `@promptbook/utils`
|
|
2715
|
-
* @deprecated [🪂] Use queues instead
|
|
2716
|
-
*/
|
|
2717
|
-
async function forEachAsync(array, options, callbackfunction) {
|
|
2718
|
-
const { maxParallelCount = Infinity } = options;
|
|
2719
|
-
let index = 0;
|
|
2720
|
-
let runningTasks = [];
|
|
2721
|
-
const tasks = [];
|
|
2722
|
-
for (const item of array) {
|
|
2723
|
-
const currentIndex = index++;
|
|
2724
|
-
const task = callbackfunction(item, currentIndex, array);
|
|
2725
|
-
tasks.push(task);
|
|
2726
|
-
runningTasks.push(task);
|
|
2727
|
-
/* not await */ Promise.resolve(task).then(() => {
|
|
2728
|
-
runningTasks = runningTasks.filter((t) => t !== task);
|
|
2729
|
-
});
|
|
2730
|
-
if (maxParallelCount < runningTasks.length) {
|
|
2731
|
-
await Promise.race(runningTasks);
|
|
2732
|
-
}
|
|
2733
|
-
}
|
|
2734
|
-
await Promise.all(tasks);
|
|
2735
|
-
}
|
|
2736
|
-
|
|
2737
2769
|
/**
|
|
2738
2770
|
* Represents the uncertain value
|
|
2739
2771
|
*
|
|
@@ -2777,7 +2809,7 @@ const ZERO_USAGE = $deepFreeze({
|
|
|
2777
2809
|
*
|
|
2778
2810
|
* @public exported from `@promptbook/core`
|
|
2779
2811
|
*/
|
|
2780
|
-
$deepFreeze({
|
|
2812
|
+
const UNCERTAIN_USAGE = $deepFreeze({
|
|
2781
2813
|
price: UNCERTAIN_ZERO_VALUE,
|
|
2782
2814
|
input: {
|
|
2783
2815
|
tokensCount: UNCERTAIN_ZERO_VALUE,
|
|
@@ -2802,6 +2834,35 @@ $deepFreeze({
|
|
|
2802
2834
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2803
2835
|
*/
|
|
2804
2836
|
|
|
2837
|
+
/**
|
|
2838
|
+
* Async version of Array.forEach
|
|
2839
|
+
*
|
|
2840
|
+
* @param array - Array to iterate over
|
|
2841
|
+
* @param options - Options for the function
|
|
2842
|
+
* @param callbackfunction - Function to call for each item
|
|
2843
|
+
* @public exported from `@promptbook/utils`
|
|
2844
|
+
* @deprecated [🪂] Use queues instead
|
|
2845
|
+
*/
|
|
2846
|
+
async function forEachAsync(array, options, callbackfunction) {
|
|
2847
|
+
const { maxParallelCount = Infinity } = options;
|
|
2848
|
+
let index = 0;
|
|
2849
|
+
let runningTasks = [];
|
|
2850
|
+
const tasks = [];
|
|
2851
|
+
for (const item of array) {
|
|
2852
|
+
const currentIndex = index++;
|
|
2853
|
+
const task = callbackfunction(item, currentIndex, array);
|
|
2854
|
+
tasks.push(task);
|
|
2855
|
+
runningTasks.push(task);
|
|
2856
|
+
/* not await */ Promise.resolve(task).then(() => {
|
|
2857
|
+
runningTasks = runningTasks.filter((t) => t !== task);
|
|
2858
|
+
});
|
|
2859
|
+
if (maxParallelCount < runningTasks.length) {
|
|
2860
|
+
await Promise.race(runningTasks);
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
await Promise.all(tasks);
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2805
2866
|
/**
|
|
2806
2867
|
* Function `addUsage` will add multiple usages into one
|
|
2807
2868
|
*
|
|
@@ -3148,27 +3209,48 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
3148
3209
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
|
|
3149
3210
|
tools,
|
|
3150
3211
|
});
|
|
3151
|
-
// TODO: [🚐] Make arrayable LLMs -> single LLM DRY
|
|
3152
3212
|
const _llms = arrayableToArray(tools.llm);
|
|
3153
3213
|
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
3154
|
-
const availableModels = await llmTools.listModels()
|
|
3155
|
-
const availableModelNames = availableModels
|
|
3214
|
+
const availableModels = (await llmTools.listModels())
|
|
3156
3215
|
.filter(({ modelVariant }) => modelVariant === 'CHAT')
|
|
3157
|
-
.map(({ modelName }) =>
|
|
3158
|
-
|
|
3159
|
-
|
|
3216
|
+
.map(({ modelName, modelDescription }) => ({
|
|
3217
|
+
modelName,
|
|
3218
|
+
modelDescription,
|
|
3219
|
+
// <- Note: `modelTitle` and `modelVariant` is not relevant for this task
|
|
3220
|
+
}));
|
|
3221
|
+
const result = await preparePersonaExecutor({
|
|
3222
|
+
availableModels /* <- Note: Passing as JSON */,
|
|
3223
|
+
personaDescription,
|
|
3224
|
+
}).asPromise();
|
|
3160
3225
|
const { outputParameters } = result;
|
|
3161
|
-
const {
|
|
3162
|
-
|
|
3226
|
+
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
3227
|
+
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
3163
3228
|
if (isVerbose) {
|
|
3164
|
-
console.info(`PERSONA ${personaDescription}`,
|
|
3229
|
+
console.info(`PERSONA ${personaDescription}`, modelsRequirementsUnchecked);
|
|
3165
3230
|
}
|
|
3166
|
-
|
|
3167
|
-
|
|
3231
|
+
if (!Array.isArray(modelsRequirementsUnchecked)) {
|
|
3232
|
+
// <- TODO: Book should have syntax and system to enforce shape of JSON
|
|
3233
|
+
modelsRequirementsUnchecked = [modelsRequirementsUnchecked];
|
|
3234
|
+
/*
|
|
3235
|
+
throw new UnexpectedError(
|
|
3236
|
+
spaceTrim(
|
|
3237
|
+
(block) => `
|
|
3238
|
+
Invalid \`modelsRequirements\`:
|
|
3239
|
+
|
|
3240
|
+
\`\`\`json
|
|
3241
|
+
${block(JSON.stringify(modelsRequirementsUnchecked, null, 4))}
|
|
3242
|
+
\`\`\`
|
|
3243
|
+
`,
|
|
3244
|
+
),
|
|
3245
|
+
);
|
|
3246
|
+
*/
|
|
3247
|
+
}
|
|
3248
|
+
const modelsRequirements = modelsRequirementsUnchecked.map((modelRequirements) => ({
|
|
3168
3249
|
modelVariant: 'CHAT',
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3250
|
+
...modelRequirements,
|
|
3251
|
+
}));
|
|
3252
|
+
return {
|
|
3253
|
+
modelsRequirements,
|
|
3172
3254
|
};
|
|
3173
3255
|
}
|
|
3174
3256
|
/**
|
|
@@ -3179,7 +3261,8 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
3179
3261
|
*/
|
|
3180
3262
|
|
|
3181
3263
|
/**
|
|
3182
|
-
*
|
|
3264
|
+
* Safely retrieves the global scope object (window in browser, global in Node.js)
|
|
3265
|
+
* regardless of the JavaScript environment in which the code is running
|
|
3183
3266
|
*
|
|
3184
3267
|
* Note: `$` is used to indicate that this function is not a pure function - it access global scope
|
|
3185
3268
|
*
|
|
@@ -3190,10 +3273,10 @@ function $getGlobalScope() {
|
|
|
3190
3273
|
}
|
|
3191
3274
|
|
|
3192
3275
|
/**
|
|
3193
|
-
*
|
|
3276
|
+
* Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
|
|
3194
3277
|
*
|
|
3195
|
-
* @param text
|
|
3196
|
-
* @returns
|
|
3278
|
+
* @param text The text string to be converted to SCREAMING_CASE format.
|
|
3279
|
+
* @returns The normalized text in SCREAMING_CASE format.
|
|
3197
3280
|
* @example 'HELLO_WORLD'
|
|
3198
3281
|
* @example 'I_LOVE_PROMPTBOOK'
|
|
3199
3282
|
* @public exported from `@promptbook/utils`
|
|
@@ -3245,10 +3328,10 @@ function normalizeTo_SCREAMING_CASE(text) {
|
|
|
3245
3328
|
*/
|
|
3246
3329
|
|
|
3247
3330
|
/**
|
|
3248
|
-
*
|
|
3331
|
+
* Normalizes a text string to snake_case format.
|
|
3249
3332
|
*
|
|
3250
|
-
* @param text
|
|
3251
|
-
* @returns
|
|
3333
|
+
* @param text The text string to be converted to snake_case format.
|
|
3334
|
+
* @returns The normalized text in snake_case format.
|
|
3252
3335
|
* @example 'hello_world'
|
|
3253
3336
|
* @example 'i_love_promptbook'
|
|
3254
3337
|
* @public exported from `@promptbook/utils`
|
|
@@ -3258,11 +3341,11 @@ function normalizeTo_snake_case(text) {
|
|
|
3258
3341
|
}
|
|
3259
3342
|
|
|
3260
3343
|
/**
|
|
3261
|
-
*
|
|
3344
|
+
* Global registry for storing and managing registered entities of a given type.
|
|
3262
3345
|
*
|
|
3263
3346
|
* Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope.
|
|
3264
3347
|
*
|
|
3265
|
-
* @private internal utility, exported are only
|
|
3348
|
+
* @private internal utility, exported are only singleton instances of this class
|
|
3266
3349
|
*/
|
|
3267
3350
|
class $Register {
|
|
3268
3351
|
constructor(registerName) {
|
|
@@ -3306,10 +3389,10 @@ class $Register {
|
|
|
3306
3389
|
}
|
|
3307
3390
|
|
|
3308
3391
|
/**
|
|
3309
|
-
*
|
|
3392
|
+
* Global registry for storing metadata about all available scrapers and converters.
|
|
3310
3393
|
*
|
|
3311
|
-
* Note: `$` is used to indicate that this interacts with the global scope
|
|
3312
|
-
* @singleton Only one instance of each register is created per build, but
|
|
3394
|
+
* Note: `$` is used to indicate that this interacts with the global scope.
|
|
3395
|
+
* @singleton Only one instance of each register is created per build, but there can be more in different contexts (e.g., tests).
|
|
3313
3396
|
* @public exported from `@promptbook/core`
|
|
3314
3397
|
*/
|
|
3315
3398
|
const $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
@@ -3318,10 +3401,11 @@ const $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
|
3318
3401
|
*/
|
|
3319
3402
|
|
|
3320
3403
|
/**
|
|
3321
|
-
*
|
|
3404
|
+
* Registry for all available scrapers in the system.
|
|
3405
|
+
* Central point for registering and accessing different types of content scrapers.
|
|
3322
3406
|
*
|
|
3323
3407
|
* Note: `$` is used to indicate that this interacts with the global scope
|
|
3324
|
-
* @singleton Only one instance of each register is created per build, but
|
|
3408
|
+
* @singleton Only one instance of each register is created per build, but there can be more than one in different build modules
|
|
3325
3409
|
* @public exported from `@promptbook/core`
|
|
3326
3410
|
*/
|
|
3327
3411
|
const $scrapersRegister = new $Register('scraper_constructors');
|
|
@@ -3489,7 +3573,9 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
3489
3573
|
*/
|
|
3490
3574
|
|
|
3491
3575
|
/**
|
|
3492
|
-
*
|
|
3576
|
+
* Factory function that creates a handler for processing knowledge sources.
|
|
3577
|
+
* Provides standardized processing of different types of knowledge sources
|
|
3578
|
+
* across various scraper implementations.
|
|
3493
3579
|
*
|
|
3494
3580
|
* @public exported from `@promptbook/core`
|
|
3495
3581
|
*/
|
|
@@ -3596,7 +3682,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3596
3682
|
> },
|
|
3597
3683
|
*/
|
|
3598
3684
|
async asJson() {
|
|
3599
|
-
return
|
|
3685
|
+
return jsonParse(await tools.fs.readFile(filename, 'utf-8'));
|
|
3600
3686
|
},
|
|
3601
3687
|
async asText() {
|
|
3602
3688
|
return await tools.fs.readFile(filename, 'utf-8');
|
|
@@ -3730,9 +3816,12 @@ TODO: [🧊] This is how it can look in future
|
|
|
3730
3816
|
*/
|
|
3731
3817
|
|
|
3732
3818
|
/**
|
|
3733
|
-
*
|
|
3819
|
+
* Prepares tasks by adding knowledge to the prompt and ensuring all necessary parameters are included.
|
|
3734
3820
|
*
|
|
3735
|
-
* @
|
|
3821
|
+
* @param tasks Sequence of tasks that are chained together to form a pipeline
|
|
3822
|
+
* @returns A promise that resolves to the prepared tasks.
|
|
3823
|
+
*
|
|
3824
|
+
* @private internal utility of `preparePipeline`
|
|
3736
3825
|
*/
|
|
3737
3826
|
async function prepareTasks(pipeline, tools, options) {
|
|
3738
3827
|
const { maxParallelCount = DEFAULT_MAX_PARALLEL_COUNT } = options;
|
|
@@ -3854,14 +3943,14 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
3854
3943
|
// TODO: [🖌][🧠] Implement some `mapAsync` function
|
|
3855
3944
|
const preparedPersonas = new Array(personas.length);
|
|
3856
3945
|
await forEachAsync(personas, { maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, async (persona, index) => {
|
|
3857
|
-
const
|
|
3946
|
+
const { modelsRequirements } = await preparePersona(persona.description, { ...tools, llm: llmToolsWithUsage }, {
|
|
3858
3947
|
rootDirname,
|
|
3859
3948
|
maxParallelCount /* <- TODO: [🪂] */,
|
|
3860
3949
|
isVerbose,
|
|
3861
3950
|
});
|
|
3862
3951
|
const preparedPersona = {
|
|
3863
3952
|
...persona,
|
|
3864
|
-
|
|
3953
|
+
modelsRequirements,
|
|
3865
3954
|
preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id],
|
|
3866
3955
|
// <- TODO: [🍙] Make some standard order of json properties
|
|
3867
3956
|
};
|
|
@@ -4169,7 +4258,7 @@ function union(...sets) {
|
|
|
4169
4258
|
}
|
|
4170
4259
|
|
|
4171
4260
|
/**
|
|
4172
|
-
*
|
|
4261
|
+
* Contains configuration options for parsing and generating CSV files, such as delimiters and quoting rules.
|
|
4173
4262
|
*
|
|
4174
4263
|
* @public exported from `@promptbook/core`
|
|
4175
4264
|
*/
|
|
@@ -4178,11 +4267,29 @@ const MANDATORY_CSV_SETTINGS = Object.freeze({
|
|
|
4178
4267
|
// encoding: 'utf-8',
|
|
4179
4268
|
});
|
|
4180
4269
|
|
|
4270
|
+
/**
|
|
4271
|
+
* Converts a CSV string into an object
|
|
4272
|
+
*
|
|
4273
|
+
* Note: This is wrapper around `papaparse.parse()` with better autohealing
|
|
4274
|
+
*
|
|
4275
|
+
* @private - for now until `@promptbook/csv` is released
|
|
4276
|
+
*/
|
|
4277
|
+
function csvParse(value /* <- TODO: string_csv */, settings, schema /* <- TODO: Make CSV Schemas */) {
|
|
4278
|
+
settings = { ...settings, ...MANDATORY_CSV_SETTINGS };
|
|
4279
|
+
// Note: Autoheal invalid '\n' characters
|
|
4280
|
+
if (settings.newline && !settings.newline.includes('\r') && value.includes('\r')) {
|
|
4281
|
+
console.warn('CSV string contains carriage return characters, but in the CSV settings the `newline` setting does not include them. Autohealing the CSV string.');
|
|
4282
|
+
value = value.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
4283
|
+
}
|
|
4284
|
+
const csv = parse(value, settings);
|
|
4285
|
+
return csv;
|
|
4286
|
+
}
|
|
4287
|
+
|
|
4181
4288
|
/**
|
|
4182
4289
|
* Function to check if a string is valid CSV
|
|
4183
4290
|
*
|
|
4184
4291
|
* @param value The string to check
|
|
4185
|
-
* @returns
|
|
4292
|
+
* @returns `true` if the string is a valid CSV string, false otherwise
|
|
4186
4293
|
*
|
|
4187
4294
|
* @public exported from `@promptbook/utils`
|
|
4188
4295
|
*/
|
|
@@ -4206,7 +4313,7 @@ function isValidCsvString(value) {
|
|
|
4206
4313
|
* @public exported from `@promptbook/core`
|
|
4207
4314
|
* <- TODO: [🏢] Export from package `@promptbook/csv`
|
|
4208
4315
|
*/
|
|
4209
|
-
const
|
|
4316
|
+
const CsvFormatParser = {
|
|
4210
4317
|
formatName: 'CSV',
|
|
4211
4318
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
4212
4319
|
isValid(value, settings, schema) {
|
|
@@ -4218,12 +4325,12 @@ const CsvFormatDefinition = {
|
|
|
4218
4325
|
heal(value, settings, schema) {
|
|
4219
4326
|
throw new Error('Not implemented');
|
|
4220
4327
|
},
|
|
4221
|
-
|
|
4328
|
+
subvalueParsers: [
|
|
4222
4329
|
{
|
|
4223
4330
|
subvalueName: 'ROW',
|
|
4224
|
-
async mapValues(
|
|
4225
|
-
|
|
4226
|
-
const csv =
|
|
4331
|
+
async mapValues(options) {
|
|
4332
|
+
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
4333
|
+
const csv = csvParse(value, settings);
|
|
4227
4334
|
if (csv.errors.length !== 0) {
|
|
4228
4335
|
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
4229
4336
|
CSV parsing error
|
|
@@ -4238,23 +4345,37 @@ const CsvFormatDefinition = {
|
|
|
4238
4345
|
${block(value)}
|
|
4239
4346
|
`));
|
|
4240
4347
|
}
|
|
4241
|
-
const mappedData =
|
|
4348
|
+
const mappedData = [];
|
|
4349
|
+
const length = csv.data.length;
|
|
4350
|
+
for (let index = 0; index < length; index++) {
|
|
4351
|
+
const row = csv.data[index];
|
|
4242
4352
|
if (row[outputParameterName]) {
|
|
4243
4353
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
4244
4354
|
}
|
|
4245
|
-
|
|
4355
|
+
const mappedRow = {
|
|
4246
4356
|
...row,
|
|
4247
|
-
[outputParameterName]: await mapCallback(row, index),
|
|
4357
|
+
[outputParameterName]: await mapCallback(row, index, length),
|
|
4248
4358
|
};
|
|
4249
|
-
|
|
4359
|
+
mappedData.push(mappedRow);
|
|
4360
|
+
if (onProgress) {
|
|
4361
|
+
// Note: Report the CSV with all rows mapped so far
|
|
4362
|
+
/*
|
|
4363
|
+
// TODO: [🛕] Report progress with all the rows including the pending ones
|
|
4364
|
+
const progressData = mappedData.map((row, i) =>
|
|
4365
|
+
i > index ? { ...row, [outputParameterName]: PENDING_VALUE_PLACEHOLDER } : row,
|
|
4366
|
+
);
|
|
4367
|
+
*/
|
|
4368
|
+
await onProgress(unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
4369
|
+
}
|
|
4370
|
+
}
|
|
4250
4371
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
4251
4372
|
},
|
|
4252
4373
|
},
|
|
4253
4374
|
{
|
|
4254
4375
|
subvalueName: 'CELL',
|
|
4255
|
-
async mapValues(
|
|
4256
|
-
|
|
4257
|
-
const csv =
|
|
4376
|
+
async mapValues(options) {
|
|
4377
|
+
const { value, settings, mapCallback, onProgress } = options;
|
|
4378
|
+
const csv = csvParse(value, settings);
|
|
4258
4379
|
if (csv.errors.length !== 0) {
|
|
4259
4380
|
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
4260
4381
|
CSV parsing error
|
|
@@ -4270,9 +4391,9 @@ const CsvFormatDefinition = {
|
|
|
4270
4391
|
`));
|
|
4271
4392
|
}
|
|
4272
4393
|
const mappedData = await Promise.all(csv.data.map(async (row, rowIndex) => {
|
|
4273
|
-
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex) => {
|
|
4394
|
+
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex, array) => {
|
|
4274
4395
|
const index = rowIndex * Object.keys(row).length + columnIndex;
|
|
4275
|
-
return /* not await */ mapCallback({ [key]: value }, index);
|
|
4396
|
+
return /* not await */ mapCallback({ [key]: value }, index, array.length);
|
|
4276
4397
|
}));
|
|
4277
4398
|
}));
|
|
4278
4399
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
@@ -4281,10 +4402,10 @@ const CsvFormatDefinition = {
|
|
|
4281
4402
|
],
|
|
4282
4403
|
};
|
|
4283
4404
|
/**
|
|
4284
|
-
* TODO: [🍓] In `
|
|
4285
|
-
* TODO: [🍓] In `
|
|
4286
|
-
* TODO: [🍓] In `
|
|
4287
|
-
* TODO: [🍓] In `
|
|
4405
|
+
* TODO: [🍓] In `CsvFormatParser` implement simple `isValid`
|
|
4406
|
+
* TODO: [🍓] In `CsvFormatParser` implement partial `canBeValid`
|
|
4407
|
+
* TODO: [🍓] In `CsvFormatParser` implement `heal
|
|
4408
|
+
* TODO: [🍓] In `CsvFormatParser` implement `subvalueParsers`
|
|
4288
4409
|
* TODO: [🏢] Allow to expect something inside CSV objects and other formats
|
|
4289
4410
|
*/
|
|
4290
4411
|
|
|
@@ -4293,7 +4414,7 @@ const CsvFormatDefinition = {
|
|
|
4293
4414
|
*
|
|
4294
4415
|
* @private still in development [🏢]
|
|
4295
4416
|
*/
|
|
4296
|
-
const
|
|
4417
|
+
const JsonFormatParser = {
|
|
4297
4418
|
formatName: 'JSON',
|
|
4298
4419
|
mimeType: 'application/json',
|
|
4299
4420
|
isValid(value, settings, schema) {
|
|
@@ -4305,28 +4426,28 @@ const JsonFormatDefinition = {
|
|
|
4305
4426
|
heal(value, settings, schema) {
|
|
4306
4427
|
throw new Error('Not implemented');
|
|
4307
4428
|
},
|
|
4308
|
-
|
|
4429
|
+
subvalueParsers: [],
|
|
4309
4430
|
};
|
|
4310
4431
|
/**
|
|
4311
4432
|
* TODO: [🧠] Maybe propper instance of object
|
|
4312
4433
|
* TODO: [0] Make string_serialized_json
|
|
4313
4434
|
* TODO: [1] Make type for JSON Settings and Schema
|
|
4314
4435
|
* TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
|
|
4315
|
-
* TODO: [🍓] In `
|
|
4316
|
-
* TODO: [🍓] In `
|
|
4317
|
-
* TODO: [🍓] In `
|
|
4318
|
-
* TODO: [🍓] In `
|
|
4436
|
+
* TODO: [🍓] In `JsonFormatParser` implement simple `isValid`
|
|
4437
|
+
* TODO: [🍓] In `JsonFormatParser` implement partial `canBeValid`
|
|
4438
|
+
* TODO: [🍓] In `JsonFormatParser` implement `heal
|
|
4439
|
+
* TODO: [🍓] In `JsonFormatParser` implement `subvalueParsers`
|
|
4319
4440
|
* TODO: [🏢] Allow to expect something inside JSON objects and other formats
|
|
4320
4441
|
*/
|
|
4321
4442
|
|
|
4322
4443
|
/**
|
|
4323
4444
|
* Definition for any text - this will be always valid
|
|
4324
4445
|
*
|
|
4325
|
-
* Note: This is not useful for validation, but for splitting and mapping with `
|
|
4446
|
+
* Note: This is not useful for validation, but for splitting and mapping with `subvalueParsers`
|
|
4326
4447
|
*
|
|
4327
4448
|
* @public exported from `@promptbook/core`
|
|
4328
4449
|
*/
|
|
4329
|
-
const
|
|
4450
|
+
const TextFormatParser = {
|
|
4330
4451
|
formatName: 'TEXT',
|
|
4331
4452
|
isValid(value) {
|
|
4332
4453
|
return typeof value === 'string';
|
|
@@ -4335,19 +4456,20 @@ const TextFormatDefinition = {
|
|
|
4335
4456
|
return typeof partialValue === 'string';
|
|
4336
4457
|
},
|
|
4337
4458
|
heal() {
|
|
4338
|
-
throw new UnexpectedError('It does not make sense to call `
|
|
4459
|
+
throw new UnexpectedError('It does not make sense to call `TextFormatParser.heal`');
|
|
4339
4460
|
},
|
|
4340
|
-
|
|
4461
|
+
subvalueParsers: [
|
|
4341
4462
|
{
|
|
4342
4463
|
subvalueName: 'LINE',
|
|
4343
|
-
async mapValues(
|
|
4464
|
+
async mapValues(options) {
|
|
4465
|
+
const { value, mapCallback, onProgress } = options;
|
|
4344
4466
|
const lines = value.split('\n');
|
|
4345
|
-
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
4467
|
+
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
|
|
4346
4468
|
// TODO: [🧠] Maybe option to skip empty line
|
|
4347
4469
|
/* not await */ mapCallback({
|
|
4348
4470
|
lineContent,
|
|
4349
4471
|
// TODO: [🧠] Maybe also put here `lineNumber`
|
|
4350
|
-
}, lineNumber)));
|
|
4472
|
+
}, lineNumber, array.length)));
|
|
4351
4473
|
return mappedLines.join('\n');
|
|
4352
4474
|
},
|
|
4353
4475
|
},
|
|
@@ -4357,10 +4479,10 @@ const TextFormatDefinition = {
|
|
|
4357
4479
|
/**
|
|
4358
4480
|
* TODO: [1] Make type for XML Text and Schema
|
|
4359
4481
|
* TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages available as subvalues
|
|
4360
|
-
* TODO: [🍓] In `
|
|
4361
|
-
* TODO: [🍓] In `
|
|
4362
|
-
* TODO: [🍓] In `
|
|
4363
|
-
* TODO: [🍓] In `
|
|
4482
|
+
* TODO: [🍓] In `TextFormatParser` implement simple `isValid`
|
|
4483
|
+
* TODO: [🍓] In `TextFormatParser` implement partial `canBeValid`
|
|
4484
|
+
* TODO: [🍓] In `TextFormatParser` implement `heal
|
|
4485
|
+
* TODO: [🍓] In `TextFormatParser` implement `subvalueParsers`
|
|
4364
4486
|
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
4365
4487
|
*/
|
|
4366
4488
|
|
|
@@ -4368,7 +4490,7 @@ const TextFormatDefinition = {
|
|
|
4368
4490
|
* Function to check if a string is valid XML
|
|
4369
4491
|
*
|
|
4370
4492
|
* @param value
|
|
4371
|
-
* @returns
|
|
4493
|
+
* @returns `true` if the string is a valid XML string, false otherwise
|
|
4372
4494
|
*
|
|
4373
4495
|
* @public exported from `@promptbook/utils`
|
|
4374
4496
|
*/
|
|
@@ -4393,7 +4515,7 @@ function isValidXmlString(value) {
|
|
|
4393
4515
|
*
|
|
4394
4516
|
* @private still in development [🏢]
|
|
4395
4517
|
*/
|
|
4396
|
-
const
|
|
4518
|
+
const XmlFormatParser = {
|
|
4397
4519
|
formatName: 'XML',
|
|
4398
4520
|
mimeType: 'application/xml',
|
|
4399
4521
|
isValid(value, settings, schema) {
|
|
@@ -4405,17 +4527,17 @@ const XmlFormatDefinition = {
|
|
|
4405
4527
|
heal(value, settings, schema) {
|
|
4406
4528
|
throw new Error('Not implemented');
|
|
4407
4529
|
},
|
|
4408
|
-
|
|
4530
|
+
subvalueParsers: [],
|
|
4409
4531
|
};
|
|
4410
4532
|
/**
|
|
4411
4533
|
* TODO: [🧠] Maybe propper instance of object
|
|
4412
4534
|
* TODO: [0] Make string_serialized_xml
|
|
4413
4535
|
* TODO: [1] Make type for XML Settings and Schema
|
|
4414
4536
|
* TODO: [🧠] What to use for validating XMLs - XSD,...
|
|
4415
|
-
* TODO: [🍓] In `
|
|
4416
|
-
* TODO: [🍓] In `
|
|
4417
|
-
* TODO: [🍓] In `
|
|
4418
|
-
* TODO: [🍓] In `
|
|
4537
|
+
* TODO: [🍓] In `XmlFormatParser` implement simple `isValid`
|
|
4538
|
+
* TODO: [🍓] In `XmlFormatParser` implement partial `canBeValid`
|
|
4539
|
+
* TODO: [🍓] In `XmlFormatParser` implement `heal
|
|
4540
|
+
* TODO: [🍓] In `XmlFormatParser` implement `subvalueParsers`
|
|
4419
4541
|
* TODO: [🏢] Allow to expect something inside XML and other formats
|
|
4420
4542
|
*/
|
|
4421
4543
|
|
|
@@ -4424,24 +4546,19 @@ const XmlFormatDefinition = {
|
|
|
4424
4546
|
*
|
|
4425
4547
|
* @private internal index of `...` <- TODO [🏢]
|
|
4426
4548
|
*/
|
|
4427
|
-
const FORMAT_DEFINITIONS = [
|
|
4428
|
-
JsonFormatDefinition,
|
|
4429
|
-
XmlFormatDefinition,
|
|
4430
|
-
TextFormatDefinition,
|
|
4431
|
-
CsvFormatDefinition,
|
|
4432
|
-
];
|
|
4549
|
+
const FORMAT_DEFINITIONS = [JsonFormatParser, XmlFormatParser, TextFormatParser, CsvFormatParser];
|
|
4433
4550
|
/**
|
|
4434
4551
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
4435
4552
|
*/
|
|
4436
4553
|
|
|
4437
4554
|
/**
|
|
4438
|
-
* Maps available parameters to expected parameters
|
|
4555
|
+
* Maps available parameters to expected parameters for a pipeline task.
|
|
4439
4556
|
*
|
|
4440
4557
|
* The strategy is:
|
|
4441
|
-
* 1)
|
|
4442
|
-
* 2)
|
|
4558
|
+
* 1) First, match parameters by name where both available and expected.
|
|
4559
|
+
* 2) Then, if there are unmatched expected and available parameters, map them by order.
|
|
4443
4560
|
*
|
|
4444
|
-
* @throws {PipelineExecutionError}
|
|
4561
|
+
* @throws {PipelineExecutionError} If the number of unmatched expected and available parameters does not match, or mapping is ambiguous.
|
|
4445
4562
|
* @private within the repository used in `createPipelineExecutor`
|
|
4446
4563
|
*/
|
|
4447
4564
|
function mapAvailableToExpectedParameters(options) {
|
|
@@ -4464,7 +4581,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
4464
4581
|
else if (!availableParametersNames.has(parameterName) && expectedParameterNames.has(parameterName)) ;
|
|
4465
4582
|
}
|
|
4466
4583
|
if (expectedParameterNames.size === 0) {
|
|
4467
|
-
// Note: [👨👨👧] Now we can freeze `mappedParameters` to prevent
|
|
4584
|
+
// Note: [👨👨👧] Now we can freeze `mappedParameters` to prevent accidental modifications after mapping
|
|
4468
4585
|
Object.freeze(mappedParameters);
|
|
4469
4586
|
return mappedParameters;
|
|
4470
4587
|
}
|
|
@@ -4495,7 +4612,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
4495
4612
|
for (let i = 0; i < expectedParameterNames.size; i++) {
|
|
4496
4613
|
mappedParameters[expectedParameterNamesArray[i]] = availableParameters[availableParametersNamesArray[i]];
|
|
4497
4614
|
}
|
|
4498
|
-
// Note: [👨👨👧] Now we can freeze `mappedParameters` to prevent
|
|
4615
|
+
// Note: [👨👨👧] Now we can freeze `mappedParameters` to prevent accidental modifications after mapping
|
|
4499
4616
|
Object.freeze(mappedParameters);
|
|
4500
4617
|
return mappedParameters;
|
|
4501
4618
|
}
|
|
@@ -4599,7 +4716,7 @@ function extractJsonBlock(markdown) {
|
|
|
4599
4716
|
}
|
|
4600
4717
|
/**
|
|
4601
4718
|
* TODO: Add some auto-healing logic + extract YAML, JSON5, TOML, etc.
|
|
4602
|
-
* TODO: [🏢] Make this logic part of `
|
|
4719
|
+
* TODO: [🏢] Make this logic part of `JsonFormatParser` or `isValidJsonString`
|
|
4603
4720
|
*/
|
|
4604
4721
|
|
|
4605
4722
|
/**
|
|
@@ -4642,10 +4759,12 @@ function templateParameters(template, parameters) {
|
|
|
4642
4759
|
throw new PipelineExecutionError('Parameter is already opened or not closed');
|
|
4643
4760
|
}
|
|
4644
4761
|
if (parameters[parameterName] === undefined) {
|
|
4762
|
+
console.log('!!! templateParameters 1', { parameterName, template, parameters });
|
|
4645
4763
|
throw new PipelineExecutionError(`Parameter \`{${parameterName}}\` is not defined`);
|
|
4646
4764
|
}
|
|
4647
4765
|
let parameterValue = parameters[parameterName];
|
|
4648
4766
|
if (parameterValue === undefined) {
|
|
4767
|
+
console.log('!!! templateParameters 2', { parameterName, template, parameters });
|
|
4649
4768
|
throw new PipelineExecutionError(`Parameter \`{${parameterName}}\` is not defined`);
|
|
4650
4769
|
}
|
|
4651
4770
|
parameterValue = valueToString(parameterValue);
|
|
@@ -4801,7 +4920,7 @@ const CountUtils = {
|
|
|
4801
4920
|
PAGES: countPages,
|
|
4802
4921
|
};
|
|
4803
4922
|
/**
|
|
4804
|
-
* TODO: [🧠][🤠] This should be probbably as part of `
|
|
4923
|
+
* TODO: [🧠][🤠] This should be probbably as part of `TextFormatParser`
|
|
4805
4924
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
4806
4925
|
*/
|
|
4807
4926
|
|
|
@@ -4829,13 +4948,17 @@ function checkExpectations(expectations, value) {
|
|
|
4829
4948
|
}
|
|
4830
4949
|
/**
|
|
4831
4950
|
* TODO: [💝] Unite object for expecting amount and format
|
|
4832
|
-
* TODO: [🧠][🤠] This should be part of `
|
|
4951
|
+
* TODO: [🧠][🤠] This should be part of `TextFormatParser`
|
|
4833
4952
|
* Note: [💝] and [🤠] are interconnected together
|
|
4834
4953
|
*/
|
|
4835
4954
|
|
|
4836
4955
|
/**
|
|
4837
|
-
*
|
|
4956
|
+
* Executes a pipeline task with multiple attempts, including joker and retry logic. Handles different task types
|
|
4957
|
+
* (prompt, script, dialog, etc.), applies postprocessing, checks expectations, and updates the execution report.
|
|
4958
|
+
* Throws errors if execution fails after all attempts.
|
|
4838
4959
|
*
|
|
4960
|
+
* @param options - The options for execution, including task, parameters, pipeline, and configuration.
|
|
4961
|
+
* @returns The result string of the executed task.
|
|
4839
4962
|
* @private internal utility of `createPipelineExecutor`
|
|
4840
4963
|
*/
|
|
4841
4964
|
async function executeAttempts(options) {
|
|
@@ -5057,7 +5180,7 @@ async function executeAttempts(options) {
|
|
|
5057
5180
|
if (task.format) {
|
|
5058
5181
|
if (task.format === 'JSON') {
|
|
5059
5182
|
if (!isValidJsonString($ongoingTaskResult.$resultString || '')) {
|
|
5060
|
-
// TODO: [🏢] Do more universally via `
|
|
5183
|
+
// TODO: [🏢] Do more universally via `FormatParser`
|
|
5061
5184
|
try {
|
|
5062
5185
|
$ongoingTaskResult.$resultString = extractJsonBlock($ongoingTaskResult.$resultString || '');
|
|
5063
5186
|
}
|
|
@@ -5159,12 +5282,16 @@ async function executeAttempts(options) {
|
|
|
5159
5282
|
*/
|
|
5160
5283
|
|
|
5161
5284
|
/**
|
|
5162
|
-
*
|
|
5285
|
+
* Executes a pipeline task that requires mapping or iterating over subvalues of a parameter (such as rows in a CSV).
|
|
5286
|
+
* Handles format and subformat resolution, error handling, and progress reporting.
|
|
5287
|
+
*
|
|
5288
|
+
* @param options - Options for execution, including task details and progress callback.
|
|
5289
|
+
* @returns The result of the subvalue mapping or execution attempts.
|
|
5163
5290
|
*
|
|
5164
5291
|
* @private internal utility of `createPipelineExecutor`
|
|
5165
5292
|
*/
|
|
5166
5293
|
async function executeFormatSubvalues(options) {
|
|
5167
|
-
const { task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification } = options;
|
|
5294
|
+
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
|
|
5168
5295
|
if (task.foreach === undefined) {
|
|
5169
5296
|
return /* not await */ executeAttempts(options);
|
|
5170
5297
|
}
|
|
@@ -5195,16 +5322,16 @@ async function executeFormatSubvalues(options) {
|
|
|
5195
5322
|
${block(pipelineIdentification)}
|
|
5196
5323
|
`));
|
|
5197
5324
|
}
|
|
5198
|
-
const
|
|
5199
|
-
if (
|
|
5325
|
+
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(task.foreach.subformatName));
|
|
5326
|
+
if (subvalueParser === undefined) {
|
|
5200
5327
|
throw new UnexpectedError(
|
|
5201
5328
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
5202
5329
|
spaceTrim$1((block) => `
|
|
5203
5330
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
5204
5331
|
|
|
5205
5332
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
5206
|
-
${block(formatDefinition.
|
|
5207
|
-
.map((
|
|
5333
|
+
${block(formatDefinition.subvalueParsers
|
|
5334
|
+
.map((subvalueParser) => subvalueParser.subvalueName)
|
|
5208
5335
|
.map((subvalueName) => `- ${subvalueName}`)
|
|
5209
5336
|
.join('\n'))}
|
|
5210
5337
|
|
|
@@ -5218,53 +5345,83 @@ async function executeFormatSubvalues(options) {
|
|
|
5218
5345
|
formatSettings = csvSettings;
|
|
5219
5346
|
// <- TODO: [🤹♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
5220
5347
|
}
|
|
5221
|
-
const resultString = await
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5348
|
+
const resultString = await subvalueParser.mapValues({
|
|
5349
|
+
value: parameterValue,
|
|
5350
|
+
outputParameterName: task.foreach.outputSubparameterName,
|
|
5351
|
+
settings: formatSettings,
|
|
5352
|
+
onProgress(partialResultString) {
|
|
5353
|
+
return onProgress(Object.freeze({
|
|
5354
|
+
[task.resultingParameterName]: partialResultString,
|
|
5355
|
+
}));
|
|
5356
|
+
},
|
|
5357
|
+
async mapCallback(subparameters, index, length) {
|
|
5358
|
+
let mappedParameters;
|
|
5359
|
+
try {
|
|
5360
|
+
mappedParameters = mapAvailableToExpectedParameters({
|
|
5361
|
+
expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map((subparameterName) => [subparameterName, null])),
|
|
5362
|
+
availableParameters: subparameters,
|
|
5363
|
+
});
|
|
5234
5364
|
}
|
|
5235
|
-
|
|
5236
|
-
|
|
5365
|
+
catch (error) {
|
|
5366
|
+
if (!(error instanceof PipelineExecutionError)) {
|
|
5367
|
+
throw error;
|
|
5368
|
+
}
|
|
5369
|
+
const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
|
|
5370
|
+
${error.message}
|
|
5237
5371
|
|
|
5238
|
-
|
|
5239
|
-
|
|
5372
|
+
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
5373
|
+
You have probbably passed wrong data to pipeline or wrong data was generated which are processed by FOREACH command
|
|
5240
5374
|
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5375
|
+
${block(pipelineIdentification)}
|
|
5376
|
+
`));
|
|
5377
|
+
if (length > BIG_DATASET_TRESHOLD) {
|
|
5378
|
+
console.error(highLevelError);
|
|
5379
|
+
return FAILED_VALUE_PLACEHOLDER;
|
|
5380
|
+
}
|
|
5381
|
+
throw highLevelError;
|
|
5382
|
+
}
|
|
5383
|
+
const allSubparameters = {
|
|
5384
|
+
...parameters,
|
|
5385
|
+
...mappedParameters,
|
|
5386
|
+
};
|
|
5387
|
+
Object.freeze(allSubparameters);
|
|
5388
|
+
try {
|
|
5389
|
+
const subresultString = await executeAttempts({
|
|
5390
|
+
...options,
|
|
5391
|
+
priority: priority + index,
|
|
5392
|
+
parameters: allSubparameters,
|
|
5393
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
5394
|
+
${block(pipelineIdentification)}
|
|
5395
|
+
Subparameter index: ${index}
|
|
5396
|
+
`),
|
|
5397
|
+
});
|
|
5398
|
+
return subresultString;
|
|
5399
|
+
}
|
|
5400
|
+
catch (error) {
|
|
5401
|
+
if (length > BIG_DATASET_TRESHOLD) {
|
|
5402
|
+
console.error(spaceTrim$1((block) => `
|
|
5403
|
+
${error.message}
|
|
5404
|
+
|
|
5405
|
+
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
5406
|
+
|
|
5407
|
+
${block(pipelineIdentification)}
|
|
5408
|
+
`));
|
|
5409
|
+
return FAILED_VALUE_PLACEHOLDER;
|
|
5410
|
+
}
|
|
5411
|
+
throw error;
|
|
5412
|
+
}
|
|
5413
|
+
},
|
|
5261
5414
|
});
|
|
5262
5415
|
return resultString;
|
|
5263
5416
|
}
|
|
5264
5417
|
|
|
5265
5418
|
/**
|
|
5266
|
-
*
|
|
5419
|
+
* Returns the context for a given task, typically used to provide additional information or variables
|
|
5420
|
+
* required for the execution of the task within a pipeline. The context is returned as a string value
|
|
5421
|
+
* that may include markdown formatting.
|
|
5267
5422
|
*
|
|
5423
|
+
* @param task - The task for which the context is being generated. This should be a deeply immutable TaskJson object.
|
|
5424
|
+
* @returns The context as a string, formatted as markdown and parameter value.
|
|
5268
5425
|
* @private internal utility of `createPipelineExecutor`
|
|
5269
5426
|
*/
|
|
5270
5427
|
async function getContextForTask(task) {
|
|
@@ -5272,7 +5429,7 @@ async function getContextForTask(task) {
|
|
|
5272
5429
|
}
|
|
5273
5430
|
|
|
5274
5431
|
/**
|
|
5275
|
-
*
|
|
5432
|
+
* Retrieves example values or templates for a given task, used to guide or validate pipeline execution.
|
|
5276
5433
|
*
|
|
5277
5434
|
* @private internal utility of `createPipelineExecutor`
|
|
5278
5435
|
*/
|
|
@@ -5281,25 +5438,127 @@ async function getExamplesForTask(task) {
|
|
|
5281
5438
|
}
|
|
5282
5439
|
|
|
5283
5440
|
/**
|
|
5284
|
-
*
|
|
5441
|
+
* Computes the cosine similarity between two embedding vectors
|
|
5442
|
+
*
|
|
5443
|
+
* Note: This is helping function for RAG (retrieval-augmented generation)
|
|
5444
|
+
*
|
|
5445
|
+
* @param embeddingVector1
|
|
5446
|
+
* @param embeddingVector2
|
|
5447
|
+
* @returns Cosine similarity between the two vectors
|
|
5448
|
+
*
|
|
5449
|
+
* @public exported from `@promptbook/core`
|
|
5450
|
+
*/
|
|
5451
|
+
function computeCosineSimilarity(embeddingVector1, embeddingVector2) {
|
|
5452
|
+
if (embeddingVector1.length !== embeddingVector2.length) {
|
|
5453
|
+
throw new TypeError('Embedding vectors must have the same length');
|
|
5454
|
+
}
|
|
5455
|
+
const dotProduct = embeddingVector1.reduce((sum, value, index) => sum + value * embeddingVector2[index], 0);
|
|
5456
|
+
const magnitude1 = Math.sqrt(embeddingVector1.reduce((sum, value) => sum + value * value, 0));
|
|
5457
|
+
const magnitude2 = Math.sqrt(embeddingVector2.reduce((sum, value) => sum + value * value, 0));
|
|
5458
|
+
return 1 - dotProduct / (magnitude1 * magnitude2);
|
|
5459
|
+
}
|
|
5460
|
+
|
|
5461
|
+
/**
|
|
5462
|
+
*
|
|
5463
|
+
* @param knowledgePieces
|
|
5464
|
+
* @returns
|
|
5465
|
+
*
|
|
5466
|
+
* @private internal utility of `createPipelineExecutor`
|
|
5467
|
+
*/
|
|
5468
|
+
function knowledgePiecesToString(knowledgePieces) {
|
|
5469
|
+
return knowledgePieces
|
|
5470
|
+
.map((knowledgePiece) => {
|
|
5471
|
+
const { content } = knowledgePiece;
|
|
5472
|
+
return `- ${content}`;
|
|
5473
|
+
})
|
|
5474
|
+
.join('\n');
|
|
5475
|
+
// <- TODO: [🧠] Some smarter aggregation of knowledge pieces, single-line vs multi-line vs mixed
|
|
5476
|
+
}
|
|
5477
|
+
|
|
5478
|
+
/**
|
|
5479
|
+
* Retrieves the most relevant knowledge pieces for a given task using embedding-based similarity search.
|
|
5480
|
+
* This is where retrieval-augmented generation (RAG) is performed to enhance the task with external knowledge.
|
|
5285
5481
|
*
|
|
5286
5482
|
* @private internal utility of `createPipelineExecutor`
|
|
5287
5483
|
*/
|
|
5288
5484
|
async function getKnowledgeForTask(options) {
|
|
5289
|
-
const { preparedPipeline, task } = options;
|
|
5290
|
-
|
|
5291
|
-
|
|
5485
|
+
const { tools, preparedPipeline, task, parameters } = options;
|
|
5486
|
+
const firstKnowlegePiece = preparedPipeline.knowledgePieces[0];
|
|
5487
|
+
const firstKnowlegeIndex = firstKnowlegePiece === null || firstKnowlegePiece === void 0 ? void 0 : firstKnowlegePiece.index[0];
|
|
5488
|
+
// <- TODO: Do not use just first knowledge piece and first index to determine embedding model, use also keyword search
|
|
5489
|
+
if (firstKnowlegePiece === undefined || firstKnowlegeIndex === undefined) {
|
|
5490
|
+
return ''; // <- Note: Np knowledge present, return empty string
|
|
5491
|
+
}
|
|
5492
|
+
try {
|
|
5493
|
+
// TODO: [🚐] Make arrayable LLMs -> single LLM DRY
|
|
5494
|
+
const _llms = arrayableToArray(tools.llm);
|
|
5495
|
+
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
5496
|
+
const taskEmbeddingPrompt = {
|
|
5497
|
+
title: 'Knowledge Search',
|
|
5498
|
+
modelRequirements: {
|
|
5499
|
+
modelVariant: 'EMBEDDING',
|
|
5500
|
+
modelName: firstKnowlegeIndex.modelName,
|
|
5501
|
+
},
|
|
5502
|
+
content: task.content,
|
|
5503
|
+
parameters,
|
|
5504
|
+
};
|
|
5505
|
+
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
5506
|
+
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
5507
|
+
const { index } = knowledgePiece;
|
|
5508
|
+
const knowledgePieceIndex = index.find((i) => i.modelName === firstKnowlegeIndex.modelName);
|
|
5509
|
+
// <- TODO: Do not use just first knowledge piece and first index to determine embedding model
|
|
5510
|
+
if (knowledgePieceIndex === undefined) {
|
|
5511
|
+
return {
|
|
5512
|
+
content: knowledgePiece.content,
|
|
5513
|
+
relevance: 0,
|
|
5514
|
+
};
|
|
5515
|
+
}
|
|
5516
|
+
const relevance = computeCosineSimilarity(knowledgePieceIndex.position, taskEmbeddingResult.content);
|
|
5517
|
+
return {
|
|
5518
|
+
content: knowledgePiece.content,
|
|
5519
|
+
relevance,
|
|
5520
|
+
};
|
|
5521
|
+
});
|
|
5522
|
+
const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
|
|
5523
|
+
const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
|
|
5524
|
+
console.log('!!! Embedding', {
|
|
5525
|
+
task,
|
|
5526
|
+
taskEmbeddingPrompt,
|
|
5527
|
+
taskEmbeddingResult,
|
|
5528
|
+
firstKnowlegePiece,
|
|
5529
|
+
firstKnowlegeIndex,
|
|
5530
|
+
knowledgePiecesWithRelevance,
|
|
5531
|
+
knowledgePiecesSorted,
|
|
5532
|
+
knowledgePiecesLimited,
|
|
5533
|
+
});
|
|
5534
|
+
return knowledgePiecesToString(knowledgePiecesLimited);
|
|
5535
|
+
}
|
|
5536
|
+
catch (error) {
|
|
5537
|
+
assertsError(error);
|
|
5538
|
+
console.error('Error in `getKnowledgeForTask`', error);
|
|
5539
|
+
// Note: If the LLM fails, just return all knowledge pieces
|
|
5540
|
+
return knowledgePiecesToString(preparedPipeline.knowledgePieces);
|
|
5541
|
+
}
|
|
5292
5542
|
}
|
|
5543
|
+
/**
|
|
5544
|
+
* TODO: !!!! Verify if this is working
|
|
5545
|
+
* TODO: [♨] Implement Better - use keyword search
|
|
5546
|
+
* TODO: [♨] Examples of values
|
|
5547
|
+
*/
|
|
5293
5548
|
|
|
5294
5549
|
/**
|
|
5295
|
-
*
|
|
5550
|
+
* Retrieves all reserved parameters for a given pipeline task, including context, knowledge, examples, and metadata.
|
|
5551
|
+
* Ensures all reserved parameters are defined and throws if any are missing.
|
|
5552
|
+
*
|
|
5553
|
+
* @param options - Options including tools, pipeline, task, and context.
|
|
5554
|
+
* @returns An object containing all reserved parameters for the task.
|
|
5296
5555
|
*
|
|
5297
5556
|
* @private internal utility of `createPipelineExecutor`
|
|
5298
5557
|
*/
|
|
5299
5558
|
async function getReservedParametersForTask(options) {
|
|
5300
|
-
const { preparedPipeline, task, pipelineIdentification } = options;
|
|
5559
|
+
const { tools, preparedPipeline, task, parameters, pipelineIdentification } = options;
|
|
5301
5560
|
const context = await getContextForTask(); // <- [🏍]
|
|
5302
|
-
const knowledge = await getKnowledgeForTask({ preparedPipeline, task });
|
|
5561
|
+
const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task, parameters });
|
|
5303
5562
|
const examples = await getExamplesForTask();
|
|
5304
5563
|
const currentDate = new Date().toISOString(); // <- TODO: [🧠][💩] Better
|
|
5305
5564
|
const modelName = RESERVED_PARAMETER_MISSING_VALUE;
|
|
@@ -5325,23 +5584,21 @@ async function getReservedParametersForTask(options) {
|
|
|
5325
5584
|
}
|
|
5326
5585
|
|
|
5327
5586
|
/**
|
|
5328
|
-
*
|
|
5587
|
+
* Executes a single task within a pipeline, handling parameter validation, error checking, and progress reporting.
|
|
5588
|
+
*
|
|
5589
|
+
* @param options - Options for execution, including the task, pipeline, parameters, and callbacks.
|
|
5590
|
+
* @returns The output parameters produced by the task.
|
|
5329
5591
|
*
|
|
5330
5592
|
* @private internal utility of `createPipelineExecutor`
|
|
5331
5593
|
*/
|
|
5332
5594
|
async function executeTask(options) {
|
|
5333
5595
|
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
|
|
5334
5596
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
5335
|
-
await onProgress({
|
|
5336
|
-
outputParameters: {
|
|
5337
|
-
[currentTask.resultingParameterName]: '', // <- TODO: [🧠] What is the best value here?
|
|
5338
|
-
},
|
|
5339
|
-
});
|
|
5340
5597
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
|
|
5341
5598
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
5342
5599
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
5343
5600
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
5344
|
-
if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
|
|
5601
|
+
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
5345
5602
|
throw new UnexpectedError(spaceTrim((block) => `
|
|
5346
5603
|
Dependent parameters are not consistent with used parameters:
|
|
5347
5604
|
|
|
@@ -5361,9 +5618,11 @@ async function executeTask(options) {
|
|
|
5361
5618
|
}
|
|
5362
5619
|
const definedParameters = Object.freeze({
|
|
5363
5620
|
...(await getReservedParametersForTask({
|
|
5621
|
+
tools,
|
|
5364
5622
|
preparedPipeline,
|
|
5365
5623
|
task: currentTask,
|
|
5366
5624
|
pipelineIdentification,
|
|
5625
|
+
parameters: parametersToPass,
|
|
5367
5626
|
})),
|
|
5368
5627
|
...parametersToPass,
|
|
5369
5628
|
});
|
|
@@ -5409,6 +5668,7 @@ async function executeTask(options) {
|
|
|
5409
5668
|
preparedPipeline,
|
|
5410
5669
|
tools,
|
|
5411
5670
|
$executionReport,
|
|
5671
|
+
onProgress,
|
|
5412
5672
|
pipelineIdentification,
|
|
5413
5673
|
maxExecutionAttempts,
|
|
5414
5674
|
maxParallelCount,
|
|
@@ -5436,7 +5696,8 @@ async function executeTask(options) {
|
|
|
5436
5696
|
*/
|
|
5437
5697
|
|
|
5438
5698
|
/**
|
|
5439
|
-
*
|
|
5699
|
+
* Filters and returns only the output parameters from the provided pipeline execution options.
|
|
5700
|
+
* Adds warnings for any expected output parameters that are missing.
|
|
5440
5701
|
*
|
|
5441
5702
|
* @private internal utility of `createPipelineExecutor`
|
|
5442
5703
|
*/
|
|
@@ -5461,9 +5722,12 @@ function filterJustOutputParameters(options) {
|
|
|
5461
5722
|
}
|
|
5462
5723
|
|
|
5463
5724
|
/**
|
|
5464
|
-
*
|
|
5725
|
+
* Executes an entire pipeline, resolving tasks in dependency order, handling errors, and reporting progress.
|
|
5465
5726
|
*
|
|
5466
|
-
* Note: This is not a `PipelineExecutor` (which is
|
|
5727
|
+
* Note: This is not a `PipelineExecutor` (which is bound to a single pipeline), but a utility function used by `createPipelineExecutor` to create a `PipelineExecutor`.
|
|
5728
|
+
*
|
|
5729
|
+
* @param options - Options for execution, including input parameters, pipeline, and callbacks.
|
|
5730
|
+
* @returns The result of the pipeline execution, including output parameters, errors, and usage statistics.
|
|
5467
5731
|
*
|
|
5468
5732
|
* @private internal utility of `createPipelineExecutor`
|
|
5469
5733
|
*/
|
|
@@ -5786,6 +6050,22 @@ function createPipelineExecutor(options) {
|
|
|
5786
6050
|
cacheDirname,
|
|
5787
6051
|
intermediateFilesStrategy,
|
|
5788
6052
|
isAutoInstalled,
|
|
6053
|
+
}).catch((error) => {
|
|
6054
|
+
assertsError(error);
|
|
6055
|
+
return exportJson({
|
|
6056
|
+
name: 'pipelineExecutorResult',
|
|
6057
|
+
message: `Unuccessful PipelineExecutorResult, last catch`,
|
|
6058
|
+
order: [],
|
|
6059
|
+
value: {
|
|
6060
|
+
isSuccessful: false,
|
|
6061
|
+
errors: [serializeError(error)],
|
|
6062
|
+
warnings: [],
|
|
6063
|
+
usage: UNCERTAIN_USAGE,
|
|
6064
|
+
executionReport: null,
|
|
6065
|
+
outputParameters: {},
|
|
6066
|
+
preparedPipeline,
|
|
6067
|
+
},
|
|
6068
|
+
});
|
|
5789
6069
|
});
|
|
5790
6070
|
};
|
|
5791
6071
|
const pipelineExecutor = (inputParameters) => createTask({
|
|
@@ -6270,7 +6550,8 @@ class LegacyDocumentScraper {
|
|
|
6270
6550
|
*/
|
|
6271
6551
|
|
|
6272
6552
|
/**
|
|
6273
|
-
*
|
|
6553
|
+
* Creates a scraper for legacy document formats (.doc, .rtf, etc).
|
|
6554
|
+
* Uses LibreOffice for conversion to extract content from older document formats.
|
|
6274
6555
|
*
|
|
6275
6556
|
* @public exported from `@promptbook/legacy-documents`
|
|
6276
6557
|
*/
|