@promptbook/core 0.72.0-9 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -8
- package/esm/index.es.js +119 -127
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +24 -18
- package/esm/typings/src/_packages/node.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +18 -12
- package/esm/typings/src/_packages/utils.index.d.ts +2 -2
- package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
- package/esm/typings/src/collection/SimplePipelineCollection.d.ts +2 -2
- package/esm/typings/src/collection/collectionToJson.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromPromise.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +5 -5
- package/esm/typings/src/config.d.ts +21 -14
- package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +12 -0
- package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +11 -0
- package/esm/typings/src/executables/apps/locatePandoc.d.ts +11 -0
- package/esm/typings/src/executables/locateApp.d.ts +33 -0
- package/esm/typings/src/executables/locateApp.test.d.ts +1 -0
- package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +12 -0
- package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +12 -0
- package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +12 -0
- package/esm/typings/src/execution/EmbeddingVector.d.ts +1 -1
- package/esm/typings/src/execution/Executables.d.ts +18 -0
- package/esm/typings/src/execution/ExecutionTools.d.ts +9 -3
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +2 -2
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
- package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +3 -2
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +29 -6
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -11
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +4 -13
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +9 -14
- package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +11 -3
- package/esm/typings/src/execution/utils/addUsage.d.ts +1 -1
- package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -1
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +2 -2
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForCli.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +7 -0
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +4 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +2 -1
- package/esm/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +4 -5
- package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +0 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +4 -4
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Request.d.ts +15 -6
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Response.d.ts +4 -4
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Request.d.ts +6 -12
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Response.d.ts +3 -3
- package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +9 -14
- package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +23 -8
- package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +4 -23
- package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/Scraper.d.ts +2 -9
- package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +2 -2
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +2 -2
- package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +2 -2
- package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +2 -2
- package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
- package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +2 -2
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -1
- package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +3 -3
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -1
- package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -1
- package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +2 -2
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -1
- package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +6 -3
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -1
- package/esm/typings/src/scrapers/website/utils/createShowdownConverter.d.ts +7 -0
- package/esm/typings/src/scrapers/website/utils/createShowdownConverter.test.d.ts +1 -0
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
- package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +1 -1
- package/esm/typings/src/types/Arrayable.d.ts +1 -1
- package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +7 -0
- package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +4 -4
- package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +2 -2
- package/esm/typings/src/types/Prompt.d.ts +2 -1
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +11 -8
- package/esm/typings/src/utils/$Register.d.ts +1 -1
- package/esm/typings/src/utils/FromtoItems.d.ts +1 -1
- package/esm/typings/src/utils/arrayableToArray.d.ts +1 -1
- package/esm/typings/src/utils/emojis.d.ts +1 -1
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +4 -2
- package/esm/typings/src/utils/execCommand/$execCommandNormalizeOptions.d.ts +12 -0
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +1 -0
- package/esm/typings/src/utils/execCommand/ExecCommandOptions.d.ts +45 -0
- package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
- package/esm/typings/src/utils/files/isExecutable.d.ts +11 -0
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
- package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +1 -1
- package/esm/typings/src/utils/normalization/IKeywords.d.ts +2 -2
- package/esm/typings/src/utils/normalization/parseKeywords.d.ts +2 -2
- package/esm/typings/src/utils/normalization/parseKeywordsFromString.d.ts +2 -2
- package/esm/typings/src/utils/normalization/searchKeywords.d.ts +2 -2
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +1 -1
- package/esm/typings/src/utils/organization/keepUnused.d.ts +1 -1
- package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
- package/esm/typings/src/utils/sets/intersection.d.ts +1 -1
- package/esm/typings/src/utils/sets/union.d.ts +1 -1
- package/esm/typings/src/utils/unwrapResult.d.ts +4 -4
- package/package.json +3 -2
- package/umd/index.umd.js +130 -135
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +0 -29
- package/esm/typings/src/scrapers/website/utils/markdownConverter.d.ts +0 -12
- package/esm/typings/src/utils/execCommand/IExecCommandOptions.d.ts +0 -23
- package/esm/typings/src/utils/execCommand/execCommandNormalizeOptions.d.ts +0 -10
- /package/esm/typings/src/{scrapers/website/WebsiteScraper.test.d.ts → executables/apps/locateLibreoffice.test.d.ts} +0 -0
- /package/esm/typings/src/{scrapers/website/utils/markdownConverter.test.d.ts → executables/apps/locatePandoc.test.d.ts} +0 -0
package/umd/index.umd.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
/**
|
|
17
17
|
* The version of the Promptbook library
|
|
18
18
|
*/
|
|
19
|
-
var PROMPTBOOK_VERSION = '0.72.0-
|
|
19
|
+
var PROMPTBOOK_VERSION = '0.72.0-34';
|
|
20
20
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
21
21
|
|
|
22
22
|
/*! *****************************************************************************
|
|
@@ -223,7 +223,6 @@
|
|
|
223
223
|
pipelineString += '\n\n';
|
|
224
224
|
pipelineString += description;
|
|
225
225
|
}
|
|
226
|
-
// TODO:> const commands: Array<Command>
|
|
227
226
|
var commands = [];
|
|
228
227
|
if (pipelineUrl) {
|
|
229
228
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
@@ -279,7 +278,6 @@
|
|
|
279
278
|
pipelineString += '\n\n';
|
|
280
279
|
pipelineString += description_1;
|
|
281
280
|
}
|
|
282
|
-
// TODO:> const commands: Array<Command>
|
|
283
281
|
var commands_1 = [];
|
|
284
282
|
var contentLanguage = 'text';
|
|
285
283
|
if (templateType === 'PROMPT_TEMPLATE') {
|
|
@@ -639,7 +637,7 @@
|
|
|
639
637
|
*
|
|
640
638
|
* @public exported from `@promptbook/core`
|
|
641
639
|
*/
|
|
642
|
-
var CLAIM = "
|
|
640
|
+
var CLAIM = "Build responsible, controlled and transparent applications on top of LLM models!";
|
|
643
641
|
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
644
642
|
/**
|
|
645
643
|
* The maximum number of iterations for a loops
|
|
@@ -654,37 +652,44 @@
|
|
|
654
652
|
*/
|
|
655
653
|
var IMMEDIATE_TIME = 10;
|
|
656
654
|
/**
|
|
657
|
-
* The maximum
|
|
655
|
+
* The maximum length of the (generated) filename
|
|
658
656
|
*
|
|
659
657
|
* @public exported from `@promptbook/core`
|
|
660
658
|
*/
|
|
661
|
-
var
|
|
659
|
+
var MAX_FILENAME_LENGTH = 30;
|
|
662
660
|
/**
|
|
663
|
-
*
|
|
661
|
+
* Strategy for caching the intermediate results for knowledge sources
|
|
664
662
|
*
|
|
665
663
|
* @public exported from `@promptbook/core`
|
|
666
664
|
*/
|
|
667
|
-
var
|
|
665
|
+
var DEFAULT_INTERMEDIATE_FILES_STRATEGY = 'HIDE_AND_KEEP';
|
|
666
|
+
// <- TODO: [😡] Change to 'VISIBLE'
|
|
668
667
|
/**
|
|
669
|
-
* The maximum
|
|
668
|
+
* The maximum number of (LLM) tasks running in parallel
|
|
670
669
|
*
|
|
671
670
|
* @public exported from `@promptbook/core`
|
|
672
671
|
*/
|
|
673
|
-
var
|
|
672
|
+
var DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹♂️]
|
|
673
|
+
/**
|
|
674
|
+
* The maximum number of attempts to execute LLM task before giving up
|
|
675
|
+
*
|
|
676
|
+
* @public exported from `@promptbook/core`
|
|
677
|
+
*/
|
|
678
|
+
var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹♂️]
|
|
674
679
|
/**
|
|
675
680
|
* @@@
|
|
676
681
|
* TODO: [🐝][main] !!! Use
|
|
677
682
|
*
|
|
678
683
|
* @public exported from `@promptbook/core`
|
|
679
684
|
*/
|
|
680
|
-
var
|
|
685
|
+
var DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = 3;
|
|
681
686
|
/**
|
|
682
687
|
* @@@
|
|
683
688
|
* TODO: [🐝][main] !!! Use
|
|
684
689
|
*
|
|
685
690
|
* @public exported from `@promptbook/core`
|
|
686
691
|
*/
|
|
687
|
-
var
|
|
692
|
+
var DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = 200;
|
|
688
693
|
/**
|
|
689
694
|
* Where to store the cache of executions for promptbook CLI
|
|
690
695
|
*
|
|
@@ -692,7 +697,7 @@
|
|
|
692
697
|
*
|
|
693
698
|
* @public exported from `@promptbook/core`
|
|
694
699
|
*/
|
|
695
|
-
var
|
|
700
|
+
var DEFAULT_EXECUTIONS_CACHE_DIRNAME = '/.promptbook/executions-cache';
|
|
696
701
|
/**
|
|
697
702
|
* Where to store the scrape cache
|
|
698
703
|
*
|
|
@@ -700,13 +705,13 @@
|
|
|
700
705
|
*
|
|
701
706
|
* @public exported from `@promptbook/core`
|
|
702
707
|
*/
|
|
703
|
-
var
|
|
708
|
+
var DEFAULT_SCRAPE_CACHE_DIRNAME = '/.promptbook/scrape-cache';
|
|
704
709
|
/**
|
|
705
710
|
* The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
|
|
706
711
|
*
|
|
707
712
|
* @public exported from `@promptbook/core`
|
|
708
713
|
*/
|
|
709
|
-
var
|
|
714
|
+
var DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = "index";
|
|
710
715
|
/**
|
|
711
716
|
* Nonce which is used for replacing things in strings
|
|
712
717
|
*
|
|
@@ -779,13 +784,13 @@
|
|
|
779
784
|
*
|
|
780
785
|
* @public exported from `@promptbook/core`
|
|
781
786
|
*/
|
|
782
|
-
var
|
|
787
|
+
var DEFAULT_IS_VERBOSE = false;
|
|
783
788
|
/**
|
|
784
789
|
* @@@
|
|
785
790
|
*
|
|
786
791
|
* @public exported from `@promptbook/core`
|
|
787
792
|
*/
|
|
788
|
-
var
|
|
793
|
+
var DEFAULT_IS_AUTO_INSTALLED = false;
|
|
789
794
|
/**
|
|
790
795
|
* @@@
|
|
791
796
|
*
|
|
@@ -1534,7 +1539,7 @@
|
|
|
1534
1539
|
return __generator(this, function (_d) {
|
|
1535
1540
|
switch (_d.label) {
|
|
1536
1541
|
case 0:
|
|
1537
|
-
_a = options || {}, _b = _a.isVerbose, isVerbose = _b === void 0 ?
|
|
1542
|
+
_a = options || {}, _b = _a.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b, _c = _a.isLazyLoaded, isLazyLoaded = _c === void 0 ? false : _c;
|
|
1538
1543
|
collection = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1539
1544
|
return __generator(this, function (_a) {
|
|
1540
1545
|
if (isVerbose) {
|
|
@@ -1820,8 +1825,7 @@
|
|
|
1820
1825
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
1821
1826
|
*
|
|
1822
1827
|
* Note: Internal utility of `joinLlmExecutionTools` but exposed type
|
|
1823
|
-
* @public exported from `@promptbook/
|
|
1824
|
-
* TODO: !!!!!! Export as runtime class not just type
|
|
1828
|
+
* @public exported from `@promptbook/core`
|
|
1825
1829
|
*/
|
|
1826
1830
|
var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
1827
1831
|
/**
|
|
@@ -2437,6 +2441,7 @@
|
|
|
2437
2441
|
}
|
|
2438
2442
|
}
|
|
2439
2443
|
/**
|
|
2444
|
+
* TODO: [🐚] This function should be removed OR changed OR be completely rewritten
|
|
2440
2445
|
* TODO: [🧠] Can this return type be better typed than void
|
|
2441
2446
|
*/
|
|
2442
2447
|
|
|
@@ -3765,12 +3770,11 @@
|
|
|
3765
3770
|
*/
|
|
3766
3771
|
function executeAttempts(options) {
|
|
3767
3772
|
return __awaiter(this, void 0, void 0, function () {
|
|
3768
|
-
var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools,
|
|
3773
|
+
var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
|
|
3769
3774
|
return __generator(this, function (_a) {
|
|
3770
3775
|
switch (_a.label) {
|
|
3771
3776
|
case 0:
|
|
3772
|
-
jokerParameterNames = options.jokerParameterNames, priority = options.priority, maxAttempts = options.maxAttempts, preparedContent = options.preparedContent, parameters = options.parameters, template = options.template, preparedPipeline = options.preparedPipeline, tools = options.tools,
|
|
3773
|
-
maxExecutionAttempts = settings.maxExecutionAttempts;
|
|
3777
|
+
jokerParameterNames = options.jokerParameterNames, priority = options.priority, maxAttempts = options.maxAttempts, preparedContent = options.preparedContent, parameters = options.parameters, template = options.template, preparedPipeline = options.preparedPipeline, tools = options.tools, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, maxExecutionAttempts = options.maxExecutionAttempts;
|
|
3774
3778
|
$ongoingTemplateResult = {
|
|
3775
3779
|
$result: null,
|
|
3776
3780
|
$resultString: null,
|
|
@@ -4136,12 +4140,12 @@
|
|
|
4136
4140
|
*/
|
|
4137
4141
|
function executeFormatSubvalues(options) {
|
|
4138
4142
|
return __awaiter(this, void 0, void 0, function () {
|
|
4139
|
-
var template, jokerParameterNames, parameters, priority,
|
|
4143
|
+
var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
|
|
4140
4144
|
var _this = this;
|
|
4141
4145
|
return __generator(this, function (_a) {
|
|
4142
4146
|
switch (_a.label) {
|
|
4143
4147
|
case 0:
|
|
4144
|
-
template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority,
|
|
4148
|
+
template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
|
|
4145
4149
|
if (template.foreach === undefined) {
|
|
4146
4150
|
return [2 /*return*/, /* not await */ executeAttempts(options)];
|
|
4147
4151
|
}
|
|
@@ -4171,7 +4175,7 @@
|
|
|
4171
4175
|
.join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4172
4176
|
}
|
|
4173
4177
|
if (formatDefinition.formatName === 'CSV') {
|
|
4174
|
-
formatSettings =
|
|
4178
|
+
formatSettings = csvSettings;
|
|
4175
4179
|
// <- TODO: [🤹♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
4176
4180
|
}
|
|
4177
4181
|
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -4324,13 +4328,12 @@
|
|
|
4324
4328
|
*/
|
|
4325
4329
|
function executeTemplate(options) {
|
|
4326
4330
|
return __awaiter(this, void 0, void 0, function () {
|
|
4327
|
-
var currentTemplate, preparedPipeline, parametersToPass, tools, onProgress,
|
|
4328
|
-
var e_1,
|
|
4329
|
-
return __generator(this, function (
|
|
4330
|
-
switch (
|
|
4331
|
+
var currentTemplate, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, _a, maxExecutionAttempts, name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _b, _c, _d, definedParameterNames, parameters, _loop_1, _e, _f, parameterName, maxAttempts, jokerParameterNames, preparedContent, resultString;
|
|
4332
|
+
var e_1, _g, _h;
|
|
4333
|
+
return __generator(this, function (_j) {
|
|
4334
|
+
switch (_j.label) {
|
|
4331
4335
|
case 0:
|
|
4332
|
-
currentTemplate = options.currentTemplate, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress,
|
|
4333
|
-
maxExecutionAttempts = settings.maxExecutionAttempts;
|
|
4336
|
+
currentTemplate = options.currentTemplate, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, _a = options.maxExecutionAttempts, maxExecutionAttempts = _a === void 0 ? DEFAULT_MAX_EXECUTION_ATTEMPTS : _a;
|
|
4334
4337
|
name = "pipeline-executor-frame-".concat(currentTemplate.name);
|
|
4335
4338
|
title = currentTemplate.title;
|
|
4336
4339
|
priority = preparedPipeline.templates.length - preparedPipeline.templates.indexOf(currentTemplate);
|
|
@@ -4345,7 +4348,7 @@
|
|
|
4345
4348
|
// <- [🍸]
|
|
4346
4349
|
})];
|
|
4347
4350
|
case 1:
|
|
4348
|
-
|
|
4351
|
+
_j.sent();
|
|
4349
4352
|
usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
|
|
4350
4353
|
dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
|
|
4351
4354
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
@@ -4356,15 +4359,15 @@
|
|
|
4356
4359
|
.map(function (name) { return "{".concat(name, "}"); })
|
|
4357
4360
|
.join(', '), "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
4358
4361
|
}
|
|
4359
|
-
|
|
4360
|
-
|
|
4362
|
+
_c = (_b = Object).freeze;
|
|
4363
|
+
_d = [{}];
|
|
4361
4364
|
return [4 /*yield*/, getReservedParametersForTemplate({
|
|
4362
4365
|
preparedPipeline: preparedPipeline,
|
|
4363
4366
|
template: currentTemplate,
|
|
4364
4367
|
pipelineIdentification: pipelineIdentification,
|
|
4365
4368
|
})];
|
|
4366
4369
|
case 2:
|
|
4367
|
-
definedParameters =
|
|
4370
|
+
definedParameters = _c.apply(_b, [__assign.apply(void 0, [__assign.apply(void 0, _d.concat([(_j.sent())])), parametersToPass])]);
|
|
4368
4371
|
definedParameterNames = new Set(Object.keys(definedParameters));
|
|
4369
4372
|
parameters = {};
|
|
4370
4373
|
_loop_1 = function (parameterName) {
|
|
@@ -4384,15 +4387,15 @@
|
|
|
4384
4387
|
try {
|
|
4385
4388
|
// Note: [2] Check that all used parameters are defined and removing unused parameters for this template
|
|
4386
4389
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
4387
|
-
for (
|
|
4388
|
-
parameterName =
|
|
4390
|
+
for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
4391
|
+
parameterName = _f.value;
|
|
4389
4392
|
_loop_1(parameterName);
|
|
4390
4393
|
}
|
|
4391
4394
|
}
|
|
4392
4395
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4393
4396
|
finally {
|
|
4394
4397
|
try {
|
|
4395
|
-
if (
|
|
4398
|
+
if (_f && !_f.done && (_g = _e.return)) _g.call(_e);
|
|
4396
4399
|
}
|
|
4397
4400
|
finally { if (e_1) throw e_1.error; }
|
|
4398
4401
|
}
|
|
@@ -4412,12 +4415,11 @@
|
|
|
4412
4415
|
template: currentTemplate,
|
|
4413
4416
|
preparedPipeline: preparedPipeline,
|
|
4414
4417
|
tools: tools,
|
|
4415
|
-
settings: settings,
|
|
4416
4418
|
$executionReport: $executionReport,
|
|
4417
4419
|
pipelineIdentification: pipelineIdentification,
|
|
4418
4420
|
})];
|
|
4419
4421
|
case 3:
|
|
4420
|
-
resultString =
|
|
4422
|
+
resultString = _j.sent();
|
|
4421
4423
|
return [4 /*yield*/, onProgress({
|
|
4422
4424
|
name: name,
|
|
4423
4425
|
title: title,
|
|
@@ -4429,12 +4431,12 @@
|
|
|
4429
4431
|
// <- [🍸]
|
|
4430
4432
|
})];
|
|
4431
4433
|
case 4:
|
|
4432
|
-
|
|
4433
|
-
return [2 /*return*/, Object.freeze((
|
|
4434
|
-
|
|
4434
|
+
_j.sent();
|
|
4435
|
+
return [2 /*return*/, Object.freeze((_h = {},
|
|
4436
|
+
_h[currentTemplate.resultingParameterName] =
|
|
4435
4437
|
// <- Note: [👩👩👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
4436
4438
|
resultString,
|
|
4437
|
-
|
|
4439
|
+
_h))];
|
|
4438
4440
|
}
|
|
4439
4441
|
});
|
|
4440
4442
|
});
|
|
@@ -4493,13 +4495,12 @@
|
|
|
4493
4495
|
*/
|
|
4494
4496
|
function executePipeline(options) {
|
|
4495
4497
|
return __awaiter(this, void 0, void 0, function () {
|
|
4496
|
-
var inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification,
|
|
4498
|
+
var inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, _a, isVerbose, preparedPipeline, errors, warnings, executionReport, isReturned, _b, _c, parameter, e_1_1, _loop_1, _d, _e, parameterName, state_1, e_2_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
|
|
4497
4499
|
var e_1, _f, e_2, _g;
|
|
4498
4500
|
return __generator(this, function (_h) {
|
|
4499
4501
|
switch (_h.label) {
|
|
4500
4502
|
case 0:
|
|
4501
|
-
inputParameters = options.inputParameters, tools = options.tools, onProgress = options.onProgress, pipeline = options.pipeline, setPreparedPipeline = options.setPreparedPipeline, pipelineIdentification = options.pipelineIdentification,
|
|
4502
|
-
maxParallelCount = settings.maxParallelCount, rootDirname = settings.rootDirname, _a = settings.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
|
|
4503
|
+
inputParameters = options.inputParameters, tools = options.tools, onProgress = options.onProgress, pipeline = options.pipeline, setPreparedPipeline = options.setPreparedPipeline, pipelineIdentification = options.pipelineIdentification, maxParallelCount = options.maxParallelCount, rootDirname = options.rootDirname, _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
4503
4504
|
preparedPipeline = options.preparedPipeline;
|
|
4504
4505
|
if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
|
|
4505
4506
|
return [4 /*yield*/, preparePipeline(pipeline, tools, {
|
|
@@ -4684,12 +4685,7 @@
|
|
|
4684
4685
|
return [3 /*break*/, 4];
|
|
4685
4686
|
case 3:
|
|
4686
4687
|
unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
|
|
4687
|
-
work_1 = executeTemplate({
|
|
4688
|
-
currentTemplate: currentTemplate,
|
|
4689
|
-
preparedPipeline: preparedPipeline,
|
|
4690
|
-
parametersToPass: parametersToPass,
|
|
4691
|
-
tools: tools,
|
|
4692
|
-
onProgress: function (progress) {
|
|
4688
|
+
work_1 = executeTemplate(__assign(__assign({}, options), { currentTemplate: currentTemplate, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
|
|
4693
4689
|
if (isReturned) {
|
|
4694
4690
|
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress, null, 4)
|
|
4695
4691
|
.split('\n')
|
|
@@ -4699,11 +4695,7 @@
|
|
|
4699
4695
|
if (onProgress) {
|
|
4700
4696
|
onProgress(progress);
|
|
4701
4697
|
}
|
|
4702
|
-
},
|
|
4703
|
-
settings: settings,
|
|
4704
|
-
$executionReport: executionReport,
|
|
4705
|
-
pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }),
|
|
4706
|
-
})
|
|
4698
|
+
}, $executionReport: executionReport, pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }) }))
|
|
4707
4699
|
.then(function (newParametersToPass) {
|
|
4708
4700
|
parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
|
|
4709
4701
|
resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
|
|
@@ -4807,8 +4799,7 @@
|
|
|
4807
4799
|
*/
|
|
4808
4800
|
function createPipelineExecutor(options) {
|
|
4809
4801
|
var _this = this;
|
|
4810
|
-
var pipeline = options.pipeline, tools = options.tools, _a = options.
|
|
4811
|
-
var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? MAX_EXECUTION_ATTEMPTS : _b, _c = settings.maxParallelCount, maxParallelCount = _c === void 0 ? MAX_PARALLEL_COUNT : _c, _d = settings.csvSettings, csvSettings = _d === void 0 ? DEFAULT_CSV_SETTINGS : _d, _e = settings.isVerbose, isVerbose = _e === void 0 ? IS_VERBOSE : _e, _f = settings.isNotPreparedWarningSupressed, isNotPreparedWarningSupressed = _f === void 0 ? false : _f, _g = settings.rootDirname, rootDirname = _g === void 0 ? null : _g;
|
|
4802
|
+
var pipeline = options.pipeline, tools = options.tools, _a = options.maxExecutionAttempts, maxExecutionAttempts = _a === void 0 ? DEFAULT_MAX_EXECUTION_ATTEMPTS : _a, _b = options.maxParallelCount, maxParallelCount = _b === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _b, _c = options.csvSettings, csvSettings = _c === void 0 ? DEFAULT_CSV_SETTINGS : _c, _d = options.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d, _e = options.isNotPreparedWarningSupressed, isNotPreparedWarningSupressed = _e === void 0 ? false : _e, _f = options.rootDirname, rootDirname = _f === void 0 ? null : _f;
|
|
4812
4803
|
validatePipeline(pipeline);
|
|
4813
4804
|
var pipelineIdentification = (function () {
|
|
4814
4805
|
// Note: This is a 😐 implementation of [🚞]
|
|
@@ -4842,14 +4833,12 @@
|
|
|
4842
4833
|
tools: tools,
|
|
4843
4834
|
onProgress: onProgress,
|
|
4844
4835
|
pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n ").concat(runCount === 1 ? '' : "Run #".concat(runCount), "\n "); }),
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
rootDirname: rootDirname,
|
|
4852
|
-
},
|
|
4836
|
+
maxExecutionAttempts: maxExecutionAttempts,
|
|
4837
|
+
maxParallelCount: maxParallelCount,
|
|
4838
|
+
csvSettings: csvSettings,
|
|
4839
|
+
isVerbose: isVerbose,
|
|
4840
|
+
isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
|
|
4841
|
+
rootDirname: rootDirname,
|
|
4853
4842
|
})];
|
|
4854
4843
|
});
|
|
4855
4844
|
}); };
|
|
@@ -4872,7 +4861,7 @@
|
|
|
4872
4861
|
return __generator(this, function (_d) {
|
|
4873
4862
|
switch (_d.label) {
|
|
4874
4863
|
case 0:
|
|
4875
|
-
_a = options.isVerbose, isVerbose = _a === void 0 ?
|
|
4864
|
+
_a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
4876
4865
|
if (tools === undefined || tools.llm === undefined) {
|
|
4877
4866
|
throw new MissingToolsError('LLM tools are required for preparing persona');
|
|
4878
4867
|
}
|
|
@@ -5054,7 +5043,7 @@
|
|
|
5054
5043
|
this.storage = globalScope[storageName];
|
|
5055
5044
|
}
|
|
5056
5045
|
$Register.prototype.list = function () {
|
|
5057
|
-
// <- TODO: ReadonlyDeep<
|
|
5046
|
+
// <- TODO: ReadonlyDeep<ReadonlyArray<TRegistered>>
|
|
5058
5047
|
return this.storage;
|
|
5059
5048
|
};
|
|
5060
5049
|
$Register.prototype.register = function (registered) {
|
|
@@ -5106,7 +5095,6 @@
|
|
|
5106
5095
|
* TODO: [®] DRY Register logic
|
|
5107
5096
|
*/
|
|
5108
5097
|
|
|
5109
|
-
// TODO: !!!!!! Maybe delete this function
|
|
5110
5098
|
/**
|
|
5111
5099
|
* Creates a message with all registered scrapers
|
|
5112
5100
|
*
|
|
@@ -5273,7 +5261,6 @@
|
|
|
5273
5261
|
* @private within the repository
|
|
5274
5262
|
*/
|
|
5275
5263
|
function sourceContentToName(sourceContent) {
|
|
5276
|
-
// TODO: !!!!!! Better name for source than gibberish hash
|
|
5277
5264
|
var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(sourceContent)))
|
|
5278
5265
|
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
5279
5266
|
.toString( /* hex */)
|
|
@@ -5373,20 +5360,20 @@
|
|
|
5373
5360
|
/**
|
|
5374
5361
|
* @@@
|
|
5375
5362
|
*
|
|
5376
|
-
* @
|
|
5363
|
+
* @public exported from `@promptbook/core`
|
|
5377
5364
|
*/
|
|
5378
5365
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
5379
5366
|
var _a;
|
|
5380
5367
|
return __awaiter(this, void 0, void 0, function () {
|
|
5381
5368
|
var sourceContent, name, _b, _c, rootDirname, _d,
|
|
5382
5369
|
// <- TODO: process.cwd() if running in Node.js
|
|
5383
|
-
isVerbose, url, response_1, mimeType, filename_1, fileExtension,
|
|
5370
|
+
isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
5384
5371
|
return __generator(this, function (_e) {
|
|
5385
5372
|
switch (_e.label) {
|
|
5386
5373
|
case 0:
|
|
5387
5374
|
sourceContent = knowledgeSource.sourceContent;
|
|
5388
5375
|
name = knowledgeSource.name;
|
|
5389
|
-
_b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ?
|
|
5376
|
+
_b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d;
|
|
5390
5377
|
TODO_USE(isVerbose);
|
|
5391
5378
|
if (!name) {
|
|
5392
5379
|
name = sourceContentToName(sourceContent);
|
|
@@ -5402,19 +5389,14 @@
|
|
|
5402
5389
|
filename: null,
|
|
5403
5390
|
url: url,
|
|
5404
5391
|
mimeType: mimeType,
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
return [2 /*return*/, content];
|
|
5414
|
-
}
|
|
5415
|
-
});
|
|
5416
|
-
});
|
|
5417
|
-
},
|
|
5392
|
+
/*
|
|
5393
|
+
TODO: [🥽]
|
|
5394
|
+
> async asBlob() {
|
|
5395
|
+
> // TODO: [👨🏻🤝👨🏻] This can be called multiple times BUT when called second time, response in already consumed
|
|
5396
|
+
> const content = await response.blob();
|
|
5397
|
+
> return content;
|
|
5398
|
+
> },
|
|
5399
|
+
*/
|
|
5418
5400
|
asJson: function () {
|
|
5419
5401
|
return __awaiter(this, void 0, void 0, function () {
|
|
5420
5402
|
var content;
|
|
@@ -5454,34 +5436,31 @@
|
|
|
5454
5436
|
}
|
|
5455
5437
|
filename_1 = path.join(rootDirname, sourceContent).split('\\').join('/');
|
|
5456
5438
|
fileExtension = getFileExtension(filename_1);
|
|
5457
|
-
|
|
5439
|
+
mimeType = extensionToMimeType(fileExtension || '');
|
|
5458
5440
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
5459
5441
|
case 3:
|
|
5460
5442
|
if (!(_e.sent())) {
|
|
5461
5443
|
throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
|
|
5462
5444
|
}
|
|
5463
|
-
// TODO:
|
|
5445
|
+
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
5464
5446
|
return [2 /*return*/, {
|
|
5465
5447
|
source: name,
|
|
5466
5448
|
filename: filename_1,
|
|
5467
5449
|
url: null,
|
|
5468
|
-
mimeType:
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
});
|
|
5483
|
-
});
|
|
5484
|
-
},
|
|
5450
|
+
mimeType: mimeType,
|
|
5451
|
+
/*
|
|
5452
|
+
TODO: [🥽]
|
|
5453
|
+
> async asBlob() {
|
|
5454
|
+
> const content = await tools.fs!.readFile(filename);
|
|
5455
|
+
> return new Blob(
|
|
5456
|
+
> [
|
|
5457
|
+
> content,
|
|
5458
|
+
> // <- TODO: [🥽] This is NOT tested, test it
|
|
5459
|
+
> ],
|
|
5460
|
+
> { type: mimeType },
|
|
5461
|
+
> );
|
|
5462
|
+
> },
|
|
5463
|
+
*/
|
|
5485
5464
|
asJson: function () {
|
|
5486
5465
|
return __awaiter(this, void 0, void 0, function () {
|
|
5487
5466
|
var _a, _b;
|
|
@@ -5517,9 +5496,14 @@
|
|
|
5517
5496
|
asJson: function () {
|
|
5518
5497
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
5519
5498
|
},
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5499
|
+
/*
|
|
5500
|
+
TODO: [🥽]
|
|
5501
|
+
> asBlob() {
|
|
5502
|
+
> throw new UnexpectedError(
|
|
5503
|
+
> 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
|
|
5504
|
+
> );
|
|
5505
|
+
> },
|
|
5506
|
+
*/
|
|
5523
5507
|
}];
|
|
5524
5508
|
}
|
|
5525
5509
|
});
|
|
@@ -5539,7 +5523,7 @@
|
|
|
5539
5523
|
return __generator(this, function (_c) {
|
|
5540
5524
|
switch (_c.label) {
|
|
5541
5525
|
case 0:
|
|
5542
|
-
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ?
|
|
5526
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a, rootDirname = options.rootDirname, _b = options.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b;
|
|
5543
5527
|
knowledgePreparedUnflatten = new Array(knowledgeSources.length);
|
|
5544
5528
|
return [4 /*yield*/, forEachAsync(knowledgeSources, { maxParallelCount: maxParallelCount }, function (knowledgeSource, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
5545
5529
|
var partialPieces, sourceHandler, _a, _b, scraper, partialPiecesUnchecked, e_1_1, pieces;
|
|
@@ -5568,7 +5552,8 @@
|
|
|
5568
5552
|
case 4:
|
|
5569
5553
|
partialPiecesUnchecked = _d.sent();
|
|
5570
5554
|
if (partialPiecesUnchecked !== null) {
|
|
5571
|
-
partialPieces = partialPiecesUnchecked;
|
|
5555
|
+
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
5556
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
5572
5557
|
return [3 /*break*/, 6];
|
|
5573
5558
|
}
|
|
5574
5559
|
_d.label = 5;
|
|
@@ -5616,7 +5601,7 @@
|
|
|
5616
5601
|
> /**
|
|
5617
5602
|
> * Unprepared knowledge
|
|
5618
5603
|
> * /
|
|
5619
|
-
> readonly knowledgeSources:
|
|
5604
|
+
> readonly knowledgeSources: ReadonlyArray<KnowledgeSourceJson>;
|
|
5620
5605
|
> };
|
|
5621
5606
|
>
|
|
5622
5607
|
> export async function prepareKnowledgePieces(
|
|
@@ -5674,7 +5659,7 @@
|
|
|
5674
5659
|
return __generator(this, function (_b) {
|
|
5675
5660
|
switch (_b.label) {
|
|
5676
5661
|
case 0:
|
|
5677
|
-
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ?
|
|
5662
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
5678
5663
|
templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
5679
5664
|
// TODO: [main] !!!!! Apply samples to each template (if missing and is for the template defined)
|
|
5680
5665
|
TODO_USE(parameters);
|
|
@@ -5736,7 +5721,7 @@
|
|
|
5736
5721
|
if (isPipelinePrepared(pipeline)) {
|
|
5737
5722
|
return [2 /*return*/, pipeline];
|
|
5738
5723
|
}
|
|
5739
|
-
rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ?
|
|
5724
|
+
rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b;
|
|
5740
5725
|
parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
|
|
5741
5726
|
if (tools === undefined || tools.llm === undefined) {
|
|
5742
5727
|
throw new MissingToolsError('LLM tools are required for preparing the pipeline');
|
|
@@ -5794,7 +5779,9 @@
|
|
|
5794
5779
|
// ----- /Templates preparation -----
|
|
5795
5780
|
// Note: Count total usage
|
|
5796
5781
|
currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
|
|
5797
|
-
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates:
|
|
5782
|
+
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: __spreadArray([], __read(templatesPrepared), false),
|
|
5783
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just ` templates: templatesPrepared`
|
|
5784
|
+
knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
|
|
5798
5785
|
}
|
|
5799
5786
|
});
|
|
5800
5787
|
});
|
|
@@ -5841,6 +5828,7 @@
|
|
|
5841
5828
|
'KNOWLEDGE ./hejny-cv.md',
|
|
5842
5829
|
'KNOWLEDGE ./hejny-cv.pdf',
|
|
5843
5830
|
'KNOWLEDGE ./hejny-cv.docx',
|
|
5831
|
+
// <- TODO: [😿] Allow ONLY files scoped in the (sub)directory NOT ../ and test it
|
|
5844
5832
|
],
|
|
5845
5833
|
/**
|
|
5846
5834
|
* Parses the KNOWLEDGE command
|
|
@@ -8964,7 +8952,7 @@
|
|
|
8964
8952
|
*/
|
|
8965
8953
|
function createLlmToolsFromConfiguration(configuration, options) {
|
|
8966
8954
|
if (options === void 0) { options = {}; }
|
|
8967
|
-
var _a = options.isVerbose, isVerbose = _a === void 0 ?
|
|
8955
|
+
var _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a, userId = options.userId;
|
|
8968
8956
|
var llmTools = configuration.map(function (llmConfiguration) {
|
|
8969
8957
|
var registeredItem = $llmToolsRegister
|
|
8970
8958
|
.list()
|
|
@@ -8975,7 +8963,7 @@
|
|
|
8975
8963
|
if (registeredItem === undefined) {
|
|
8976
8964
|
throw new Error(spaceTrim__default["default"](function (block) { return "\n There is no constructor for LLM provider `".concat(llmConfiguration.className, "` from `").concat(llmConfiguration.packageName, "`\n\n You have probably forgotten install and import the provider package.\n To fix this issue, you can:\n\n Install:\n\n > npm install ").concat(llmConfiguration.packageName, "\n\n And import:\n\n > import '").concat(llmConfiguration.packageName, "';\n\n\n ").concat(block($registeredLlmToolsMessage()), "\n "); }));
|
|
8977
8965
|
}
|
|
8978
|
-
return registeredItem(__assign({ isVerbose: isVerbose }, llmConfiguration.options));
|
|
8966
|
+
return registeredItem(__assign({ isVerbose: isVerbose, userId: userId }, llmConfiguration.options));
|
|
8979
8967
|
});
|
|
8980
8968
|
return joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(llmTools), false));
|
|
8981
8969
|
}
|
|
@@ -9065,7 +9053,7 @@
|
|
|
9065
9053
|
function cacheLlmTools(llmTools, options) {
|
|
9066
9054
|
var _this = this;
|
|
9067
9055
|
if (options === void 0) { options = {}; }
|
|
9068
|
-
var _a = options.storage, storage = _a === void 0 ? new MemoryStorage() : _a, _b = options.
|
|
9056
|
+
var _a = options.storage, storage = _a === void 0 ? new MemoryStorage() : _a, _b = options.isCacheReloaded, isCacheReloaded = _b === void 0 ? false : _b;
|
|
9069
9057
|
var proxyTools = __assign(__assign({}, llmTools), {
|
|
9070
9058
|
// <- Note: [🥫]
|
|
9071
9059
|
get title() {
|
|
@@ -9087,7 +9075,7 @@
|
|
|
9087
9075
|
key = titleToName(prompt.title.substring(0, MAX_FILENAME_LENGTH - 10) +
|
|
9088
9076
|
'-' +
|
|
9089
9077
|
sha256__default["default"](hexEncoder__default["default"].parse(JSON.stringify(prompt.parameters))).toString( /* hex */));
|
|
9090
|
-
if (!!
|
|
9078
|
+
if (!!isCacheReloaded) return [3 /*break*/, 2];
|
|
9091
9079
|
return [4 /*yield*/, storage.getItem(key)];
|
|
9092
9080
|
case 1:
|
|
9093
9081
|
_a = _c.sent();
|
|
@@ -9396,7 +9384,11 @@
|
|
|
9396
9384
|
mimeTypes: ['application/msword', 'text/rtf'],
|
|
9397
9385
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
9398
9386
|
isAvilableInBrowser: false,
|
|
9399
|
-
requiredExecutables: [
|
|
9387
|
+
requiredExecutables: [
|
|
9388
|
+
'Pandoc',
|
|
9389
|
+
'LibreOffice',
|
|
9390
|
+
// <- TODO: [🧠] Should be 'LibreOffice' here, its dependency of dependency
|
|
9391
|
+
],
|
|
9400
9392
|
}); /* <- TODO: [🤛] */
|
|
9401
9393
|
/**
|
|
9402
9394
|
* Registration of known scraper metadata
|
|
@@ -9420,7 +9412,7 @@
|
|
|
9420
9412
|
mimeTypes: ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
|
9421
9413
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
9422
9414
|
isAvilableInBrowser: false,
|
|
9423
|
-
requiredExecutables: ['
|
|
9415
|
+
requiredExecutables: ['Pandoc'],
|
|
9424
9416
|
}); /* <- TODO: [🤛] */
|
|
9425
9417
|
/**
|
|
9426
9418
|
* Registration of known scraper metadata
|
|
@@ -9444,7 +9436,7 @@
|
|
|
9444
9436
|
mimeTypes: ['text/markdown', 'text/plain'],
|
|
9445
9437
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
9446
9438
|
isAvilableInBrowser: true,
|
|
9447
|
-
requiredExecutables: [
|
|
9439
|
+
requiredExecutables: [],
|
|
9448
9440
|
}); /* <- TODO: [🤛] */
|
|
9449
9441
|
/**
|
|
9450
9442
|
* Registration of known scraper metadata
|
|
@@ -9468,7 +9460,7 @@
|
|
|
9468
9460
|
mimeTypes: ['application/pdf'],
|
|
9469
9461
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
9470
9462
|
isAvilableInBrowser: true,
|
|
9471
|
-
requiredExecutables: [
|
|
9463
|
+
requiredExecutables: [],
|
|
9472
9464
|
}); /* <- TODO: [🤛] */
|
|
9473
9465
|
/**
|
|
9474
9466
|
* Registration of known scraper metadata
|
|
@@ -9492,7 +9484,7 @@
|
|
|
9492
9484
|
mimeTypes: ['text/html'],
|
|
9493
9485
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
9494
9486
|
isAvilableInBrowser: false,
|
|
9495
|
-
requiredExecutables: [
|
|
9487
|
+
requiredExecutables: [],
|
|
9496
9488
|
}); /* <- TODO: [🤛] */
|
|
9497
9489
|
/**
|
|
9498
9490
|
* Registration of known scraper metadata
|
|
@@ -9865,30 +9857,33 @@
|
|
|
9865
9857
|
exports.CsvFormatDefinition = CsvFormatDefinition;
|
|
9866
9858
|
exports.CsvFormatError = CsvFormatError;
|
|
9867
9859
|
exports.DEFAULT_CSV_SETTINGS = DEFAULT_CSV_SETTINGS;
|
|
9860
|
+
exports.DEFAULT_EXECUTIONS_CACHE_DIRNAME = DEFAULT_EXECUTIONS_CACHE_DIRNAME;
|
|
9861
|
+
exports.DEFAULT_INTERMEDIATE_FILES_STRATEGY = DEFAULT_INTERMEDIATE_FILES_STRATEGY;
|
|
9862
|
+
exports.DEFAULT_IS_AUTO_INSTALLED = DEFAULT_IS_AUTO_INSTALLED;
|
|
9863
|
+
exports.DEFAULT_IS_VERBOSE = DEFAULT_IS_VERBOSE;
|
|
9864
|
+
exports.DEFAULT_MAX_EXECUTION_ATTEMPTS = DEFAULT_MAX_EXECUTION_ATTEMPTS;
|
|
9865
|
+
exports.DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH;
|
|
9866
|
+
exports.DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL;
|
|
9867
|
+
exports.DEFAULT_MAX_PARALLEL_COUNT = DEFAULT_MAX_PARALLEL_COUNT;
|
|
9868
|
+
exports.DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME;
|
|
9868
9869
|
exports.DEFAULT_REMOTE_URL = DEFAULT_REMOTE_URL;
|
|
9869
9870
|
exports.DEFAULT_REMOTE_URL_PATH = DEFAULT_REMOTE_URL_PATH;
|
|
9871
|
+
exports.DEFAULT_SCRAPE_CACHE_DIRNAME = DEFAULT_SCRAPE_CACHE_DIRNAME;
|
|
9870
9872
|
exports.ERRORS = ERRORS;
|
|
9871
|
-
exports.EXECUTIONS_CACHE_DIRNAME = EXECUTIONS_CACHE_DIRNAME;
|
|
9872
9873
|
exports.EXPECTATION_UNITS = EXPECTATION_UNITS;
|
|
9873
9874
|
exports.EnvironmentMismatchError = EnvironmentMismatchError;
|
|
9874
9875
|
exports.ExecutionReportStringOptionsDefaults = ExecutionReportStringOptionsDefaults;
|
|
9875
9876
|
exports.ExpectError = ExpectError;
|
|
9876
|
-
exports.IS_AUTO_INSTALLED = IS_AUTO_INSTALLED;
|
|
9877
|
-
exports.IS_VERBOSE = IS_VERBOSE;
|
|
9878
9877
|
exports.KnowledgeScrapeError = KnowledgeScrapeError;
|
|
9879
9878
|
exports.LimitReachedError = LimitReachedError;
|
|
9880
9879
|
exports.MANDATORY_CSV_SETTINGS = MANDATORY_CSV_SETTINGS;
|
|
9881
|
-
exports.MAX_EXECUTION_ATTEMPTS = MAX_EXECUTION_ATTEMPTS;
|
|
9882
9880
|
exports.MAX_FILENAME_LENGTH = MAX_FILENAME_LENGTH;
|
|
9883
|
-
exports.MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH;
|
|
9884
|
-
exports.MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL;
|
|
9885
|
-
exports.MAX_PARALLEL_COUNT = MAX_PARALLEL_COUNT;
|
|
9886
9881
|
exports.MODEL_VARIANTS = MODEL_VARIANTS;
|
|
9887
9882
|
exports.MemoryStorage = MemoryStorage;
|
|
9888
9883
|
exports.MissingToolsError = MissingToolsError;
|
|
9884
|
+
exports.MultipleLlmExecutionTools = MultipleLlmExecutionTools;
|
|
9889
9885
|
exports.NotFoundError = NotFoundError;
|
|
9890
9886
|
exports.NotYetImplementedError = NotYetImplementedError;
|
|
9891
|
-
exports.PIPELINE_COLLECTION_BASE_FILENAME = PIPELINE_COLLECTION_BASE_FILENAME;
|
|
9892
9887
|
exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
|
|
9893
9888
|
exports.ParseError = ParseError;
|
|
9894
9889
|
exports.PipelineExecutionError = PipelineExecutionError;
|
|
@@ -9896,7 +9891,6 @@
|
|
|
9896
9891
|
exports.PipelineUrlError = PipelineUrlError;
|
|
9897
9892
|
exports.PrefixStorage = PrefixStorage;
|
|
9898
9893
|
exports.RESERVED_PARAMETER_NAMES = RESERVED_PARAMETER_NAMES;
|
|
9899
|
-
exports.SCRAPE_CACHE_DIRNAME = SCRAPE_CACHE_DIRNAME;
|
|
9900
9894
|
exports.TemplateTypes = TemplateTypes;
|
|
9901
9895
|
exports.TextFormatDefinition = TextFormatDefinition;
|
|
9902
9896
|
exports.UNCERTAIN_USAGE = UNCERTAIN_USAGE;
|
|
@@ -9928,6 +9922,7 @@
|
|
|
9928
9922
|
exports.isPipelinePrepared = isPipelinePrepared;
|
|
9929
9923
|
exports.joinLlmExecutionTools = joinLlmExecutionTools;
|
|
9930
9924
|
exports.limitTotalUsage = limitTotalUsage;
|
|
9925
|
+
exports.makeKnowledgeSourceHandler = makeKnowledgeSourceHandler;
|
|
9931
9926
|
exports.pipelineJsonToString = pipelineJsonToString;
|
|
9932
9927
|
exports.pipelineStringToJson = pipelineStringToJson;
|
|
9933
9928
|
exports.pipelineStringToJsonSync = pipelineStringToJsonSync;
|