@promptbook/markdown-utils 0.100.0-5 → 0.100.0-61
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 +2 -8
- 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 +1 -2
- 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,13 +1,14 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.spaceTrim, global.
|
|
5
|
-
})(this, (function (exports, spaceTrim,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier/parser-html'), require('prettier/parser-markdown'), require('prettier/standalone'), require('crypto'), require('rxjs'), require('waitasecond'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('path'), require('crypto-js'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier/parser-html', 'prettier/parser-markdown', 'prettier/standalone', 'crypto', 'rxjs', 'waitasecond', 'crypto-js/enc-hex', 'crypto-js/sha256', 'path', 'crypto-js', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.spaceTrim, global.parserHtml, global.parserMarkdown, global.standalone, global.crypto, global.rxjs, global.waitasecond, global.hexEncoder, global.sha256, global.path, global.cryptoJs, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, spaceTrim, parserHtml, parserMarkdown, standalone, crypto, rxjs, waitasecond, hexEncoder, sha256, path, cryptoJs, 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 parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
|
|
11
|
+
var parserMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(parserMarkdown);
|
|
11
12
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
12
13
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
13
14
|
|
|
@@ -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-61';
|
|
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
|
|
@@ -347,6 +348,19 @@
|
|
|
347
348
|
* @public exported from `@promptbook/core`
|
|
348
349
|
*/
|
|
349
350
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
351
|
+
/**
|
|
352
|
+
* Default simulated duration for a task in milliseconds (used for progress reporting)
|
|
353
|
+
*
|
|
354
|
+
* @public exported from `@promptbook/core`
|
|
355
|
+
*/
|
|
356
|
+
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
357
|
+
/**
|
|
358
|
+
* API request timeout in milliseconds
|
|
359
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
360
|
+
*
|
|
361
|
+
* @public exported from `@promptbook/core`
|
|
362
|
+
*/
|
|
363
|
+
parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
350
364
|
/**
|
|
351
365
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
352
366
|
*
|
|
@@ -685,9 +699,9 @@
|
|
|
685
699
|
*/
|
|
686
700
|
function prettifyMarkdown(content) {
|
|
687
701
|
try {
|
|
688
|
-
return
|
|
702
|
+
return standalone.format(content, {
|
|
689
703
|
parser: 'markdown',
|
|
690
|
-
plugins: [parserHtml__default["default"]],
|
|
704
|
+
plugins: [parserMarkdown__default["default"], parserHtml__default["default"]],
|
|
691
705
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
692
706
|
endOfLine: 'lf',
|
|
693
707
|
tabWidth: 4,
|
|
@@ -2206,6 +2220,7 @@
|
|
|
2206
2220
|
const errors = [];
|
|
2207
2221
|
const warnings = [];
|
|
2208
2222
|
let currentValue = {};
|
|
2223
|
+
let customTldr = null;
|
|
2209
2224
|
const partialResultSubject = new rxjs.Subject();
|
|
2210
2225
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2211
2226
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2216,6 +2231,9 @@
|
|
|
2216
2231
|
Object.assign(currentValue, newOngoingResult);
|
|
2217
2232
|
// <- TODO: assign deep
|
|
2218
2233
|
partialResultSubject.next(newOngoingResult);
|
|
2234
|
+
}, (tldrInfo) => {
|
|
2235
|
+
customTldr = tldrInfo;
|
|
2236
|
+
updatedAt = new Date();
|
|
2219
2237
|
});
|
|
2220
2238
|
finalResultPromise
|
|
2221
2239
|
.catch((error) => {
|
|
@@ -2269,6 +2287,78 @@
|
|
|
2269
2287
|
return status;
|
|
2270
2288
|
// <- Note: [1] --||--
|
|
2271
2289
|
},
|
|
2290
|
+
get tldr() {
|
|
2291
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2292
|
+
// Use custom tldr if available
|
|
2293
|
+
if (customTldr) {
|
|
2294
|
+
return customTldr;
|
|
2295
|
+
}
|
|
2296
|
+
// Fallback to default implementation
|
|
2297
|
+
const cv = currentValue;
|
|
2298
|
+
// If explicit percent is provided, use it
|
|
2299
|
+
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;
|
|
2300
|
+
// Simulate progress if not provided
|
|
2301
|
+
if (typeof percentRaw !== 'number') {
|
|
2302
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
|
2303
|
+
const now = new Date();
|
|
2304
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
|
2305
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
|
2306
|
+
// If subtasks are defined, split progress evenly
|
|
2307
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
|
2308
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
|
2309
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
|
2310
|
+
: 0;
|
|
2311
|
+
// Progress from completed subtasks
|
|
2312
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
|
2313
|
+
// Progress from elapsed time for current subtask
|
|
2314
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
2315
|
+
// Combine: completed subtasks + time progress for current subtask
|
|
2316
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
|
2317
|
+
if (status === 'FINISHED')
|
|
2318
|
+
percentRaw = 1;
|
|
2319
|
+
if (status === 'ERROR')
|
|
2320
|
+
percentRaw = 0;
|
|
2321
|
+
}
|
|
2322
|
+
// Clamp to [0,1]
|
|
2323
|
+
let percent = Number(percentRaw) || 0;
|
|
2324
|
+
if (percent < 0)
|
|
2325
|
+
percent = 0;
|
|
2326
|
+
if (percent > 1)
|
|
2327
|
+
percent = 1;
|
|
2328
|
+
// Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
|
|
2329
|
+
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;
|
|
2330
|
+
let message = messageFromResult;
|
|
2331
|
+
if (!message) {
|
|
2332
|
+
// If subtasks, show current subtask
|
|
2333
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
|
2334
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
|
2335
|
+
if (current && current.title) {
|
|
2336
|
+
message = `Working on ${current.title}`;
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
if (!message) {
|
|
2340
|
+
if (errors.length) {
|
|
2341
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
2342
|
+
}
|
|
2343
|
+
else if (warnings.length) {
|
|
2344
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
2345
|
+
}
|
|
2346
|
+
else if (status === 'FINISHED') {
|
|
2347
|
+
message = 'Finished';
|
|
2348
|
+
}
|
|
2349
|
+
else if (status === 'ERROR') {
|
|
2350
|
+
message = 'Error';
|
|
2351
|
+
}
|
|
2352
|
+
else {
|
|
2353
|
+
message = 'Running';
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
return {
|
|
2358
|
+
percent: percent,
|
|
2359
|
+
message,
|
|
2360
|
+
};
|
|
2361
|
+
},
|
|
2272
2362
|
get createdAt() {
|
|
2273
2363
|
return createdAt;
|
|
2274
2364
|
// <- Note: [1] --||--
|
|
@@ -2517,6 +2607,76 @@
|
|
|
2517
2607
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2518
2608
|
*/
|
|
2519
2609
|
|
|
2610
|
+
/**
|
|
2611
|
+
* Predefined profiles for LLM providers to maintain consistency across the application
|
|
2612
|
+
* These profiles represent each provider as a virtual persona in chat interfaces
|
|
2613
|
+
*
|
|
2614
|
+
* @private !!!!
|
|
2615
|
+
*/
|
|
2616
|
+
const LLM_PROVIDER_PROFILES = {
|
|
2617
|
+
OPENAI: {
|
|
2618
|
+
name: 'OPENAI',
|
|
2619
|
+
fullname: 'OpenAI GPT',
|
|
2620
|
+
color: '#10a37f', // OpenAI's signature green
|
|
2621
|
+
// Note: avatarSrc could be added when we have provider logos available
|
|
2622
|
+
},
|
|
2623
|
+
ANTHROPIC: {
|
|
2624
|
+
name: 'ANTHROPIC',
|
|
2625
|
+
fullname: 'Anthropic Claude',
|
|
2626
|
+
color: '#d97706', // Anthropic's orange/amber color
|
|
2627
|
+
},
|
|
2628
|
+
AZURE_OPENAI: {
|
|
2629
|
+
name: 'AZURE_OPENAI',
|
|
2630
|
+
fullname: 'Azure OpenAI',
|
|
2631
|
+
color: '#0078d4', // Microsoft Azure blue
|
|
2632
|
+
},
|
|
2633
|
+
GOOGLE: {
|
|
2634
|
+
name: 'GOOGLE',
|
|
2635
|
+
fullname: 'Google Gemini',
|
|
2636
|
+
color: '#4285f4', // Google blue
|
|
2637
|
+
},
|
|
2638
|
+
DEEPSEEK: {
|
|
2639
|
+
name: 'DEEPSEEK',
|
|
2640
|
+
fullname: 'DeepSeek',
|
|
2641
|
+
color: '#7c3aed', // Purple color for DeepSeek
|
|
2642
|
+
},
|
|
2643
|
+
OLLAMA: {
|
|
2644
|
+
name: 'OLLAMA',
|
|
2645
|
+
fullname: 'Ollama',
|
|
2646
|
+
color: '#059669', // Emerald green for local models
|
|
2647
|
+
},
|
|
2648
|
+
REMOTE: {
|
|
2649
|
+
name: 'REMOTE',
|
|
2650
|
+
fullname: 'Remote Server',
|
|
2651
|
+
color: '#6b7280', // Gray for remote/proxy connections
|
|
2652
|
+
},
|
|
2653
|
+
MOCKED_ECHO: {
|
|
2654
|
+
name: 'MOCKED_ECHO',
|
|
2655
|
+
fullname: 'Echo (Test)',
|
|
2656
|
+
color: '#8b5cf6', // Purple for test/mock tools
|
|
2657
|
+
},
|
|
2658
|
+
MOCKED_FAKE: {
|
|
2659
|
+
name: 'MOCKED_FAKE',
|
|
2660
|
+
fullname: 'Fake LLM (Test)',
|
|
2661
|
+
color: '#ec4899', // Pink for fake/test tools
|
|
2662
|
+
},
|
|
2663
|
+
VERCEL: {
|
|
2664
|
+
name: 'VERCEL',
|
|
2665
|
+
fullname: 'Vercel AI',
|
|
2666
|
+
color: '#000000', // Vercel's black
|
|
2667
|
+
},
|
|
2668
|
+
MULTIPLE: {
|
|
2669
|
+
name: 'MULTIPLE',
|
|
2670
|
+
fullname: 'Multiple Providers',
|
|
2671
|
+
color: '#6366f1', // Indigo for combined/multiple providers
|
|
2672
|
+
},
|
|
2673
|
+
};
|
|
2674
|
+
/**
|
|
2675
|
+
* TODO: Refactor this - each profile must be alongside the provider definition
|
|
2676
|
+
* TODO: Unite `AvatarProfileProps` and `ChatParticipant`
|
|
2677
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2678
|
+
*/
|
|
2679
|
+
|
|
2520
2680
|
/**
|
|
2521
2681
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
2522
2682
|
*
|
|
@@ -2542,7 +2702,7 @@
|
|
|
2542
2702
|
}
|
|
2543
2703
|
return spaceTrim__default["default"]((block) => `
|
|
2544
2704
|
${headLine}
|
|
2545
|
-
|
|
2705
|
+
|
|
2546
2706
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
2547
2707
|
`);
|
|
2548
2708
|
})
|
|
@@ -2553,6 +2713,9 @@
|
|
|
2553
2713
|
${block(innerModelsTitlesAndDescriptions)}
|
|
2554
2714
|
`);
|
|
2555
2715
|
}
|
|
2716
|
+
get profile() {
|
|
2717
|
+
return LLM_PROVIDER_PROFILES.MULTIPLE;
|
|
2718
|
+
}
|
|
2556
2719
|
/**
|
|
2557
2720
|
* Check the configuration of all execution tools
|
|
2558
2721
|
*/
|
|
@@ -2597,25 +2760,22 @@
|
|
|
2597
2760
|
const errors = [];
|
|
2598
2761
|
llm: for (const llmExecutionTools of this.llmExecutionTools) {
|
|
2599
2762
|
try {
|
|
2600
|
-
|
|
2763
|
+
switch (prompt.modelRequirements.modelVariant) {
|
|
2601
2764
|
case 'CHAT':
|
|
2602
2765
|
if (llmExecutionTools.callChatModel === undefined) {
|
|
2603
2766
|
continue llm;
|
|
2604
2767
|
}
|
|
2605
2768
|
return await llmExecutionTools.callChatModel(prompt);
|
|
2606
|
-
break variant;
|
|
2607
2769
|
case 'COMPLETION':
|
|
2608
2770
|
if (llmExecutionTools.callCompletionModel === undefined) {
|
|
2609
2771
|
continue llm;
|
|
2610
2772
|
}
|
|
2611
2773
|
return await llmExecutionTools.callCompletionModel(prompt);
|
|
2612
|
-
break variant;
|
|
2613
2774
|
case 'EMBEDDING':
|
|
2614
2775
|
if (llmExecutionTools.callEmbeddingModel === undefined) {
|
|
2615
2776
|
continue llm;
|
|
2616
2777
|
}
|
|
2617
2778
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
2618
|
-
break variant;
|
|
2619
2779
|
// <- case [🤖]:
|
|
2620
2780
|
default:
|
|
2621
2781
|
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
@@ -2768,7 +2928,7 @@
|
|
|
2768
2928
|
const result = await preparePersonaExecutor({
|
|
2769
2929
|
availableModels /* <- Note: Passing as JSON */,
|
|
2770
2930
|
personaDescription,
|
|
2771
|
-
}).asPromise();
|
|
2931
|
+
}).asPromise({ isCrashedOnError: true });
|
|
2772
2932
|
const { outputParameters } = result;
|
|
2773
2933
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
2774
2934
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -3919,7 +4079,7 @@
|
|
|
3919
4079
|
});
|
|
3920
4080
|
const result = await prepareTitleExecutor({
|
|
3921
4081
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
3922
|
-
}).asPromise();
|
|
4082
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3923
4083
|
const { outputParameters } = result;
|
|
3924
4084
|
const { title: titleRaw } = outputParameters;
|
|
3925
4085
|
if (isVerbose) {
|
|
@@ -4911,7 +5071,7 @@
|
|
|
4911
5071
|
*/
|
|
4912
5072
|
async function executeAttempts(options) {
|
|
4913
5073
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
4914
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
|
|
5074
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
4915
5075
|
const $ongoingTaskResult = {
|
|
4916
5076
|
$result: null,
|
|
4917
5077
|
$resultString: null,
|
|
@@ -5155,6 +5315,10 @@
|
|
|
5155
5315
|
result: $ongoingTaskResult.$resultString,
|
|
5156
5316
|
error: error,
|
|
5157
5317
|
});
|
|
5318
|
+
// Report failed attempt
|
|
5319
|
+
onProgress({
|
|
5320
|
+
errors: [error],
|
|
5321
|
+
});
|
|
5158
5322
|
}
|
|
5159
5323
|
finally {
|
|
5160
5324
|
if (!isJokerAttempt &&
|
|
@@ -6028,15 +6192,74 @@
|
|
|
6028
6192
|
});
|
|
6029
6193
|
});
|
|
6030
6194
|
};
|
|
6031
|
-
const pipelineExecutor = (inputParameters) =>
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6195
|
+
const pipelineExecutor = (inputParameters) => {
|
|
6196
|
+
const startTime = new Date().getTime();
|
|
6197
|
+
return createTask({
|
|
6198
|
+
taskType: 'EXECUTION',
|
|
6199
|
+
title: pipeline.title,
|
|
6200
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6201
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6202
|
+
var _a, _b;
|
|
6203
|
+
updateOngoingResult(newOngoingResult);
|
|
6204
|
+
// Calculate and update tldr based on pipeline progress
|
|
6205
|
+
const cv = newOngoingResult;
|
|
6206
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
6207
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6208
|
+
let resolvedParameters = 0;
|
|
6209
|
+
let currentTaskTitle = '';
|
|
6210
|
+
// Get the resolved parameters from output parameters
|
|
6211
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6212
|
+
// Count how many output parameters have non-empty values
|
|
6213
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6214
|
+
}
|
|
6215
|
+
// Try to determine current task from execution report
|
|
6216
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
6217
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
6218
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
6219
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
6220
|
+
}
|
|
6221
|
+
}
|
|
6222
|
+
// Calculate base progress percentage
|
|
6223
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
6224
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
6225
|
+
if (resolvedParameters < totalParameters) {
|
|
6226
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
6227
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
6228
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
6229
|
+
// If we have time progress but no parameter progress, show time progress
|
|
6230
|
+
if (percent === 0 && timeProgress > 0) {
|
|
6231
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
6232
|
+
}
|
|
6233
|
+
else if (percent < 1) {
|
|
6234
|
+
// Add partial progress for current task
|
|
6235
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
6236
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
6237
|
+
}
|
|
6238
|
+
}
|
|
6239
|
+
// Clamp to [0,1]
|
|
6240
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6241
|
+
// Generate message
|
|
6242
|
+
let message = '';
|
|
6243
|
+
if (currentTaskTitle) {
|
|
6244
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
6245
|
+
}
|
|
6246
|
+
else if (resolvedParameters === 0) {
|
|
6247
|
+
message = 'Starting pipeline execution';
|
|
6248
|
+
}
|
|
6249
|
+
else if (resolvedParameters < totalParameters) {
|
|
6250
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
6251
|
+
}
|
|
6252
|
+
else {
|
|
6253
|
+
message = 'Completing pipeline execution';
|
|
6254
|
+
}
|
|
6255
|
+
updateTldr({
|
|
6256
|
+
percent: percent,
|
|
6257
|
+
message,
|
|
6258
|
+
});
|
|
6259
|
+
});
|
|
6260
|
+
},
|
|
6261
|
+
});
|
|
6262
|
+
};
|
|
6040
6263
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6041
6264
|
return pipelineExecutor;
|
|
6042
6265
|
}
|
|
@@ -6121,7 +6344,9 @@
|
|
|
6121
6344
|
},
|
|
6122
6345
|
});
|
|
6123
6346
|
const knowledgeContent = await source.asText();
|
|
6124
|
-
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise(
|
|
6347
|
+
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
|
|
6348
|
+
isCrashedOnError: true,
|
|
6349
|
+
});
|
|
6125
6350
|
const { outputParameters } = result;
|
|
6126
6351
|
const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
|
|
6127
6352
|
const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
@@ -6145,12 +6370,16 @@
|
|
|
6145
6370
|
];
|
|
6146
6371
|
*/
|
|
6147
6372
|
try {
|
|
6148
|
-
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise(
|
|
6373
|
+
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
|
|
6374
|
+
isCrashedOnError: true,
|
|
6375
|
+
});
|
|
6149
6376
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
6150
6377
|
title = spaceTrim__default["default"](titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
6151
6378
|
name = titleToName(title);
|
|
6152
6379
|
// --- Keywords
|
|
6153
|
-
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise(
|
|
6380
|
+
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
6381
|
+
isCrashedOnError: true,
|
|
6382
|
+
});
|
|
6154
6383
|
const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
|
|
6155
6384
|
keywords = (keywordsRaw || '')
|
|
6156
6385
|
.split(',')
|