@promptbook/legacy-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/README.md
CHANGED
|
@@ -10,14 +10,18 @@ Write AI applications using plain human language across multiple models and plat
|
|
|
10
10
|
[ Promptbook](https://badge.fury.io/js/promptbook.svg)](https://www.npmjs.com/package/promptbook)
|
|
11
11
|
[ Promptbook](https://packagequality.com/shield/promptbook.svg)](https://packagequality.com/#?package=promptbook)
|
|
12
12
|
[](https://snyk.io/test/github/webgptorg/promptbook)
|
|
13
|
-
[](https://github.com/webgptorg/promptbook/actions/workflows/test-books.yml)
|
|
14
|
+
[](https://github.com/webgptorg/promptbook/actions/workflows/test-build.yml)
|
|
15
|
+
[](https://github.com/webgptorg/promptbook/actions/workflows/test-lint.yml)
|
|
16
|
+
[](https://github.com/webgptorg/promptbook/actions/workflows/test-spell-check.yml)
|
|
17
|
+
[](https://github.com/webgptorg/promptbook/actions/workflows/test-types.yml)
|
|
15
18
|
[](https://github.com/webgptorg/promptbook/issues)
|
|
16
19
|
|
|
17
20
|
|
|
18
21
|
|
|
19
22
|
## 🌟 New Features
|
|
20
23
|
|
|
24
|
+
- 🚀 **GPT-5 Support** - Now includes OpenAI's most advanced language model with unprecedented reasoning capabilities and 200K context window
|
|
21
25
|
- 💡 VS Code support for `.book` files with syntax highlighting and IntelliSense
|
|
22
26
|
- 🐳 Official Docker image (`hejny/promptbook`) for seamless containerized usage
|
|
23
27
|
- 🔥 Native support for OpenAI `o3-mini`, GPT-4 and other leading LLMs
|
|
@@ -25,10 +29,6 @@ Write AI applications using plain human language across multiple models and plat
|
|
|
25
29
|
|
|
26
30
|
|
|
27
31
|
|
|
28
|
-
<blockquote style="color: #ff8811">
|
|
29
|
-
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
30
|
-
</blockquote>
|
|
31
|
-
|
|
32
32
|
## 📦 Package `@promptbook/legacy-documents`
|
|
33
33
|
|
|
34
34
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
@@ -62,8 +62,6 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
62
62
|
|
|
63
63
|
During the computer revolution, we have seen [multiple generations of computer languages](https://github.com/webgptorg/promptbook/discussions/180), from the physical rewiring of the vacuum tubes through low-level machine code to the high-level languages like Python or JavaScript. And now, we're on the edge of the **next revolution**!
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
65
|
It's a revolution of writing software in **plain human language** that is understandable and executable by both humans and machines – and it's going to change everything!
|
|
68
66
|
|
|
69
67
|
The incredible growth in power of microprocessors and the Moore's Law have been the driving force behind the ever-more powerful languages, and it's been an amazing journey! Similarly, the large language models (like GPT or Claude) are the next big thing in language technology, and they're set to transform the way we interact with computers.
|
|
@@ -189,8 +187,6 @@ Join our growing community of developers and users:
|
|
|
189
187
|
|
|
190
188
|
_A concise, Markdown-based DSL for crafting AI workflows and automations._
|
|
191
189
|
|
|
192
|
-
|
|
193
|
-
|
|
194
190
|
### Introduction
|
|
195
191
|
|
|
196
192
|
Book is a Markdown-based language that simplifies the creation of AI applications, workflows, and automations. With human-readable commands, you can define inputs, outputs, personas, knowledge sources, and actions—without needing model-specific details.
|
|
@@ -240,8 +236,6 @@ Personas can have access to different knowledge, tools and actions. They can als
|
|
|
240
236
|
|
|
241
237
|
- [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
|
|
242
238
|
|
|
243
|
-
|
|
244
|
-
|
|
245
239
|
### **3. How:** Knowledge, Instruments and Actions
|
|
246
240
|
|
|
247
241
|
The resources used by the personas are used to do the work.
|
|
@@ -316,6 +310,7 @@ Or you can install them separately:
|
|
|
316
310
|
- **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API
|
|
317
311
|
- **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Useful templates and examples of books which can be used as a starting point
|
|
318
312
|
- **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
|
|
313
|
+
- **[@promptbook/color](https://www.npmjs.com/package/@promptbook/color)** - Color manipulation library
|
|
319
314
|
- ⭐ **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
|
|
320
315
|
- 🐋 **[Docker image](https://hub.docker.com/r/hejny/promptbook/)** - Promptbook server
|
|
321
316
|
|
|
@@ -341,8 +336,6 @@ The following glossary is used to clarify certain concepts:
|
|
|
341
336
|
|
|
342
337
|
_Note: This section is not a complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
343
338
|
|
|
344
|
-
|
|
345
|
-
|
|
346
339
|
### 💯 Core concepts
|
|
347
340
|
|
|
348
341
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
package/esm/index.es.js
CHANGED
|
@@ -6,8 +6,9 @@ import colors from 'colors';
|
|
|
6
6
|
import { forTime } from 'waitasecond';
|
|
7
7
|
import { SHA256 } from 'crypto-js';
|
|
8
8
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
9
|
-
import { format } from 'prettier';
|
|
10
9
|
import parserHtml from 'prettier/parser-html';
|
|
10
|
+
import parserMarkdown from 'prettier/parser-markdown';
|
|
11
|
+
import { format } from 'prettier/standalone';
|
|
11
12
|
import { randomBytes } from 'crypto';
|
|
12
13
|
import { Subject } from 'rxjs';
|
|
13
14
|
import sha256 from 'crypto-js/sha256';
|
|
@@ -28,7 +29,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
28
29
|
* @generated
|
|
29
30
|
* @see https://github.com/webgptorg/promptbook
|
|
30
31
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0
|
|
32
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0';
|
|
32
33
|
/**
|
|
33
34
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
35
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -220,6 +221,19 @@ let DEFAULT_IS_VERBOSE = false;
|
|
|
220
221
|
* @public exported from `@promptbook/core`
|
|
221
222
|
*/
|
|
222
223
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
224
|
+
/**
|
|
225
|
+
* Default simulated duration for a task in milliseconds (used for progress reporting)
|
|
226
|
+
*
|
|
227
|
+
* @public exported from `@promptbook/core`
|
|
228
|
+
*/
|
|
229
|
+
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
230
|
+
/**
|
|
231
|
+
* API request timeout in milliseconds
|
|
232
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
233
|
+
*
|
|
234
|
+
* @public exported from `@promptbook/core`
|
|
235
|
+
*/
|
|
236
|
+
parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
223
237
|
/**
|
|
224
238
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
225
239
|
*
|
|
@@ -1213,7 +1227,7 @@ function prettifyMarkdown(content) {
|
|
|
1213
1227
|
try {
|
|
1214
1228
|
return format(content, {
|
|
1215
1229
|
parser: 'markdown',
|
|
1216
|
-
plugins: [parserHtml],
|
|
1230
|
+
plugins: [parserMarkdown, parserHtml],
|
|
1217
1231
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
1218
1232
|
endOfLine: 'lf',
|
|
1219
1233
|
tabWidth: 4,
|
|
@@ -2697,6 +2711,7 @@ function createTask(options) {
|
|
|
2697
2711
|
const errors = [];
|
|
2698
2712
|
const warnings = [];
|
|
2699
2713
|
let currentValue = {};
|
|
2714
|
+
let customTldr = null;
|
|
2700
2715
|
const partialResultSubject = new Subject();
|
|
2701
2716
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2702
2717
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2707,6 +2722,9 @@ function createTask(options) {
|
|
|
2707
2722
|
Object.assign(currentValue, newOngoingResult);
|
|
2708
2723
|
// <- TODO: assign deep
|
|
2709
2724
|
partialResultSubject.next(newOngoingResult);
|
|
2725
|
+
}, (tldrInfo) => {
|
|
2726
|
+
customTldr = tldrInfo;
|
|
2727
|
+
updatedAt = new Date();
|
|
2710
2728
|
});
|
|
2711
2729
|
finalResultPromise
|
|
2712
2730
|
.catch((error) => {
|
|
@@ -2760,6 +2778,78 @@ function createTask(options) {
|
|
|
2760
2778
|
return status;
|
|
2761
2779
|
// <- Note: [1] --||--
|
|
2762
2780
|
},
|
|
2781
|
+
get tldr() {
|
|
2782
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2783
|
+
// Use custom tldr if available
|
|
2784
|
+
if (customTldr) {
|
|
2785
|
+
return customTldr;
|
|
2786
|
+
}
|
|
2787
|
+
// Fallback to default implementation
|
|
2788
|
+
const cv = currentValue;
|
|
2789
|
+
// If explicit percent is provided, use it
|
|
2790
|
+
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;
|
|
2791
|
+
// Simulate progress if not provided
|
|
2792
|
+
if (typeof percentRaw !== 'number') {
|
|
2793
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
|
2794
|
+
const now = new Date();
|
|
2795
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
|
2796
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
|
2797
|
+
// If subtasks are defined, split progress evenly
|
|
2798
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
|
2799
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
|
2800
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
|
2801
|
+
: 0;
|
|
2802
|
+
// Progress from completed subtasks
|
|
2803
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
|
2804
|
+
// Progress from elapsed time for current subtask
|
|
2805
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
2806
|
+
// Combine: completed subtasks + time progress for current subtask
|
|
2807
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
|
2808
|
+
if (status === 'FINISHED')
|
|
2809
|
+
percentRaw = 1;
|
|
2810
|
+
if (status === 'ERROR')
|
|
2811
|
+
percentRaw = 0;
|
|
2812
|
+
}
|
|
2813
|
+
// Clamp to [0,1]
|
|
2814
|
+
let percent = Number(percentRaw) || 0;
|
|
2815
|
+
if (percent < 0)
|
|
2816
|
+
percent = 0;
|
|
2817
|
+
if (percent > 1)
|
|
2818
|
+
percent = 1;
|
|
2819
|
+
// Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
|
|
2820
|
+
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;
|
|
2821
|
+
let message = messageFromResult;
|
|
2822
|
+
if (!message) {
|
|
2823
|
+
// If subtasks, show current subtask
|
|
2824
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
|
2825
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
|
2826
|
+
if (current && current.title) {
|
|
2827
|
+
message = `Working on ${current.title}`;
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
if (!message) {
|
|
2831
|
+
if (errors.length) {
|
|
2832
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
2833
|
+
}
|
|
2834
|
+
else if (warnings.length) {
|
|
2835
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
2836
|
+
}
|
|
2837
|
+
else if (status === 'FINISHED') {
|
|
2838
|
+
message = 'Finished';
|
|
2839
|
+
}
|
|
2840
|
+
else if (status === 'ERROR') {
|
|
2841
|
+
message = 'Error';
|
|
2842
|
+
}
|
|
2843
|
+
else {
|
|
2844
|
+
message = 'Running';
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
return {
|
|
2849
|
+
percent: percent,
|
|
2850
|
+
message,
|
|
2851
|
+
};
|
|
2852
|
+
},
|
|
2763
2853
|
get createdAt() {
|
|
2764
2854
|
return createdAt;
|
|
2765
2855
|
// <- Note: [1] --||--
|
|
@@ -3008,6 +3098,76 @@ function countUsage(llmTools) {
|
|
|
3008
3098
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3009
3099
|
*/
|
|
3010
3100
|
|
|
3101
|
+
/**
|
|
3102
|
+
* Predefined profiles for LLM providers to maintain consistency across the application
|
|
3103
|
+
* These profiles represent each provider as a virtual persona in chat interfaces
|
|
3104
|
+
*
|
|
3105
|
+
* @private !!!!
|
|
3106
|
+
*/
|
|
3107
|
+
const LLM_PROVIDER_PROFILES = {
|
|
3108
|
+
OPENAI: {
|
|
3109
|
+
name: 'OPENAI',
|
|
3110
|
+
fullname: 'OpenAI GPT',
|
|
3111
|
+
color: '#10a37f', // OpenAI's signature green
|
|
3112
|
+
// Note: avatarSrc could be added when we have provider logos available
|
|
3113
|
+
},
|
|
3114
|
+
ANTHROPIC: {
|
|
3115
|
+
name: 'ANTHROPIC',
|
|
3116
|
+
fullname: 'Anthropic Claude',
|
|
3117
|
+
color: '#d97706', // Anthropic's orange/amber color
|
|
3118
|
+
},
|
|
3119
|
+
AZURE_OPENAI: {
|
|
3120
|
+
name: 'AZURE_OPENAI',
|
|
3121
|
+
fullname: 'Azure OpenAI',
|
|
3122
|
+
color: '#0078d4', // Microsoft Azure blue
|
|
3123
|
+
},
|
|
3124
|
+
GOOGLE: {
|
|
3125
|
+
name: 'GOOGLE',
|
|
3126
|
+
fullname: 'Google Gemini',
|
|
3127
|
+
color: '#4285f4', // Google blue
|
|
3128
|
+
},
|
|
3129
|
+
DEEPSEEK: {
|
|
3130
|
+
name: 'DEEPSEEK',
|
|
3131
|
+
fullname: 'DeepSeek',
|
|
3132
|
+
color: '#7c3aed', // Purple color for DeepSeek
|
|
3133
|
+
},
|
|
3134
|
+
OLLAMA: {
|
|
3135
|
+
name: 'OLLAMA',
|
|
3136
|
+
fullname: 'Ollama',
|
|
3137
|
+
color: '#059669', // Emerald green for local models
|
|
3138
|
+
},
|
|
3139
|
+
REMOTE: {
|
|
3140
|
+
name: 'REMOTE',
|
|
3141
|
+
fullname: 'Remote Server',
|
|
3142
|
+
color: '#6b7280', // Gray for remote/proxy connections
|
|
3143
|
+
},
|
|
3144
|
+
MOCKED_ECHO: {
|
|
3145
|
+
name: 'MOCKED_ECHO',
|
|
3146
|
+
fullname: 'Echo (Test)',
|
|
3147
|
+
color: '#8b5cf6', // Purple for test/mock tools
|
|
3148
|
+
},
|
|
3149
|
+
MOCKED_FAKE: {
|
|
3150
|
+
name: 'MOCKED_FAKE',
|
|
3151
|
+
fullname: 'Fake LLM (Test)',
|
|
3152
|
+
color: '#ec4899', // Pink for fake/test tools
|
|
3153
|
+
},
|
|
3154
|
+
VERCEL: {
|
|
3155
|
+
name: 'VERCEL',
|
|
3156
|
+
fullname: 'Vercel AI',
|
|
3157
|
+
color: '#000000', // Vercel's black
|
|
3158
|
+
},
|
|
3159
|
+
MULTIPLE: {
|
|
3160
|
+
name: 'MULTIPLE',
|
|
3161
|
+
fullname: 'Multiple Providers',
|
|
3162
|
+
color: '#6366f1', // Indigo for combined/multiple providers
|
|
3163
|
+
},
|
|
3164
|
+
};
|
|
3165
|
+
/**
|
|
3166
|
+
* TODO: Refactor this - each profile must be alongside the provider definition
|
|
3167
|
+
* TODO: Unite `AvatarProfileProps` and `ChatParticipant`
|
|
3168
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3169
|
+
*/
|
|
3170
|
+
|
|
3011
3171
|
/**
|
|
3012
3172
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
3013
3173
|
*
|
|
@@ -3033,7 +3193,7 @@ class MultipleLlmExecutionTools {
|
|
|
3033
3193
|
}
|
|
3034
3194
|
return spaceTrim$1((block) => `
|
|
3035
3195
|
${headLine}
|
|
3036
|
-
|
|
3196
|
+
|
|
3037
3197
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
3038
3198
|
`);
|
|
3039
3199
|
})
|
|
@@ -3044,6 +3204,9 @@ class MultipleLlmExecutionTools {
|
|
|
3044
3204
|
${block(innerModelsTitlesAndDescriptions)}
|
|
3045
3205
|
`);
|
|
3046
3206
|
}
|
|
3207
|
+
get profile() {
|
|
3208
|
+
return LLM_PROVIDER_PROFILES.MULTIPLE;
|
|
3209
|
+
}
|
|
3047
3210
|
/**
|
|
3048
3211
|
* Check the configuration of all execution tools
|
|
3049
3212
|
*/
|
|
@@ -3088,25 +3251,22 @@ class MultipleLlmExecutionTools {
|
|
|
3088
3251
|
const errors = [];
|
|
3089
3252
|
llm: for (const llmExecutionTools of this.llmExecutionTools) {
|
|
3090
3253
|
try {
|
|
3091
|
-
|
|
3254
|
+
switch (prompt.modelRequirements.modelVariant) {
|
|
3092
3255
|
case 'CHAT':
|
|
3093
3256
|
if (llmExecutionTools.callChatModel === undefined) {
|
|
3094
3257
|
continue llm;
|
|
3095
3258
|
}
|
|
3096
3259
|
return await llmExecutionTools.callChatModel(prompt);
|
|
3097
|
-
break variant;
|
|
3098
3260
|
case 'COMPLETION':
|
|
3099
3261
|
if (llmExecutionTools.callCompletionModel === undefined) {
|
|
3100
3262
|
continue llm;
|
|
3101
3263
|
}
|
|
3102
3264
|
return await llmExecutionTools.callCompletionModel(prompt);
|
|
3103
|
-
break variant;
|
|
3104
3265
|
case 'EMBEDDING':
|
|
3105
3266
|
if (llmExecutionTools.callEmbeddingModel === undefined) {
|
|
3106
3267
|
continue llm;
|
|
3107
3268
|
}
|
|
3108
3269
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
3109
|
-
break variant;
|
|
3110
3270
|
// <- case [🤖]:
|
|
3111
3271
|
default:
|
|
3112
3272
|
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
@@ -3259,7 +3419,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
3259
3419
|
const result = await preparePersonaExecutor({
|
|
3260
3420
|
availableModels /* <- Note: Passing as JSON */,
|
|
3261
3421
|
personaDescription,
|
|
3262
|
-
}).asPromise();
|
|
3422
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3263
3423
|
const { outputParameters } = result;
|
|
3264
3424
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
3265
3425
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -4013,7 +4173,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
4013
4173
|
});
|
|
4014
4174
|
const result = await prepareTitleExecutor({
|
|
4015
4175
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
4016
|
-
}).asPromise();
|
|
4176
|
+
}).asPromise({ isCrashedOnError: true });
|
|
4017
4177
|
const { outputParameters } = result;
|
|
4018
4178
|
const { title: titleRaw } = outputParameters;
|
|
4019
4179
|
if (isVerbose) {
|
|
@@ -5107,7 +5267,7 @@ function validatePromptResult(options) {
|
|
|
5107
5267
|
*/
|
|
5108
5268
|
async function executeAttempts(options) {
|
|
5109
5269
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
5110
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
|
|
5270
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
5111
5271
|
const $ongoingTaskResult = {
|
|
5112
5272
|
$result: null,
|
|
5113
5273
|
$resultString: null,
|
|
@@ -5351,6 +5511,10 @@ async function executeAttempts(options) {
|
|
|
5351
5511
|
result: $ongoingTaskResult.$resultString,
|
|
5352
5512
|
error: error,
|
|
5353
5513
|
});
|
|
5514
|
+
// Report failed attempt
|
|
5515
|
+
onProgress({
|
|
5516
|
+
errors: [error],
|
|
5517
|
+
});
|
|
5354
5518
|
}
|
|
5355
5519
|
finally {
|
|
5356
5520
|
if (!isJokerAttempt &&
|
|
@@ -6224,15 +6388,74 @@ function createPipelineExecutor(options) {
|
|
|
6224
6388
|
});
|
|
6225
6389
|
});
|
|
6226
6390
|
};
|
|
6227
|
-
const pipelineExecutor = (inputParameters) =>
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6391
|
+
const pipelineExecutor = (inputParameters) => {
|
|
6392
|
+
const startTime = new Date().getTime();
|
|
6393
|
+
return createTask({
|
|
6394
|
+
taskType: 'EXECUTION',
|
|
6395
|
+
title: pipeline.title,
|
|
6396
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6397
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6398
|
+
var _a, _b;
|
|
6399
|
+
updateOngoingResult(newOngoingResult);
|
|
6400
|
+
// Calculate and update tldr based on pipeline progress
|
|
6401
|
+
const cv = newOngoingResult;
|
|
6402
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
6403
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6404
|
+
let resolvedParameters = 0;
|
|
6405
|
+
let currentTaskTitle = '';
|
|
6406
|
+
// Get the resolved parameters from output parameters
|
|
6407
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6408
|
+
// Count how many output parameters have non-empty values
|
|
6409
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6410
|
+
}
|
|
6411
|
+
// Try to determine current task from execution report
|
|
6412
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
6413
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
6414
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
6415
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
6416
|
+
}
|
|
6417
|
+
}
|
|
6418
|
+
// Calculate base progress percentage
|
|
6419
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
6420
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
6421
|
+
if (resolvedParameters < totalParameters) {
|
|
6422
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
6423
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
6424
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
6425
|
+
// If we have time progress but no parameter progress, show time progress
|
|
6426
|
+
if (percent === 0 && timeProgress > 0) {
|
|
6427
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
6428
|
+
}
|
|
6429
|
+
else if (percent < 1) {
|
|
6430
|
+
// Add partial progress for current task
|
|
6431
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
6432
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
6433
|
+
}
|
|
6434
|
+
}
|
|
6435
|
+
// Clamp to [0,1]
|
|
6436
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6437
|
+
// Generate message
|
|
6438
|
+
let message = '';
|
|
6439
|
+
if (currentTaskTitle) {
|
|
6440
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
6441
|
+
}
|
|
6442
|
+
else if (resolvedParameters === 0) {
|
|
6443
|
+
message = 'Starting pipeline execution';
|
|
6444
|
+
}
|
|
6445
|
+
else if (resolvedParameters < totalParameters) {
|
|
6446
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
6447
|
+
}
|
|
6448
|
+
else {
|
|
6449
|
+
message = 'Completing pipeline execution';
|
|
6450
|
+
}
|
|
6451
|
+
updateTldr({
|
|
6452
|
+
percent: percent,
|
|
6453
|
+
message,
|
|
6454
|
+
});
|
|
6455
|
+
});
|
|
6456
|
+
},
|
|
6457
|
+
});
|
|
6458
|
+
};
|
|
6236
6459
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6237
6460
|
return pipelineExecutor;
|
|
6238
6461
|
}
|
|
@@ -6317,7 +6540,9 @@ class MarkdownScraper {
|
|
|
6317
6540
|
},
|
|
6318
6541
|
});
|
|
6319
6542
|
const knowledgeContent = await source.asText();
|
|
6320
|
-
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise(
|
|
6543
|
+
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
|
|
6544
|
+
isCrashedOnError: true,
|
|
6545
|
+
});
|
|
6321
6546
|
const { outputParameters } = result;
|
|
6322
6547
|
const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
|
|
6323
6548
|
const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
@@ -6341,12 +6566,16 @@ class MarkdownScraper {
|
|
|
6341
6566
|
];
|
|
6342
6567
|
*/
|
|
6343
6568
|
try {
|
|
6344
|
-
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise(
|
|
6569
|
+
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
|
|
6570
|
+
isCrashedOnError: true,
|
|
6571
|
+
});
|
|
6345
6572
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
6346
6573
|
title = spaceTrim$1(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
6347
6574
|
name = titleToName(title);
|
|
6348
6575
|
// --- Keywords
|
|
6349
|
-
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise(
|
|
6576
|
+
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
6577
|
+
isCrashedOnError: true,
|
|
6578
|
+
});
|
|
6350
6579
|
const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
|
|
6351
6580
|
keywords = (keywordsRaw || '')
|
|
6352
6581
|
.split(',')
|