@promptbook/pdf 0.100.0-8 → 0.100.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 +7 -14
- package/esm/index.es.js +252 -23
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/color.index.d.ts +50 -0
- package/esm/typings/src/_packages/components.index.d.ts +36 -0
- package/esm/typings/src/_packages/core.index.d.ts +30 -0
- package/esm/typings/src/_packages/types.index.d.ts +38 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSource.d.ts +30 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSource.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +26 -0
- package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +38 -0
- package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +39 -0
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +45 -0
- package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +44 -0
- package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +56 -0
- package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +39 -0
- package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +49 -0
- package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +46 -0
- package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +44 -0
- package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +44 -0
- package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +38 -0
- package/esm/typings/src/book-2.0/commitments/_base/BaseCommitmentDefinition.d.ts +52 -0
- package/esm/typings/src/book-2.0/commitments/_base/BookCommitment.d.ts +5 -0
- package/esm/typings/src/book-2.0/commitments/_base/CommitmentDefinition.d.ts +48 -0
- package/esm/typings/src/book-2.0/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +22 -0
- package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +19 -0
- package/esm/typings/src/book-2.0/commitments/_misc/AgentModelRequirements.d.ts +37 -0
- package/esm/typings/src/book-2.0/commitments/_misc/AgentSourceParseResult.d.ts +18 -0
- package/esm/typings/src/book-2.0/commitments/_misc/ParsedCommitment.d.ts +22 -0
- package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirements.d.ts +62 -0
- package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirementsWithCommitments.d.ts +36 -0
- package/esm/typings/src/book-2.0/commitments/_misc/createCommitmentRegex.d.ts +20 -0
- package/esm/typings/src/book-2.0/commitments/_misc/parseAgentSourceWithCommitments.d.ts +24 -0
- package/esm/typings/src/book-2.0/commitments/_misc/removeCommentsFromSystemMessage.d.ts +11 -0
- package/esm/typings/src/book-2.0/commitments/index.d.ts +56 -0
- package/esm/typings/src/book-2.0/utils/profileImageUtils.d.ts +39 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +35 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChipFromSource.d.ts +21 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarChip/index.d.ts +2 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +26 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfileFromSource.d.ts +19 -0
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +35 -0
- package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +15 -0
- package/esm/typings/src/book-components/BookEditor/config.d.ts +10 -0
- package/esm/typings/src/book-components/BookEditor/injectCssModuleIntoShadowRoot.d.ts +11 -0
- package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +20 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +110 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChat.d.ts +14 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChat.test.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +24 -0
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +16 -0
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +32 -0
- package/esm/typings/src/book-components/Chat/utils/ChatPersistence.d.ts +25 -0
- package/esm/typings/src/book-components/Chat/utils/ExportFormat.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/utils/addUtmParamsToUrl.d.ts +7 -0
- package/esm/typings/src/book-components/Chat/utils/createShortLinkForChat.d.ts +7 -0
- package/esm/typings/src/book-components/Chat/utils/downloadFile.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/utils/exportChatHistory.d.ts +9 -0
- package/esm/typings/src/book-components/Chat/utils/generatePdfContent.d.ts +8 -0
- package/esm/typings/src/book-components/Chat/utils/generateQrDataUrl.d.ts +7 -0
- package/esm/typings/src/book-components/Chat/utils/getPromptbookBranding.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/utils/messagesToHtml.d.ts +8 -0
- package/esm/typings/src/book-components/Chat/utils/messagesToJson.d.ts +7 -0
- package/esm/typings/src/book-components/Chat/utils/messagesToMarkdown.d.ts +8 -0
- package/esm/typings/src/book-components/Chat/utils/messagesToText.d.ts +8 -0
- package/esm/typings/src/book-components/_common/react-utils/classNames.d.ts +7 -0
- package/esm/typings/src/book-components/_common/react-utils/collectCssTextsForClass.d.ts +7 -0
- package/esm/typings/src/book-components/_common/react-utils/escapeHtml.d.ts +6 -0
- package/esm/typings/src/book-components/_common/react-utils/escapeRegex.d.ts +6 -0
- package/esm/typings/src/config.d.ts +19 -0
- package/esm/typings/src/execution/AvailableModel.d.ts +4 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +27 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +8 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +6 -1
- package/esm/typings/src/llm-providers/_common/filterModels.d.ts +0 -3
- package/esm/typings/src/llm-providers/_common/profiles/llmProviderProfiles.d.ts +81 -0
- package/esm/typings/src/llm-providers/_common/profiles/test/llmProviderProfiles.test.d.ts +1 -0
- package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +5 -0
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +5 -5
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -0
- package/esm/typings/src/llm-providers/ollama/ollama-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +8 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +5 -0
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +5 -0
- package/esm/typings/src/pipeline/book-notation.d.ts +2 -1
- package/esm/typings/src/playground/permanent/error-handling-playground.d.ts +5 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +0 -2
- package/esm/typings/src/types/typeAliases.d.ts +6 -0
- package/esm/typings/src/utils/color/$randomColor.d.ts +11 -0
- package/esm/typings/src/utils/color/Color.d.ts +180 -0
- package/esm/typings/src/utils/color/css-colors.d.ts +159 -0
- package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +14 -0
- package/esm/typings/src/utils/color/internal-utils/hslToRgb.d.ts +17 -0
- package/esm/typings/src/utils/color/internal-utils/rgbToHsl.d.ts +17 -0
- package/esm/typings/src/utils/color/operators/ColorTransformer.d.ts +5 -0
- package/esm/typings/src/utils/color/operators/darken.d.ts +9 -0
- package/esm/typings/src/utils/color/operators/furthest.d.ts +16 -0
- package/esm/typings/src/utils/color/operators/grayscale.d.ts +9 -0
- package/esm/typings/src/utils/color/operators/lighten.d.ts +12 -0
- package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +11 -0
- package/esm/typings/src/utils/color/operators/nearest.d.ts +10 -0
- package/esm/typings/src/utils/color/operators/negative.d.ts +7 -0
- package/esm/typings/src/utils/color/operators/negativeLightness.d.ts +7 -0
- package/esm/typings/src/utils/color/operators/withAlpha.d.ts +9 -0
- package/esm/typings/src/utils/color/utils/areColorsEqual.d.ts +14 -0
- package/esm/typings/src/utils/color/utils/colorDistance.d.ts +21 -0
- package/esm/typings/src/utils/color/utils/colorHue.d.ts +11 -0
- package/esm/typings/src/utils/color/utils/colorHueDistance.d.ts +11 -0
- package/esm/typings/src/utils/color/utils/colorHueDistance.test.d.ts +1 -0
- package/esm/typings/src/utils/color/utils/colorLuminance.d.ts +9 -0
- package/esm/typings/src/utils/color/utils/colorSatulightion.d.ts +7 -0
- package/esm/typings/src/utils/color/utils/colorSaturation.d.ts +9 -0
- package/esm/typings/src/utils/color/utils/colorToDataUrl.d.ts +10 -0
- package/esm/typings/src/utils/color/utils/mixColors.d.ts +11 -0
- package/esm/typings/src/utils/organization/preserve.d.ts +21 -0
- package/esm/typings/src/utils/take/classes/TakeChain.d.ts +11 -0
- package/esm/typings/src/utils/take/interfaces/ITakeChain.d.ts +12 -0
- package/esm/typings/src/utils/take/interfaces/Takeable.d.ts +7 -0
- package/esm/typings/src/utils/take/take.d.ts +12 -0
- package/esm/typings/src/utils/take/take.test.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -3
- package/umd/index.umd.js +256 -27
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +0 -14
package/umd/index.umd.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('spacetrim'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('prettier'), require('prettier/parser-
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'spacetrim', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier', 'prettier/parser-
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-pdf"] = {}, global.promises, global.spaceTrim, global.cryptoJs, global.hexEncoder, global.path, global.
|
|
5
|
-
})(this, (function (exports, promises, spaceTrim, cryptoJs, hexEncoder, path,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('spacetrim'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('prettier/parser-html'), require('prettier/parser-markdown'), require('prettier/standalone'), require('crypto'), require('rxjs'), require('waitasecond'), require('crypto-js/sha256'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'spacetrim', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier/parser-html', 'prettier/parser-markdown', 'prettier/standalone', 'crypto', 'rxjs', 'waitasecond', 'crypto-js/sha256', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-pdf"] = {}, global.promises, global.spaceTrim, global.cryptoJs, global.hexEncoder, global.path, global.parserHtml, global.parserMarkdown, global.standalone, global.crypto, global.rxjs, global.waitasecond, global.sha256, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, promises, spaceTrim, cryptoJs, hexEncoder, path, parserHtml, parserMarkdown, standalone, crypto, rxjs, waitasecond, sha256, mimeTypes, papaparse) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
|
|
10
10
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
11
11
|
var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
|
|
12
|
+
var parserMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(parserMarkdown);
|
|
12
13
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
13
14
|
|
|
14
15
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
* @generated
|
|
26
27
|
* @see https://github.com/webgptorg/promptbook
|
|
27
28
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0';
|
|
29
30
|
/**
|
|
30
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -217,6 +218,19 @@
|
|
|
217
218
|
* @public exported from `@promptbook/core`
|
|
218
219
|
*/
|
|
219
220
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
221
|
+
/**
|
|
222
|
+
* Default simulated duration for a task in milliseconds (used for progress reporting)
|
|
223
|
+
*
|
|
224
|
+
* @public exported from `@promptbook/core`
|
|
225
|
+
*/
|
|
226
|
+
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
227
|
+
/**
|
|
228
|
+
* API request timeout in milliseconds
|
|
229
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
230
|
+
*
|
|
231
|
+
* @public exported from `@promptbook/core`
|
|
232
|
+
*/
|
|
233
|
+
parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
220
234
|
/**
|
|
221
235
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
222
236
|
*
|
|
@@ -1031,9 +1045,9 @@
|
|
|
1031
1045
|
*/
|
|
1032
1046
|
function prettifyMarkdown(content) {
|
|
1033
1047
|
try {
|
|
1034
|
-
return
|
|
1048
|
+
return standalone.format(content, {
|
|
1035
1049
|
parser: 'markdown',
|
|
1036
|
-
plugins: [parserHtml__default["default"]],
|
|
1050
|
+
plugins: [parserMarkdown__default["default"], parserHtml__default["default"]],
|
|
1037
1051
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
1038
1052
|
endOfLine: 'lf',
|
|
1039
1053
|
tabWidth: 4,
|
|
@@ -2535,6 +2549,7 @@
|
|
|
2535
2549
|
const errors = [];
|
|
2536
2550
|
const warnings = [];
|
|
2537
2551
|
let currentValue = {};
|
|
2552
|
+
let customTldr = null;
|
|
2538
2553
|
const partialResultSubject = new rxjs.Subject();
|
|
2539
2554
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2540
2555
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2545,6 +2560,9 @@
|
|
|
2545
2560
|
Object.assign(currentValue, newOngoingResult);
|
|
2546
2561
|
// <- TODO: assign deep
|
|
2547
2562
|
partialResultSubject.next(newOngoingResult);
|
|
2563
|
+
}, (tldrInfo) => {
|
|
2564
|
+
customTldr = tldrInfo;
|
|
2565
|
+
updatedAt = new Date();
|
|
2548
2566
|
});
|
|
2549
2567
|
finalResultPromise
|
|
2550
2568
|
.catch((error) => {
|
|
@@ -2598,6 +2616,78 @@
|
|
|
2598
2616
|
return status;
|
|
2599
2617
|
// <- Note: [1] --||--
|
|
2600
2618
|
},
|
|
2619
|
+
get tldr() {
|
|
2620
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2621
|
+
// Use custom tldr if available
|
|
2622
|
+
if (customTldr) {
|
|
2623
|
+
return customTldr;
|
|
2624
|
+
}
|
|
2625
|
+
// Fallback to default implementation
|
|
2626
|
+
const cv = currentValue;
|
|
2627
|
+
// If explicit percent is provided, use it
|
|
2628
|
+
let percentRaw = (_f = (_d = (_b = (_a = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _a === void 0 ? void 0 : _a.percent) !== null && _b !== void 0 ? _b : (_c = cv === null || cv === void 0 ? void 0 : cv.usage) === null || _c === void 0 ? void 0 : _c.percent) !== null && _d !== void 0 ? _d : (_e = cv === null || cv === void 0 ? void 0 : cv.progress) === null || _e === void 0 ? void 0 : _e.percent) !== null && _f !== void 0 ? _f : cv === null || cv === void 0 ? void 0 : cv.percent;
|
|
2629
|
+
// Simulate progress if not provided
|
|
2630
|
+
if (typeof percentRaw !== 'number') {
|
|
2631
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
|
2632
|
+
const now = new Date();
|
|
2633
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
|
2634
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
|
2635
|
+
// If subtasks are defined, split progress evenly
|
|
2636
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
|
2637
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
|
2638
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
|
2639
|
+
: 0;
|
|
2640
|
+
// Progress from completed subtasks
|
|
2641
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
|
2642
|
+
// Progress from elapsed time for current subtask
|
|
2643
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
2644
|
+
// Combine: completed subtasks + time progress for current subtask
|
|
2645
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
|
2646
|
+
if (status === 'FINISHED')
|
|
2647
|
+
percentRaw = 1;
|
|
2648
|
+
if (status === 'ERROR')
|
|
2649
|
+
percentRaw = 0;
|
|
2650
|
+
}
|
|
2651
|
+
// Clamp to [0,1]
|
|
2652
|
+
let percent = Number(percentRaw) || 0;
|
|
2653
|
+
if (percent < 0)
|
|
2654
|
+
percent = 0;
|
|
2655
|
+
if (percent > 1)
|
|
2656
|
+
percent = 1;
|
|
2657
|
+
// Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
|
|
2658
|
+
const messageFromResult = (_k = (_j = (_h = (_g = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _g === void 0 ? void 0 : _g.message) !== null && _h !== void 0 ? _h : cv === null || cv === void 0 ? void 0 : cv.message) !== null && _j !== void 0 ? _j : cv === null || cv === void 0 ? void 0 : cv.summary) !== null && _k !== void 0 ? _k : cv === null || cv === void 0 ? void 0 : cv.statusMessage;
|
|
2659
|
+
let message = messageFromResult;
|
|
2660
|
+
if (!message) {
|
|
2661
|
+
// If subtasks, show current subtask
|
|
2662
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
|
2663
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
|
2664
|
+
if (current && current.title) {
|
|
2665
|
+
message = `Working on ${current.title}`;
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
if (!message) {
|
|
2669
|
+
if (errors.length) {
|
|
2670
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
2671
|
+
}
|
|
2672
|
+
else if (warnings.length) {
|
|
2673
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
2674
|
+
}
|
|
2675
|
+
else if (status === 'FINISHED') {
|
|
2676
|
+
message = 'Finished';
|
|
2677
|
+
}
|
|
2678
|
+
else if (status === 'ERROR') {
|
|
2679
|
+
message = 'Error';
|
|
2680
|
+
}
|
|
2681
|
+
else {
|
|
2682
|
+
message = 'Running';
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
return {
|
|
2687
|
+
percent: percent,
|
|
2688
|
+
message,
|
|
2689
|
+
};
|
|
2690
|
+
},
|
|
2601
2691
|
get createdAt() {
|
|
2602
2692
|
return createdAt;
|
|
2603
2693
|
// <- Note: [1] --||--
|
|
@@ -2846,6 +2936,76 @@
|
|
|
2846
2936
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2847
2937
|
*/
|
|
2848
2938
|
|
|
2939
|
+
/**
|
|
2940
|
+
* Predefined profiles for LLM providers to maintain consistency across the application
|
|
2941
|
+
* These profiles represent each provider as a virtual persona in chat interfaces
|
|
2942
|
+
*
|
|
2943
|
+
* @private !!!!
|
|
2944
|
+
*/
|
|
2945
|
+
const LLM_PROVIDER_PROFILES = {
|
|
2946
|
+
OPENAI: {
|
|
2947
|
+
name: 'OPENAI',
|
|
2948
|
+
fullname: 'OpenAI GPT',
|
|
2949
|
+
color: '#10a37f', // OpenAI's signature green
|
|
2950
|
+
// Note: avatarSrc could be added when we have provider logos available
|
|
2951
|
+
},
|
|
2952
|
+
ANTHROPIC: {
|
|
2953
|
+
name: 'ANTHROPIC',
|
|
2954
|
+
fullname: 'Anthropic Claude',
|
|
2955
|
+
color: '#d97706', // Anthropic's orange/amber color
|
|
2956
|
+
},
|
|
2957
|
+
AZURE_OPENAI: {
|
|
2958
|
+
name: 'AZURE_OPENAI',
|
|
2959
|
+
fullname: 'Azure OpenAI',
|
|
2960
|
+
color: '#0078d4', // Microsoft Azure blue
|
|
2961
|
+
},
|
|
2962
|
+
GOOGLE: {
|
|
2963
|
+
name: 'GOOGLE',
|
|
2964
|
+
fullname: 'Google Gemini',
|
|
2965
|
+
color: '#4285f4', // Google blue
|
|
2966
|
+
},
|
|
2967
|
+
DEEPSEEK: {
|
|
2968
|
+
name: 'DEEPSEEK',
|
|
2969
|
+
fullname: 'DeepSeek',
|
|
2970
|
+
color: '#7c3aed', // Purple color for DeepSeek
|
|
2971
|
+
},
|
|
2972
|
+
OLLAMA: {
|
|
2973
|
+
name: 'OLLAMA',
|
|
2974
|
+
fullname: 'Ollama',
|
|
2975
|
+
color: '#059669', // Emerald green for local models
|
|
2976
|
+
},
|
|
2977
|
+
REMOTE: {
|
|
2978
|
+
name: 'REMOTE',
|
|
2979
|
+
fullname: 'Remote Server',
|
|
2980
|
+
color: '#6b7280', // Gray for remote/proxy connections
|
|
2981
|
+
},
|
|
2982
|
+
MOCKED_ECHO: {
|
|
2983
|
+
name: 'MOCKED_ECHO',
|
|
2984
|
+
fullname: 'Echo (Test)',
|
|
2985
|
+
color: '#8b5cf6', // Purple for test/mock tools
|
|
2986
|
+
},
|
|
2987
|
+
MOCKED_FAKE: {
|
|
2988
|
+
name: 'MOCKED_FAKE',
|
|
2989
|
+
fullname: 'Fake LLM (Test)',
|
|
2990
|
+
color: '#ec4899', // Pink for fake/test tools
|
|
2991
|
+
},
|
|
2992
|
+
VERCEL: {
|
|
2993
|
+
name: 'VERCEL',
|
|
2994
|
+
fullname: 'Vercel AI',
|
|
2995
|
+
color: '#000000', // Vercel's black
|
|
2996
|
+
},
|
|
2997
|
+
MULTIPLE: {
|
|
2998
|
+
name: 'MULTIPLE',
|
|
2999
|
+
fullname: 'Multiple Providers',
|
|
3000
|
+
color: '#6366f1', // Indigo for combined/multiple providers
|
|
3001
|
+
},
|
|
3002
|
+
};
|
|
3003
|
+
/**
|
|
3004
|
+
* TODO: Refactor this - each profile must be alongside the provider definition
|
|
3005
|
+
* TODO: Unite `AvatarProfileProps` and `ChatParticipant`
|
|
3006
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3007
|
+
*/
|
|
3008
|
+
|
|
2849
3009
|
/**
|
|
2850
3010
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
2851
3011
|
*
|
|
@@ -2871,7 +3031,7 @@
|
|
|
2871
3031
|
}
|
|
2872
3032
|
return spaceTrim__default["default"]((block) => `
|
|
2873
3033
|
${headLine}
|
|
2874
|
-
|
|
3034
|
+
|
|
2875
3035
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
2876
3036
|
`);
|
|
2877
3037
|
})
|
|
@@ -2882,6 +3042,9 @@
|
|
|
2882
3042
|
${block(innerModelsTitlesAndDescriptions)}
|
|
2883
3043
|
`);
|
|
2884
3044
|
}
|
|
3045
|
+
get profile() {
|
|
3046
|
+
return LLM_PROVIDER_PROFILES.MULTIPLE;
|
|
3047
|
+
}
|
|
2885
3048
|
/**
|
|
2886
3049
|
* Check the configuration of all execution tools
|
|
2887
3050
|
*/
|
|
@@ -2926,25 +3089,22 @@
|
|
|
2926
3089
|
const errors = [];
|
|
2927
3090
|
llm: for (const llmExecutionTools of this.llmExecutionTools) {
|
|
2928
3091
|
try {
|
|
2929
|
-
|
|
3092
|
+
switch (prompt.modelRequirements.modelVariant) {
|
|
2930
3093
|
case 'CHAT':
|
|
2931
3094
|
if (llmExecutionTools.callChatModel === undefined) {
|
|
2932
3095
|
continue llm;
|
|
2933
3096
|
}
|
|
2934
3097
|
return await llmExecutionTools.callChatModel(prompt);
|
|
2935
|
-
break variant;
|
|
2936
3098
|
case 'COMPLETION':
|
|
2937
3099
|
if (llmExecutionTools.callCompletionModel === undefined) {
|
|
2938
3100
|
continue llm;
|
|
2939
3101
|
}
|
|
2940
3102
|
return await llmExecutionTools.callCompletionModel(prompt);
|
|
2941
|
-
break variant;
|
|
2942
3103
|
case 'EMBEDDING':
|
|
2943
3104
|
if (llmExecutionTools.callEmbeddingModel === undefined) {
|
|
2944
3105
|
continue llm;
|
|
2945
3106
|
}
|
|
2946
3107
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
2947
|
-
break variant;
|
|
2948
3108
|
// <- case [🤖]:
|
|
2949
3109
|
default:
|
|
2950
3110
|
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
@@ -3097,7 +3257,7 @@
|
|
|
3097
3257
|
const result = await preparePersonaExecutor({
|
|
3098
3258
|
availableModels /* <- Note: Passing as JSON */,
|
|
3099
3259
|
personaDescription,
|
|
3100
|
-
}).asPromise();
|
|
3260
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3101
3261
|
const { outputParameters } = result;
|
|
3102
3262
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
3103
3263
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -3861,7 +4021,7 @@
|
|
|
3861
4021
|
});
|
|
3862
4022
|
const result = await prepareTitleExecutor({
|
|
3863
4023
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
3864
|
-
}).asPromise();
|
|
4024
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3865
4025
|
const { outputParameters } = result;
|
|
3866
4026
|
const { title: titleRaw } = outputParameters;
|
|
3867
4027
|
if (isVerbose) {
|
|
@@ -4955,7 +5115,7 @@
|
|
|
4955
5115
|
*/
|
|
4956
5116
|
async function executeAttempts(options) {
|
|
4957
5117
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
4958
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
|
|
5118
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
4959
5119
|
const $ongoingTaskResult = {
|
|
4960
5120
|
$result: null,
|
|
4961
5121
|
$resultString: null,
|
|
@@ -5199,6 +5359,10 @@
|
|
|
5199
5359
|
result: $ongoingTaskResult.$resultString,
|
|
5200
5360
|
error: error,
|
|
5201
5361
|
});
|
|
5362
|
+
// Report failed attempt
|
|
5363
|
+
onProgress({
|
|
5364
|
+
errors: [error],
|
|
5365
|
+
});
|
|
5202
5366
|
}
|
|
5203
5367
|
finally {
|
|
5204
5368
|
if (!isJokerAttempt &&
|
|
@@ -6072,15 +6236,74 @@
|
|
|
6072
6236
|
});
|
|
6073
6237
|
});
|
|
6074
6238
|
};
|
|
6075
|
-
const pipelineExecutor = (inputParameters) =>
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6239
|
+
const pipelineExecutor = (inputParameters) => {
|
|
6240
|
+
const startTime = new Date().getTime();
|
|
6241
|
+
return createTask({
|
|
6242
|
+
taskType: 'EXECUTION',
|
|
6243
|
+
title: pipeline.title,
|
|
6244
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6245
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6246
|
+
var _a, _b;
|
|
6247
|
+
updateOngoingResult(newOngoingResult);
|
|
6248
|
+
// Calculate and update tldr based on pipeline progress
|
|
6249
|
+
const cv = newOngoingResult;
|
|
6250
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
6251
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6252
|
+
let resolvedParameters = 0;
|
|
6253
|
+
let currentTaskTitle = '';
|
|
6254
|
+
// Get the resolved parameters from output parameters
|
|
6255
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6256
|
+
// Count how many output parameters have non-empty values
|
|
6257
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6258
|
+
}
|
|
6259
|
+
// Try to determine current task from execution report
|
|
6260
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
6261
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
6262
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
6263
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
6264
|
+
}
|
|
6265
|
+
}
|
|
6266
|
+
// Calculate base progress percentage
|
|
6267
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
6268
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
6269
|
+
if (resolvedParameters < totalParameters) {
|
|
6270
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
6271
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
6272
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
6273
|
+
// If we have time progress but no parameter progress, show time progress
|
|
6274
|
+
if (percent === 0 && timeProgress > 0) {
|
|
6275
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
6276
|
+
}
|
|
6277
|
+
else if (percent < 1) {
|
|
6278
|
+
// Add partial progress for current task
|
|
6279
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
6280
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
6281
|
+
}
|
|
6282
|
+
}
|
|
6283
|
+
// Clamp to [0,1]
|
|
6284
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6285
|
+
// Generate message
|
|
6286
|
+
let message = '';
|
|
6287
|
+
if (currentTaskTitle) {
|
|
6288
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
6289
|
+
}
|
|
6290
|
+
else if (resolvedParameters === 0) {
|
|
6291
|
+
message = 'Starting pipeline execution';
|
|
6292
|
+
}
|
|
6293
|
+
else if (resolvedParameters < totalParameters) {
|
|
6294
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
6295
|
+
}
|
|
6296
|
+
else {
|
|
6297
|
+
message = 'Completing pipeline execution';
|
|
6298
|
+
}
|
|
6299
|
+
updateTldr({
|
|
6300
|
+
percent: percent,
|
|
6301
|
+
message,
|
|
6302
|
+
});
|
|
6303
|
+
});
|
|
6304
|
+
},
|
|
6305
|
+
});
|
|
6306
|
+
};
|
|
6084
6307
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6085
6308
|
return pipelineExecutor;
|
|
6086
6309
|
}
|
|
@@ -6165,7 +6388,9 @@
|
|
|
6165
6388
|
},
|
|
6166
6389
|
});
|
|
6167
6390
|
const knowledgeContent = await source.asText();
|
|
6168
|
-
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise(
|
|
6391
|
+
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
|
|
6392
|
+
isCrashedOnError: true,
|
|
6393
|
+
});
|
|
6169
6394
|
const { outputParameters } = result;
|
|
6170
6395
|
const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
|
|
6171
6396
|
const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
@@ -6189,12 +6414,16 @@
|
|
|
6189
6414
|
];
|
|
6190
6415
|
*/
|
|
6191
6416
|
try {
|
|
6192
|
-
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise(
|
|
6417
|
+
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
|
|
6418
|
+
isCrashedOnError: true,
|
|
6419
|
+
});
|
|
6193
6420
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
6194
6421
|
title = spaceTrim__default["default"](titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
6195
6422
|
name = titleToName(title);
|
|
6196
6423
|
// --- Keywords
|
|
6197
|
-
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise(
|
|
6424
|
+
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
6425
|
+
isCrashedOnError: true,
|
|
6426
|
+
});
|
|
6198
6427
|
const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
|
|
6199
6428
|
keywords = (keywordsRaw || '')
|
|
6200
6429
|
.split(',')
|