@promptbook/pdf 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 +93 -112
- 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 +4 -3
- package/umd/index.umd.js +93 -112
- 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/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#  Promptbook
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Build responsible, controlled and transparent applications on top of LLM models!
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -20,10 +20,6 @@ Supercharge your use of large language models
|
|
|
20
20
|
|
|
21
21
|
- ✨ **Support of [OpenAI o1 model](https://openai.com/o1/)**
|
|
22
22
|
|
|
23
|
-
<blockquote style="color: #ff8811">
|
|
24
|
-
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
25
|
-
</blockquote>
|
|
26
|
-
|
|
27
23
|
|
|
28
24
|
|
|
29
25
|
## 📦 Package `@promptbook/pdf`
|
|
@@ -54,15 +50,15 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
54
50
|
|
|
55
51
|
|
|
56
52
|
|
|
57
|
-
If you have a simple, single prompt for ChatGPT, GPT-4, Anthropic Claude, Google Gemini, Llama
|
|
53
|
+
If you have a simple, single prompt for ChatGPT, GPT-4, Anthropic Claude, Google Gemini, Llama 3, or whatever, it doesn't matter how you integrate it. Whether it's calling a REST API directly, using the SDK, hardcoding the prompt into the source code, or importing a text file, the process remains the same.
|
|
58
54
|
|
|
59
|
-
But often you will struggle with the limitations of LLMs
|
|
55
|
+
But often you will struggle with the **limitations of LLMs**, such as **hallucinations, off-topic responses, poor quality output, language and prompt drift, word repetition repetition repetition repetition or misuse, lack of context, or just plain w𝒆𝐢rd responses**. When this happens, you generally have three options:
|
|
60
56
|
|
|
61
57
|
1. **Fine-tune** the model to your specifications or even train your own.
|
|
62
58
|
2. **Prompt-engineer** the prompt to the best shape you can achieve.
|
|
63
59
|
3. Orchestrate **multiple prompts** in a [pipeline](https://github.com/webgptorg/promptbook/discussions/64) to get the best result.
|
|
64
60
|
|
|
65
|
-
In all of these situations, but especially in 3., the Promptbook
|
|
61
|
+
In all of these situations, but especially in 3., the **✨ Promptbook can make your life waaaaaaaaaay easier**.
|
|
66
62
|
|
|
67
63
|
- [**Separates concerns**](https://github.com/webgptorg/promptbook/discussions/32) between prompt-engineer and programmer, between code files and prompt files, and between prompts and their execution logic.
|
|
68
64
|
- Establishes a [**common format `.ptbk.md`**](https://github.com/webgptorg/promptbook/discussions/85) that can be used to describe your prompt business logic without having to write code or deal with the technicalities of LLMs.
|
package/esm/index.es.js
CHANGED
|
@@ -12,7 +12,7 @@ import { unparse, parse } from 'papaparse';
|
|
|
12
12
|
/**
|
|
13
13
|
* The version of the Promptbook library
|
|
14
14
|
*/
|
|
15
|
-
var PROMPTBOOK_VERSION = '0.72.0-
|
|
15
|
+
var PROMPTBOOK_VERSION = '0.72.0-34';
|
|
16
16
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
17
17
|
|
|
18
18
|
/*! *****************************************************************************
|
|
@@ -227,7 +227,6 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
227
227
|
pipelineString += '\n\n';
|
|
228
228
|
pipelineString += description;
|
|
229
229
|
}
|
|
230
|
-
// TODO:> const commands: Array<Command>
|
|
231
230
|
var commands = [];
|
|
232
231
|
if (pipelineUrl) {
|
|
233
232
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
@@ -283,7 +282,6 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
283
282
|
pipelineString += '\n\n';
|
|
284
283
|
pipelineString += description_1;
|
|
285
284
|
}
|
|
286
|
-
// TODO:> const commands: Array<Command>
|
|
287
285
|
var commands_1 = [];
|
|
288
286
|
var contentLanguage = 'text';
|
|
289
287
|
if (templateType === 'PROMPT_TEMPLATE') {
|
|
@@ -643,18 +641,19 @@ var LOOP_LIMIT = 1000;
|
|
|
643
641
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
644
642
|
*/
|
|
645
643
|
var IMMEDIATE_TIME = 10;
|
|
644
|
+
// <- TODO: [😡] Change to 'VISIBLE'
|
|
646
645
|
/**
|
|
647
646
|
* The maximum number of (LLM) tasks running in parallel
|
|
648
647
|
*
|
|
649
648
|
* @public exported from `@promptbook/core`
|
|
650
649
|
*/
|
|
651
|
-
var
|
|
650
|
+
var DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹♂️]
|
|
652
651
|
/**
|
|
653
652
|
* The maximum number of attempts to execute LLM task before giving up
|
|
654
653
|
*
|
|
655
654
|
* @public exported from `@promptbook/core`
|
|
656
655
|
*/
|
|
657
|
-
var
|
|
656
|
+
var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹♂️]
|
|
658
657
|
/**
|
|
659
658
|
* Nonce which is used for replacing things in strings
|
|
660
659
|
*
|
|
@@ -706,7 +705,7 @@ var DEFAULT_CSV_SETTINGS = Object.freeze({
|
|
|
706
705
|
*
|
|
707
706
|
* @public exported from `@promptbook/core`
|
|
708
707
|
*/
|
|
709
|
-
var
|
|
708
|
+
var DEFAULT_IS_VERBOSE = false;
|
|
710
709
|
/**
|
|
711
710
|
* @@@
|
|
712
711
|
*
|
|
@@ -1902,6 +1901,7 @@ function assertsExecutionSuccessful(executionResult) {
|
|
|
1902
1901
|
}
|
|
1903
1902
|
}
|
|
1904
1903
|
/**
|
|
1904
|
+
* TODO: [🐚] This function should be removed OR changed OR be completely rewritten
|
|
1905
1905
|
* TODO: [🧠] Can this return type be better typed than void
|
|
1906
1906
|
*/
|
|
1907
1907
|
|
|
@@ -2087,8 +2087,7 @@ $deepFreeze({
|
|
|
2087
2087
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
2088
2088
|
*
|
|
2089
2089
|
* Note: Internal utility of `joinLlmExecutionTools` but exposed type
|
|
2090
|
-
* @public exported from `@promptbook/
|
|
2091
|
-
* TODO: !!!!!! Export as runtime class not just type
|
|
2090
|
+
* @public exported from `@promptbook/core`
|
|
2092
2091
|
*/
|
|
2093
2092
|
var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
2094
2093
|
/**
|
|
@@ -2590,7 +2589,7 @@ function preparePersona(personaDescription, tools, options) {
|
|
|
2590
2589
|
return __generator(this, function (_d) {
|
|
2591
2590
|
switch (_d.label) {
|
|
2592
2591
|
case 0:
|
|
2593
|
-
_a = options.isVerbose, isVerbose = _a === void 0 ?
|
|
2592
|
+
_a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
2594
2593
|
if (tools === undefined || tools.llm === undefined) {
|
|
2595
2594
|
throw new MissingToolsError('LLM tools are required for preparing persona');
|
|
2596
2595
|
}
|
|
@@ -2772,7 +2771,7 @@ var $Register = /** @class */ (function () {
|
|
|
2772
2771
|
this.storage = globalScope[storageName];
|
|
2773
2772
|
}
|
|
2774
2773
|
$Register.prototype.list = function () {
|
|
2775
|
-
// <- TODO: ReadonlyDeep<
|
|
2774
|
+
// <- TODO: ReadonlyDeep<ReadonlyArray<TRegistered>>
|
|
2776
2775
|
return this.storage;
|
|
2777
2776
|
};
|
|
2778
2777
|
$Register.prototype.register = function (registered) {
|
|
@@ -2824,7 +2823,6 @@ var $scrapersRegister = new $Register('scraper_constructors');
|
|
|
2824
2823
|
* TODO: [®] DRY Register logic
|
|
2825
2824
|
*/
|
|
2826
2825
|
|
|
2827
|
-
// TODO: !!!!!! Maybe delete this function
|
|
2828
2826
|
/**
|
|
2829
2827
|
* Creates a message with all registered scrapers
|
|
2830
2828
|
*
|
|
@@ -2932,7 +2930,6 @@ function $registeredScrapersMessage() {
|
|
|
2932
2930
|
* @private within the repository
|
|
2933
2931
|
*/
|
|
2934
2932
|
function sourceContentToName(sourceContent) {
|
|
2935
|
-
// TODO: !!!!!! Better name for source than gibberish hash
|
|
2936
2933
|
var hash = SHA256(hexEncoder.parse(JSON.stringify(sourceContent)))
|
|
2937
2934
|
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
2938
2935
|
.toString( /* hex */)
|
|
@@ -3006,20 +3003,20 @@ function isFileExisting(filename, fs) {
|
|
|
3006
3003
|
/**
|
|
3007
3004
|
* @@@
|
|
3008
3005
|
*
|
|
3009
|
-
* @
|
|
3006
|
+
* @public exported from `@promptbook/core`
|
|
3010
3007
|
*/
|
|
3011
3008
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
3012
3009
|
var _a;
|
|
3013
3010
|
return __awaiter(this, void 0, void 0, function () {
|
|
3014
3011
|
var sourceContent, name, _b, _c, rootDirname, _d,
|
|
3015
3012
|
// <- TODO: process.cwd() if running in Node.js
|
|
3016
|
-
isVerbose, url, response_1, mimeType, filename_1, fileExtension,
|
|
3013
|
+
isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
3017
3014
|
return __generator(this, function (_e) {
|
|
3018
3015
|
switch (_e.label) {
|
|
3019
3016
|
case 0:
|
|
3020
3017
|
sourceContent = knowledgeSource.sourceContent;
|
|
3021
3018
|
name = knowledgeSource.name;
|
|
3022
|
-
_b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ?
|
|
3019
|
+
_b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d;
|
|
3023
3020
|
TODO_USE(isVerbose);
|
|
3024
3021
|
if (!name) {
|
|
3025
3022
|
name = sourceContentToName(sourceContent);
|
|
@@ -3035,19 +3032,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3035
3032
|
filename: null,
|
|
3036
3033
|
url: url,
|
|
3037
3034
|
mimeType: mimeType,
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
return [2 /*return*/, content];
|
|
3047
|
-
}
|
|
3048
|
-
});
|
|
3049
|
-
});
|
|
3050
|
-
},
|
|
3035
|
+
/*
|
|
3036
|
+
TODO: [🥽]
|
|
3037
|
+
> async asBlob() {
|
|
3038
|
+
> // TODO: [👨🏻🤝👨🏻] This can be called multiple times BUT when called second time, response in already consumed
|
|
3039
|
+
> const content = await response.blob();
|
|
3040
|
+
> return content;
|
|
3041
|
+
> },
|
|
3042
|
+
*/
|
|
3051
3043
|
asJson: function () {
|
|
3052
3044
|
return __awaiter(this, void 0, void 0, function () {
|
|
3053
3045
|
var content;
|
|
@@ -3087,34 +3079,31 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3087
3079
|
}
|
|
3088
3080
|
filename_1 = join(rootDirname, sourceContent).split('\\').join('/');
|
|
3089
3081
|
fileExtension = getFileExtension(filename_1);
|
|
3090
|
-
|
|
3082
|
+
mimeType = extensionToMimeType(fileExtension || '');
|
|
3091
3083
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3092
3084
|
case 3:
|
|
3093
3085
|
if (!(_e.sent())) {
|
|
3094
3086
|
throw new NotFoundError(spaceTrim$1(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
|
|
3095
3087
|
}
|
|
3096
|
-
// TODO:
|
|
3088
|
+
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
3097
3089
|
return [2 /*return*/, {
|
|
3098
3090
|
source: name,
|
|
3099
3091
|
filename: filename_1,
|
|
3100
3092
|
url: null,
|
|
3101
|
-
mimeType:
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
});
|
|
3116
|
-
});
|
|
3117
|
-
},
|
|
3093
|
+
mimeType: mimeType,
|
|
3094
|
+
/*
|
|
3095
|
+
TODO: [🥽]
|
|
3096
|
+
> async asBlob() {
|
|
3097
|
+
> const content = await tools.fs!.readFile(filename);
|
|
3098
|
+
> return new Blob(
|
|
3099
|
+
> [
|
|
3100
|
+
> content,
|
|
3101
|
+
> // <- TODO: [🥽] This is NOT tested, test it
|
|
3102
|
+
> ],
|
|
3103
|
+
> { type: mimeType },
|
|
3104
|
+
> );
|
|
3105
|
+
> },
|
|
3106
|
+
*/
|
|
3118
3107
|
asJson: function () {
|
|
3119
3108
|
return __awaiter(this, void 0, void 0, function () {
|
|
3120
3109
|
var _a, _b;
|
|
@@ -3150,9 +3139,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3150
3139
|
asJson: function () {
|
|
3151
3140
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
3152
3141
|
},
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3142
|
+
/*
|
|
3143
|
+
TODO: [🥽]
|
|
3144
|
+
> asBlob() {
|
|
3145
|
+
> throw new UnexpectedError(
|
|
3146
|
+
> 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
|
|
3147
|
+
> );
|
|
3148
|
+
> },
|
|
3149
|
+
*/
|
|
3156
3150
|
}];
|
|
3157
3151
|
}
|
|
3158
3152
|
});
|
|
@@ -3172,7 +3166,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
3172
3166
|
return __generator(this, function (_c) {
|
|
3173
3167
|
switch (_c.label) {
|
|
3174
3168
|
case 0:
|
|
3175
|
-
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ?
|
|
3169
|
+
_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;
|
|
3176
3170
|
knowledgePreparedUnflatten = new Array(knowledgeSources.length);
|
|
3177
3171
|
return [4 /*yield*/, forEachAsync(knowledgeSources, { maxParallelCount: maxParallelCount }, function (knowledgeSource, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
3178
3172
|
var partialPieces, sourceHandler, _a, _b, scraper, partialPiecesUnchecked, e_1_1, pieces;
|
|
@@ -3201,7 +3195,8 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
3201
3195
|
case 4:
|
|
3202
3196
|
partialPiecesUnchecked = _d.sent();
|
|
3203
3197
|
if (partialPiecesUnchecked !== null) {
|
|
3204
|
-
partialPieces = partialPiecesUnchecked;
|
|
3198
|
+
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
3199
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
3205
3200
|
return [3 /*break*/, 6];
|
|
3206
3201
|
}
|
|
3207
3202
|
_d.label = 5;
|
|
@@ -3249,7 +3244,7 @@ TODO: [🧊] This is how it can look in future
|
|
|
3249
3244
|
> /**
|
|
3250
3245
|
> * Unprepared knowledge
|
|
3251
3246
|
> * /
|
|
3252
|
-
> readonly knowledgeSources:
|
|
3247
|
+
> readonly knowledgeSources: ReadonlyArray<KnowledgeSourceJson>;
|
|
3253
3248
|
> };
|
|
3254
3249
|
>
|
|
3255
3250
|
> export async function prepareKnowledgePieces(
|
|
@@ -3307,7 +3302,7 @@ function prepareTemplates(pipeline, tools, options) {
|
|
|
3307
3302
|
return __generator(this, function (_b) {
|
|
3308
3303
|
switch (_b.label) {
|
|
3309
3304
|
case 0:
|
|
3310
|
-
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ?
|
|
3305
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
3311
3306
|
templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
3312
3307
|
// TODO: [main] !!!!! Apply samples to each template (if missing and is for the template defined)
|
|
3313
3308
|
TODO_USE(parameters);
|
|
@@ -3369,7 +3364,7 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3369
3364
|
if (isPipelinePrepared(pipeline)) {
|
|
3370
3365
|
return [2 /*return*/, pipeline];
|
|
3371
3366
|
}
|
|
3372
|
-
rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ?
|
|
3367
|
+
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;
|
|
3373
3368
|
parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
|
|
3374
3369
|
if (tools === undefined || tools.llm === undefined) {
|
|
3375
3370
|
throw new MissingToolsError('LLM tools are required for preparing the pipeline');
|
|
@@ -3427,7 +3422,9 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3427
3422
|
// ----- /Templates preparation -----
|
|
3428
3423
|
// Note: Count total usage
|
|
3429
3424
|
currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
|
|
3430
|
-
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates:
|
|
3425
|
+
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: __spreadArray([], __read(templatesPrepared), false),
|
|
3426
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just ` templates: templatesPrepared`
|
|
3427
|
+
knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
|
|
3431
3428
|
}
|
|
3432
3429
|
});
|
|
3433
3430
|
});
|
|
@@ -4398,12 +4395,11 @@ function checkExpectations(expectations, value) {
|
|
|
4398
4395
|
*/
|
|
4399
4396
|
function executeAttempts(options) {
|
|
4400
4397
|
return __awaiter(this, void 0, void 0, function () {
|
|
4401
|
-
var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools,
|
|
4398
|
+
var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
|
|
4402
4399
|
return __generator(this, function (_a) {
|
|
4403
4400
|
switch (_a.label) {
|
|
4404
4401
|
case 0:
|
|
4405
|
-
jokerParameterNames = options.jokerParameterNames, priority = options.priority, maxAttempts = options.maxAttempts, preparedContent = options.preparedContent, parameters = options.parameters, template = options.template, preparedPipeline = options.preparedPipeline, tools = options.tools,
|
|
4406
|
-
maxExecutionAttempts = settings.maxExecutionAttempts;
|
|
4402
|
+
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;
|
|
4407
4403
|
$ongoingTemplateResult = {
|
|
4408
4404
|
$result: null,
|
|
4409
4405
|
$resultString: null,
|
|
@@ -4769,12 +4765,12 @@ function executeAttempts(options) {
|
|
|
4769
4765
|
*/
|
|
4770
4766
|
function executeFormatSubvalues(options) {
|
|
4771
4767
|
return __awaiter(this, void 0, void 0, function () {
|
|
4772
|
-
var template, jokerParameterNames, parameters, priority,
|
|
4768
|
+
var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
|
|
4773
4769
|
var _this = this;
|
|
4774
4770
|
return __generator(this, function (_a) {
|
|
4775
4771
|
switch (_a.label) {
|
|
4776
4772
|
case 0:
|
|
4777
|
-
template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority,
|
|
4773
|
+
template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
|
|
4778
4774
|
if (template.foreach === undefined) {
|
|
4779
4775
|
return [2 /*return*/, /* not await */ executeAttempts(options)];
|
|
4780
4776
|
}
|
|
@@ -4804,7 +4800,7 @@ function executeFormatSubvalues(options) {
|
|
|
4804
4800
|
.join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4805
4801
|
}
|
|
4806
4802
|
if (formatDefinition.formatName === 'CSV') {
|
|
4807
|
-
formatSettings =
|
|
4803
|
+
formatSettings = csvSettings;
|
|
4808
4804
|
// <- TODO: [🤹♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
4809
4805
|
}
|
|
4810
4806
|
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -4957,13 +4953,12 @@ function getReservedParametersForTemplate(options) {
|
|
|
4957
4953
|
*/
|
|
4958
4954
|
function executeTemplate(options) {
|
|
4959
4955
|
return __awaiter(this, void 0, void 0, function () {
|
|
4960
|
-
var currentTemplate, preparedPipeline, parametersToPass, tools, onProgress,
|
|
4961
|
-
var e_1,
|
|
4962
|
-
return __generator(this, function (
|
|
4963
|
-
switch (
|
|
4956
|
+
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;
|
|
4957
|
+
var e_1, _g, _h;
|
|
4958
|
+
return __generator(this, function (_j) {
|
|
4959
|
+
switch (_j.label) {
|
|
4964
4960
|
case 0:
|
|
4965
|
-
currentTemplate = options.currentTemplate, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress,
|
|
4966
|
-
maxExecutionAttempts = settings.maxExecutionAttempts;
|
|
4961
|
+
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;
|
|
4967
4962
|
name = "pipeline-executor-frame-".concat(currentTemplate.name);
|
|
4968
4963
|
title = currentTemplate.title;
|
|
4969
4964
|
priority = preparedPipeline.templates.length - preparedPipeline.templates.indexOf(currentTemplate);
|
|
@@ -4978,7 +4973,7 @@ function executeTemplate(options) {
|
|
|
4978
4973
|
// <- [🍸]
|
|
4979
4974
|
})];
|
|
4980
4975
|
case 1:
|
|
4981
|
-
|
|
4976
|
+
_j.sent();
|
|
4982
4977
|
usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
|
|
4983
4978
|
dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
|
|
4984
4979
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
@@ -4989,15 +4984,15 @@ function executeTemplate(options) {
|
|
|
4989
4984
|
.map(function (name) { return "{".concat(name, "}"); })
|
|
4990
4985
|
.join(', '), "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
4991
4986
|
}
|
|
4992
|
-
|
|
4993
|
-
|
|
4987
|
+
_c = (_b = Object).freeze;
|
|
4988
|
+
_d = [{}];
|
|
4994
4989
|
return [4 /*yield*/, getReservedParametersForTemplate({
|
|
4995
4990
|
preparedPipeline: preparedPipeline,
|
|
4996
4991
|
template: currentTemplate,
|
|
4997
4992
|
pipelineIdentification: pipelineIdentification,
|
|
4998
4993
|
})];
|
|
4999
4994
|
case 2:
|
|
5000
|
-
definedParameters =
|
|
4995
|
+
definedParameters = _c.apply(_b, [__assign.apply(void 0, [__assign.apply(void 0, _d.concat([(_j.sent())])), parametersToPass])]);
|
|
5001
4996
|
definedParameterNames = new Set(Object.keys(definedParameters));
|
|
5002
4997
|
parameters = {};
|
|
5003
4998
|
_loop_1 = function (parameterName) {
|
|
@@ -5017,15 +5012,15 @@ function executeTemplate(options) {
|
|
|
5017
5012
|
try {
|
|
5018
5013
|
// Note: [2] Check that all used parameters are defined and removing unused parameters for this template
|
|
5019
5014
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
5020
|
-
for (
|
|
5021
|
-
parameterName =
|
|
5015
|
+
for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
5016
|
+
parameterName = _f.value;
|
|
5022
5017
|
_loop_1(parameterName);
|
|
5023
5018
|
}
|
|
5024
5019
|
}
|
|
5025
5020
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5026
5021
|
finally {
|
|
5027
5022
|
try {
|
|
5028
|
-
if (
|
|
5023
|
+
if (_f && !_f.done && (_g = _e.return)) _g.call(_e);
|
|
5029
5024
|
}
|
|
5030
5025
|
finally { if (e_1) throw e_1.error; }
|
|
5031
5026
|
}
|
|
@@ -5045,12 +5040,11 @@ function executeTemplate(options) {
|
|
|
5045
5040
|
template: currentTemplate,
|
|
5046
5041
|
preparedPipeline: preparedPipeline,
|
|
5047
5042
|
tools: tools,
|
|
5048
|
-
settings: settings,
|
|
5049
5043
|
$executionReport: $executionReport,
|
|
5050
5044
|
pipelineIdentification: pipelineIdentification,
|
|
5051
5045
|
})];
|
|
5052
5046
|
case 3:
|
|
5053
|
-
resultString =
|
|
5047
|
+
resultString = _j.sent();
|
|
5054
5048
|
return [4 /*yield*/, onProgress({
|
|
5055
5049
|
name: name,
|
|
5056
5050
|
title: title,
|
|
@@ -5062,12 +5056,12 @@ function executeTemplate(options) {
|
|
|
5062
5056
|
// <- [🍸]
|
|
5063
5057
|
})];
|
|
5064
5058
|
case 4:
|
|
5065
|
-
|
|
5066
|
-
return [2 /*return*/, Object.freeze((
|
|
5067
|
-
|
|
5059
|
+
_j.sent();
|
|
5060
|
+
return [2 /*return*/, Object.freeze((_h = {},
|
|
5061
|
+
_h[currentTemplate.resultingParameterName] =
|
|
5068
5062
|
// <- Note: [👩👩👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
5069
5063
|
resultString,
|
|
5070
|
-
|
|
5064
|
+
_h))];
|
|
5071
5065
|
}
|
|
5072
5066
|
});
|
|
5073
5067
|
});
|
|
@@ -5126,13 +5120,12 @@ function filterJustOutputParameters(options) {
|
|
|
5126
5120
|
*/
|
|
5127
5121
|
function executePipeline(options) {
|
|
5128
5122
|
return __awaiter(this, void 0, void 0, function () {
|
|
5129
|
-
var inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification,
|
|
5123
|
+
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;
|
|
5130
5124
|
var e_1, _f, e_2, _g;
|
|
5131
5125
|
return __generator(this, function (_h) {
|
|
5132
5126
|
switch (_h.label) {
|
|
5133
5127
|
case 0:
|
|
5134
|
-
inputParameters = options.inputParameters, tools = options.tools, onProgress = options.onProgress, pipeline = options.pipeline, setPreparedPipeline = options.setPreparedPipeline, pipelineIdentification = options.pipelineIdentification,
|
|
5135
|
-
maxParallelCount = settings.maxParallelCount, rootDirname = settings.rootDirname, _a = settings.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
|
|
5128
|
+
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;
|
|
5136
5129
|
preparedPipeline = options.preparedPipeline;
|
|
5137
5130
|
if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
|
|
5138
5131
|
return [4 /*yield*/, preparePipeline(pipeline, tools, {
|
|
@@ -5317,12 +5310,7 @@ function executePipeline(options) {
|
|
|
5317
5310
|
return [3 /*break*/, 4];
|
|
5318
5311
|
case 3:
|
|
5319
5312
|
unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
|
|
5320
|
-
work_1 = executeTemplate({
|
|
5321
|
-
currentTemplate: currentTemplate,
|
|
5322
|
-
preparedPipeline: preparedPipeline,
|
|
5323
|
-
parametersToPass: parametersToPass,
|
|
5324
|
-
tools: tools,
|
|
5325
|
-
onProgress: function (progress) {
|
|
5313
|
+
work_1 = executeTemplate(__assign(__assign({}, options), { currentTemplate: currentTemplate, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
|
|
5326
5314
|
if (isReturned) {
|
|
5327
5315
|
throw new UnexpectedError(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)
|
|
5328
5316
|
.split('\n')
|
|
@@ -5332,11 +5320,7 @@ function executePipeline(options) {
|
|
|
5332
5320
|
if (onProgress) {
|
|
5333
5321
|
onProgress(progress);
|
|
5334
5322
|
}
|
|
5335
|
-
},
|
|
5336
|
-
settings: settings,
|
|
5337
|
-
$executionReport: executionReport,
|
|
5338
|
-
pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }),
|
|
5339
|
-
})
|
|
5323
|
+
}, $executionReport: executionReport, pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }) }))
|
|
5340
5324
|
.then(function (newParametersToPass) {
|
|
5341
5325
|
parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
|
|
5342
5326
|
resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
|
|
@@ -5440,8 +5424,7 @@ function executePipeline(options) {
|
|
|
5440
5424
|
*/
|
|
5441
5425
|
function createPipelineExecutor(options) {
|
|
5442
5426
|
var _this = this;
|
|
5443
|
-
var pipeline = options.pipeline, tools = options.tools, _a = options.
|
|
5444
|
-
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;
|
|
5427
|
+
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;
|
|
5445
5428
|
validatePipeline(pipeline);
|
|
5446
5429
|
var pipelineIdentification = (function () {
|
|
5447
5430
|
// Note: This is a 😐 implementation of [🚞]
|
|
@@ -5475,14 +5458,12 @@ function createPipelineExecutor(options) {
|
|
|
5475
5458
|
tools: tools,
|
|
5476
5459
|
onProgress: onProgress,
|
|
5477
5460
|
pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n ").concat(runCount === 1 ? '' : "Run #".concat(runCount), "\n "); }),
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
rootDirname: rootDirname,
|
|
5485
|
-
},
|
|
5461
|
+
maxExecutionAttempts: maxExecutionAttempts,
|
|
5462
|
+
maxParallelCount: maxParallelCount,
|
|
5463
|
+
csvSettings: csvSettings,
|
|
5464
|
+
isVerbose: isVerbose,
|
|
5465
|
+
isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
|
|
5466
|
+
rootDirname: rootDirname,
|
|
5486
5467
|
})];
|
|
5487
5468
|
});
|
|
5488
5469
|
}); };
|
|
@@ -5504,7 +5485,7 @@ var markdownScraperMetadata = $deepFreeze({
|
|
|
5504
5485
|
mimeTypes: ['text/markdown', 'text/plain'],
|
|
5505
5486
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
5506
5487
|
isAvilableInBrowser: true,
|
|
5507
|
-
requiredExecutables: [
|
|
5488
|
+
requiredExecutables: [],
|
|
5508
5489
|
}); /* <- TODO: [🤛] */
|
|
5509
5490
|
/**
|
|
5510
5491
|
* Registration of known scraper metadata
|
|
@@ -5548,7 +5529,7 @@ var MarkdownScraper = /** @class */ (function () {
|
|
|
5548
5529
|
return __generator(this, function (_k) {
|
|
5549
5530
|
switch (_k.label) {
|
|
5550
5531
|
case 0:
|
|
5551
|
-
_a = this.options, _b = _a.maxParallelCount, maxParallelCount = _b === void 0 ?
|
|
5532
|
+
_a = this.options, _b = _a.maxParallelCount, maxParallelCount = _b === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
|
|
5552
5533
|
llm = this.tools.llm;
|
|
5553
5534
|
if (llm === undefined) {
|
|
5554
5535
|
throw new MissingToolsError('LLM tools are required for scraping external files');
|
|
@@ -5647,7 +5628,8 @@ var MarkdownScraper = /** @class */ (function () {
|
|
|
5647
5628
|
embeddingResult = _c.sent();
|
|
5648
5629
|
index.push({
|
|
5649
5630
|
modelName: embeddingResult.modelName,
|
|
5650
|
-
position: embeddingResult.content,
|
|
5631
|
+
position: __spreadArray([], __read(embeddingResult.content), false),
|
|
5632
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just `position: embeddingResult.content`
|
|
5651
5633
|
});
|
|
5652
5634
|
_c.label = 6;
|
|
5653
5635
|
case 6: return [3 /*break*/, 8];
|
|
@@ -5698,7 +5680,7 @@ var pdfScraperMetadata = $deepFreeze({
|
|
|
5698
5680
|
mimeTypes: ['application/pdf'],
|
|
5699
5681
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
5700
5682
|
isAvilableInBrowser: true,
|
|
5701
|
-
requiredExecutables: [
|
|
5683
|
+
requiredExecutables: [],
|
|
5702
5684
|
}); /* <- TODO: [🤛] */
|
|
5703
5685
|
/**
|
|
5704
5686
|
* Registration of known scraper metadata
|
|
@@ -5711,7 +5693,7 @@ var pdfScraperMetadata = $deepFreeze({
|
|
|
5711
5693
|
$scrapersMetadataRegister.register(pdfScraperMetadata);
|
|
5712
5694
|
|
|
5713
5695
|
/**
|
|
5714
|
-
* Scraper for .
|
|
5696
|
+
* Scraper for .pdf files
|
|
5715
5697
|
*
|
|
5716
5698
|
* @see `documentationUrl` for more details
|
|
5717
5699
|
* @public exported from `@promptbook/pdf`
|
|
@@ -5754,9 +5736,8 @@ var PdfScraper = /** @class */ (function () {
|
|
|
5754
5736
|
TODO_USE(this.options);
|
|
5755
5737
|
/*
|
|
5756
5738
|
const {
|
|
5757
|
-
externalProgramsPaths = {},
|
|
5758
5739
|
cacheDirname = SCRAPE_CACHE_DIRNAME,
|
|
5759
|
-
|
|
5740
|
+
intermediateFilesStrategy = DEFAULT_INTERMEDIATE_FILES_STRATEGY,
|
|
5760
5741
|
isVerbose = IS_VERBOSE,
|
|
5761
5742
|
} = options;
|
|
5762
5743
|
*/
|