@promptbook/documents 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,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('spacetrim'), require('child_process'), require('colors'), require('waitasecond'), 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', 'child_process', 'colors', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier', 'prettier/parser-
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-documents"] = {}, global.promises, global.spaceTrim, global.child_process, global.colors, global.waitasecond, global.cryptoJs, global.hexEncoder, global.path, global.
|
|
5
|
-
})(this, (function (exports, promises, spaceTrim, child_process, colors, waitasecond, cryptoJs, hexEncoder, path,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('spacetrim'), require('child_process'), require('colors'), require('waitasecond'), 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('crypto-js/sha256'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'spacetrim', 'child_process', 'colors', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier/parser-html', 'prettier/parser-markdown', 'prettier/standalone', 'crypto', 'rxjs', 'crypto-js/sha256', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-documents"] = {}, global.promises, global.spaceTrim, global.child_process, global.colors, global.waitasecond, global.cryptoJs, global.hexEncoder, global.path, global.parserHtml, global.parserMarkdown, global.standalone, global.crypto, global.rxjs, global.sha256, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, promises, spaceTrim, child_process, colors, waitasecond, cryptoJs, hexEncoder, path, parserHtml, parserMarkdown, standalone, crypto, rxjs, 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
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
11
11
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
12
12
|
var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
|
|
13
|
+
var parserMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(parserMarkdown);
|
|
13
14
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
14
15
|
|
|
15
16
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
* @generated
|
|
27
28
|
* @see https://github.com/webgptorg/promptbook
|
|
28
29
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0';
|
|
30
31
|
/**
|
|
31
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -218,6 +219,19 @@
|
|
|
218
219
|
* @public exported from `@promptbook/core`
|
|
219
220
|
*/
|
|
220
221
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
222
|
+
/**
|
|
223
|
+
* Default simulated duration for a task in milliseconds (used for progress reporting)
|
|
224
|
+
*
|
|
225
|
+
* @public exported from `@promptbook/core`
|
|
226
|
+
*/
|
|
227
|
+
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
228
|
+
/**
|
|
229
|
+
* API request timeout in milliseconds
|
|
230
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
231
|
+
*
|
|
232
|
+
* @public exported from `@promptbook/core`
|
|
233
|
+
*/
|
|
234
|
+
parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
221
235
|
/**
|
|
222
236
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
223
237
|
*
|
|
@@ -1209,9 +1223,9 @@
|
|
|
1209
1223
|
*/
|
|
1210
1224
|
function prettifyMarkdown(content) {
|
|
1211
1225
|
try {
|
|
1212
|
-
return
|
|
1226
|
+
return standalone.format(content, {
|
|
1213
1227
|
parser: 'markdown',
|
|
1214
|
-
plugins: [parserHtml__default["default"]],
|
|
1228
|
+
plugins: [parserMarkdown__default["default"], parserHtml__default["default"]],
|
|
1215
1229
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
1216
1230
|
endOfLine: 'lf',
|
|
1217
1231
|
tabWidth: 4,
|
|
@@ -2695,6 +2709,7 @@
|
|
|
2695
2709
|
const errors = [];
|
|
2696
2710
|
const warnings = [];
|
|
2697
2711
|
let currentValue = {};
|
|
2712
|
+
let customTldr = null;
|
|
2698
2713
|
const partialResultSubject = new rxjs.Subject();
|
|
2699
2714
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2700
2715
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2705,6 +2720,9 @@
|
|
|
2705
2720
|
Object.assign(currentValue, newOngoingResult);
|
|
2706
2721
|
// <- TODO: assign deep
|
|
2707
2722
|
partialResultSubject.next(newOngoingResult);
|
|
2723
|
+
}, (tldrInfo) => {
|
|
2724
|
+
customTldr = tldrInfo;
|
|
2725
|
+
updatedAt = new Date();
|
|
2708
2726
|
});
|
|
2709
2727
|
finalResultPromise
|
|
2710
2728
|
.catch((error) => {
|
|
@@ -2758,6 +2776,78 @@
|
|
|
2758
2776
|
return status;
|
|
2759
2777
|
// <- Note: [1] --||--
|
|
2760
2778
|
},
|
|
2779
|
+
get tldr() {
|
|
2780
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2781
|
+
// Use custom tldr if available
|
|
2782
|
+
if (customTldr) {
|
|
2783
|
+
return customTldr;
|
|
2784
|
+
}
|
|
2785
|
+
// Fallback to default implementation
|
|
2786
|
+
const cv = currentValue;
|
|
2787
|
+
// If explicit percent is provided, use it
|
|
2788
|
+
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;
|
|
2789
|
+
// Simulate progress if not provided
|
|
2790
|
+
if (typeof percentRaw !== 'number') {
|
|
2791
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
|
2792
|
+
const now = new Date();
|
|
2793
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
|
2794
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
|
2795
|
+
// If subtasks are defined, split progress evenly
|
|
2796
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
|
2797
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
|
2798
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
|
2799
|
+
: 0;
|
|
2800
|
+
// Progress from completed subtasks
|
|
2801
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
|
2802
|
+
// Progress from elapsed time for current subtask
|
|
2803
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
2804
|
+
// Combine: completed subtasks + time progress for current subtask
|
|
2805
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
|
2806
|
+
if (status === 'FINISHED')
|
|
2807
|
+
percentRaw = 1;
|
|
2808
|
+
if (status === 'ERROR')
|
|
2809
|
+
percentRaw = 0;
|
|
2810
|
+
}
|
|
2811
|
+
// Clamp to [0,1]
|
|
2812
|
+
let percent = Number(percentRaw) || 0;
|
|
2813
|
+
if (percent < 0)
|
|
2814
|
+
percent = 0;
|
|
2815
|
+
if (percent > 1)
|
|
2816
|
+
percent = 1;
|
|
2817
|
+
// Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
|
|
2818
|
+
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;
|
|
2819
|
+
let message = messageFromResult;
|
|
2820
|
+
if (!message) {
|
|
2821
|
+
// If subtasks, show current subtask
|
|
2822
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
|
2823
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
|
2824
|
+
if (current && current.title) {
|
|
2825
|
+
message = `Working on ${current.title}`;
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
if (!message) {
|
|
2829
|
+
if (errors.length) {
|
|
2830
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
2831
|
+
}
|
|
2832
|
+
else if (warnings.length) {
|
|
2833
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
2834
|
+
}
|
|
2835
|
+
else if (status === 'FINISHED') {
|
|
2836
|
+
message = 'Finished';
|
|
2837
|
+
}
|
|
2838
|
+
else if (status === 'ERROR') {
|
|
2839
|
+
message = 'Error';
|
|
2840
|
+
}
|
|
2841
|
+
else {
|
|
2842
|
+
message = 'Running';
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
return {
|
|
2847
|
+
percent: percent,
|
|
2848
|
+
message,
|
|
2849
|
+
};
|
|
2850
|
+
},
|
|
2761
2851
|
get createdAt() {
|
|
2762
2852
|
return createdAt;
|
|
2763
2853
|
// <- Note: [1] --||--
|
|
@@ -3006,6 +3096,76 @@
|
|
|
3006
3096
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3007
3097
|
*/
|
|
3008
3098
|
|
|
3099
|
+
/**
|
|
3100
|
+
* Predefined profiles for LLM providers to maintain consistency across the application
|
|
3101
|
+
* These profiles represent each provider as a virtual persona in chat interfaces
|
|
3102
|
+
*
|
|
3103
|
+
* @private !!!!
|
|
3104
|
+
*/
|
|
3105
|
+
const LLM_PROVIDER_PROFILES = {
|
|
3106
|
+
OPENAI: {
|
|
3107
|
+
name: 'OPENAI',
|
|
3108
|
+
fullname: 'OpenAI GPT',
|
|
3109
|
+
color: '#10a37f', // OpenAI's signature green
|
|
3110
|
+
// Note: avatarSrc could be added when we have provider logos available
|
|
3111
|
+
},
|
|
3112
|
+
ANTHROPIC: {
|
|
3113
|
+
name: 'ANTHROPIC',
|
|
3114
|
+
fullname: 'Anthropic Claude',
|
|
3115
|
+
color: '#d97706', // Anthropic's orange/amber color
|
|
3116
|
+
},
|
|
3117
|
+
AZURE_OPENAI: {
|
|
3118
|
+
name: 'AZURE_OPENAI',
|
|
3119
|
+
fullname: 'Azure OpenAI',
|
|
3120
|
+
color: '#0078d4', // Microsoft Azure blue
|
|
3121
|
+
},
|
|
3122
|
+
GOOGLE: {
|
|
3123
|
+
name: 'GOOGLE',
|
|
3124
|
+
fullname: 'Google Gemini',
|
|
3125
|
+
color: '#4285f4', // Google blue
|
|
3126
|
+
},
|
|
3127
|
+
DEEPSEEK: {
|
|
3128
|
+
name: 'DEEPSEEK',
|
|
3129
|
+
fullname: 'DeepSeek',
|
|
3130
|
+
color: '#7c3aed', // Purple color for DeepSeek
|
|
3131
|
+
},
|
|
3132
|
+
OLLAMA: {
|
|
3133
|
+
name: 'OLLAMA',
|
|
3134
|
+
fullname: 'Ollama',
|
|
3135
|
+
color: '#059669', // Emerald green for local models
|
|
3136
|
+
},
|
|
3137
|
+
REMOTE: {
|
|
3138
|
+
name: 'REMOTE',
|
|
3139
|
+
fullname: 'Remote Server',
|
|
3140
|
+
color: '#6b7280', // Gray for remote/proxy connections
|
|
3141
|
+
},
|
|
3142
|
+
MOCKED_ECHO: {
|
|
3143
|
+
name: 'MOCKED_ECHO',
|
|
3144
|
+
fullname: 'Echo (Test)',
|
|
3145
|
+
color: '#8b5cf6', // Purple for test/mock tools
|
|
3146
|
+
},
|
|
3147
|
+
MOCKED_FAKE: {
|
|
3148
|
+
name: 'MOCKED_FAKE',
|
|
3149
|
+
fullname: 'Fake LLM (Test)',
|
|
3150
|
+
color: '#ec4899', // Pink for fake/test tools
|
|
3151
|
+
},
|
|
3152
|
+
VERCEL: {
|
|
3153
|
+
name: 'VERCEL',
|
|
3154
|
+
fullname: 'Vercel AI',
|
|
3155
|
+
color: '#000000', // Vercel's black
|
|
3156
|
+
},
|
|
3157
|
+
MULTIPLE: {
|
|
3158
|
+
name: 'MULTIPLE',
|
|
3159
|
+
fullname: 'Multiple Providers',
|
|
3160
|
+
color: '#6366f1', // Indigo for combined/multiple providers
|
|
3161
|
+
},
|
|
3162
|
+
};
|
|
3163
|
+
/**
|
|
3164
|
+
* TODO: Refactor this - each profile must be alongside the provider definition
|
|
3165
|
+
* TODO: Unite `AvatarProfileProps` and `ChatParticipant`
|
|
3166
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3167
|
+
*/
|
|
3168
|
+
|
|
3009
3169
|
/**
|
|
3010
3170
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
3011
3171
|
*
|
|
@@ -3031,7 +3191,7 @@
|
|
|
3031
3191
|
}
|
|
3032
3192
|
return spaceTrim__default["default"]((block) => `
|
|
3033
3193
|
${headLine}
|
|
3034
|
-
|
|
3194
|
+
|
|
3035
3195
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
3036
3196
|
`);
|
|
3037
3197
|
})
|
|
@@ -3042,6 +3202,9 @@
|
|
|
3042
3202
|
${block(innerModelsTitlesAndDescriptions)}
|
|
3043
3203
|
`);
|
|
3044
3204
|
}
|
|
3205
|
+
get profile() {
|
|
3206
|
+
return LLM_PROVIDER_PROFILES.MULTIPLE;
|
|
3207
|
+
}
|
|
3045
3208
|
/**
|
|
3046
3209
|
* Check the configuration of all execution tools
|
|
3047
3210
|
*/
|
|
@@ -3086,25 +3249,22 @@
|
|
|
3086
3249
|
const errors = [];
|
|
3087
3250
|
llm: for (const llmExecutionTools of this.llmExecutionTools) {
|
|
3088
3251
|
try {
|
|
3089
|
-
|
|
3252
|
+
switch (prompt.modelRequirements.modelVariant) {
|
|
3090
3253
|
case 'CHAT':
|
|
3091
3254
|
if (llmExecutionTools.callChatModel === undefined) {
|
|
3092
3255
|
continue llm;
|
|
3093
3256
|
}
|
|
3094
3257
|
return await llmExecutionTools.callChatModel(prompt);
|
|
3095
|
-
break variant;
|
|
3096
3258
|
case 'COMPLETION':
|
|
3097
3259
|
if (llmExecutionTools.callCompletionModel === undefined) {
|
|
3098
3260
|
continue llm;
|
|
3099
3261
|
}
|
|
3100
3262
|
return await llmExecutionTools.callCompletionModel(prompt);
|
|
3101
|
-
break variant;
|
|
3102
3263
|
case 'EMBEDDING':
|
|
3103
3264
|
if (llmExecutionTools.callEmbeddingModel === undefined) {
|
|
3104
3265
|
continue llm;
|
|
3105
3266
|
}
|
|
3106
3267
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
3107
|
-
break variant;
|
|
3108
3268
|
// <- case [🤖]:
|
|
3109
3269
|
default:
|
|
3110
3270
|
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
@@ -3257,7 +3417,7 @@
|
|
|
3257
3417
|
const result = await preparePersonaExecutor({
|
|
3258
3418
|
availableModels /* <- Note: Passing as JSON */,
|
|
3259
3419
|
personaDescription,
|
|
3260
|
-
}).asPromise();
|
|
3420
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3261
3421
|
const { outputParameters } = result;
|
|
3262
3422
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
3263
3423
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -4011,7 +4171,7 @@
|
|
|
4011
4171
|
});
|
|
4012
4172
|
const result = await prepareTitleExecutor({
|
|
4013
4173
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
4014
|
-
}).asPromise();
|
|
4174
|
+
}).asPromise({ isCrashedOnError: true });
|
|
4015
4175
|
const { outputParameters } = result;
|
|
4016
4176
|
const { title: titleRaw } = outputParameters;
|
|
4017
4177
|
if (isVerbose) {
|
|
@@ -5105,7 +5265,7 @@
|
|
|
5105
5265
|
*/
|
|
5106
5266
|
async function executeAttempts(options) {
|
|
5107
5267
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
5108
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
|
|
5268
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
5109
5269
|
const $ongoingTaskResult = {
|
|
5110
5270
|
$result: null,
|
|
5111
5271
|
$resultString: null,
|
|
@@ -5349,6 +5509,10 @@
|
|
|
5349
5509
|
result: $ongoingTaskResult.$resultString,
|
|
5350
5510
|
error: error,
|
|
5351
5511
|
});
|
|
5512
|
+
// Report failed attempt
|
|
5513
|
+
onProgress({
|
|
5514
|
+
errors: [error],
|
|
5515
|
+
});
|
|
5352
5516
|
}
|
|
5353
5517
|
finally {
|
|
5354
5518
|
if (!isJokerAttempt &&
|
|
@@ -6222,15 +6386,74 @@
|
|
|
6222
6386
|
});
|
|
6223
6387
|
});
|
|
6224
6388
|
};
|
|
6225
|
-
const pipelineExecutor = (inputParameters) =>
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6389
|
+
const pipelineExecutor = (inputParameters) => {
|
|
6390
|
+
const startTime = new Date().getTime();
|
|
6391
|
+
return createTask({
|
|
6392
|
+
taskType: 'EXECUTION',
|
|
6393
|
+
title: pipeline.title,
|
|
6394
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6395
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6396
|
+
var _a, _b;
|
|
6397
|
+
updateOngoingResult(newOngoingResult);
|
|
6398
|
+
// Calculate and update tldr based on pipeline progress
|
|
6399
|
+
const cv = newOngoingResult;
|
|
6400
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
6401
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6402
|
+
let resolvedParameters = 0;
|
|
6403
|
+
let currentTaskTitle = '';
|
|
6404
|
+
// Get the resolved parameters from output parameters
|
|
6405
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6406
|
+
// Count how many output parameters have non-empty values
|
|
6407
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6408
|
+
}
|
|
6409
|
+
// Try to determine current task from execution report
|
|
6410
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
6411
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
6412
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
6413
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
6414
|
+
}
|
|
6415
|
+
}
|
|
6416
|
+
// Calculate base progress percentage
|
|
6417
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
6418
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
6419
|
+
if (resolvedParameters < totalParameters) {
|
|
6420
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
6421
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
6422
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
6423
|
+
// If we have time progress but no parameter progress, show time progress
|
|
6424
|
+
if (percent === 0 && timeProgress > 0) {
|
|
6425
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
6426
|
+
}
|
|
6427
|
+
else if (percent < 1) {
|
|
6428
|
+
// Add partial progress for current task
|
|
6429
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
6430
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
6431
|
+
}
|
|
6432
|
+
}
|
|
6433
|
+
// Clamp to [0,1]
|
|
6434
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6435
|
+
// Generate message
|
|
6436
|
+
let message = '';
|
|
6437
|
+
if (currentTaskTitle) {
|
|
6438
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
6439
|
+
}
|
|
6440
|
+
else if (resolvedParameters === 0) {
|
|
6441
|
+
message = 'Starting pipeline execution';
|
|
6442
|
+
}
|
|
6443
|
+
else if (resolvedParameters < totalParameters) {
|
|
6444
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
6445
|
+
}
|
|
6446
|
+
else {
|
|
6447
|
+
message = 'Completing pipeline execution';
|
|
6448
|
+
}
|
|
6449
|
+
updateTldr({
|
|
6450
|
+
percent: percent,
|
|
6451
|
+
message,
|
|
6452
|
+
});
|
|
6453
|
+
});
|
|
6454
|
+
},
|
|
6455
|
+
});
|
|
6456
|
+
};
|
|
6234
6457
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6235
6458
|
return pipelineExecutor;
|
|
6236
6459
|
}
|
|
@@ -6315,7 +6538,9 @@
|
|
|
6315
6538
|
},
|
|
6316
6539
|
});
|
|
6317
6540
|
const knowledgeContent = await source.asText();
|
|
6318
|
-
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise(
|
|
6541
|
+
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
|
|
6542
|
+
isCrashedOnError: true,
|
|
6543
|
+
});
|
|
6319
6544
|
const { outputParameters } = result;
|
|
6320
6545
|
const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
|
|
6321
6546
|
const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
@@ -6339,12 +6564,16 @@
|
|
|
6339
6564
|
];
|
|
6340
6565
|
*/
|
|
6341
6566
|
try {
|
|
6342
|
-
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise(
|
|
6567
|
+
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
|
|
6568
|
+
isCrashedOnError: true,
|
|
6569
|
+
});
|
|
6343
6570
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
6344
6571
|
title = spaceTrim__default["default"](titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
6345
6572
|
name = titleToName(title);
|
|
6346
6573
|
// --- Keywords
|
|
6347
|
-
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise(
|
|
6574
|
+
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
6575
|
+
isCrashedOnError: true,
|
|
6576
|
+
});
|
|
6348
6577
|
const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
|
|
6349
6578
|
keywords = (keywordsRaw || '')
|
|
6350
6579
|
.split(',')
|