@promptbook/pdf 0.100.0-9 → 0.100.1
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 +29 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfileFromSource.d.ts +19 -0
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +40 -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 +11 -6
- 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/_common/register/LlmToolsMetadata.d.ts +3 -4
- 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 +179 -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/pdf`
|
|
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
|
@@ -3,8 +3,9 @@ import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
|
3
3
|
import { SHA256 } from 'crypto-js';
|
|
4
4
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
5
5
|
import { basename, join, dirname } from 'path';
|
|
6
|
-
import { format } from 'prettier';
|
|
7
6
|
import parserHtml from 'prettier/parser-html';
|
|
7
|
+
import parserMarkdown from 'prettier/parser-markdown';
|
|
8
|
+
import { format } from 'prettier/standalone';
|
|
8
9
|
import { randomBytes } from 'crypto';
|
|
9
10
|
import { Subject } from 'rxjs';
|
|
10
11
|
import { forTime } from 'waitasecond';
|
|
@@ -26,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
27
|
* @generated
|
|
27
28
|
* @see https://github.com/webgptorg/promptbook
|
|
28
29
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.1';
|
|
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 @@ let DEFAULT_IS_VERBOSE = false;
|
|
|
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
|
*
|
|
@@ -1034,7 +1048,7 @@ function prettifyMarkdown(content) {
|
|
|
1034
1048
|
try {
|
|
1035
1049
|
return format(content, {
|
|
1036
1050
|
parser: 'markdown',
|
|
1037
|
-
plugins: [parserHtml],
|
|
1051
|
+
plugins: [parserMarkdown, parserHtml],
|
|
1038
1052
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
1039
1053
|
endOfLine: 'lf',
|
|
1040
1054
|
tabWidth: 4,
|
|
@@ -2536,6 +2550,7 @@ function createTask(options) {
|
|
|
2536
2550
|
const errors = [];
|
|
2537
2551
|
const warnings = [];
|
|
2538
2552
|
let currentValue = {};
|
|
2553
|
+
let customTldr = null;
|
|
2539
2554
|
const partialResultSubject = new Subject();
|
|
2540
2555
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2541
2556
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2546,6 +2561,9 @@ function createTask(options) {
|
|
|
2546
2561
|
Object.assign(currentValue, newOngoingResult);
|
|
2547
2562
|
// <- TODO: assign deep
|
|
2548
2563
|
partialResultSubject.next(newOngoingResult);
|
|
2564
|
+
}, (tldrInfo) => {
|
|
2565
|
+
customTldr = tldrInfo;
|
|
2566
|
+
updatedAt = new Date();
|
|
2549
2567
|
});
|
|
2550
2568
|
finalResultPromise
|
|
2551
2569
|
.catch((error) => {
|
|
@@ -2599,6 +2617,78 @@ function createTask(options) {
|
|
|
2599
2617
|
return status;
|
|
2600
2618
|
// <- Note: [1] --||--
|
|
2601
2619
|
},
|
|
2620
|
+
get tldr() {
|
|
2621
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2622
|
+
// Use custom tldr if available
|
|
2623
|
+
if (customTldr) {
|
|
2624
|
+
return customTldr;
|
|
2625
|
+
}
|
|
2626
|
+
// Fallback to default implementation
|
|
2627
|
+
const cv = currentValue;
|
|
2628
|
+
// If explicit percent is provided, use it
|
|
2629
|
+
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;
|
|
2630
|
+
// Simulate progress if not provided
|
|
2631
|
+
if (typeof percentRaw !== 'number') {
|
|
2632
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
|
2633
|
+
const now = new Date();
|
|
2634
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
|
2635
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
|
2636
|
+
// If subtasks are defined, split progress evenly
|
|
2637
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
|
2638
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
|
2639
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
|
2640
|
+
: 0;
|
|
2641
|
+
// Progress from completed subtasks
|
|
2642
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
|
2643
|
+
// Progress from elapsed time for current subtask
|
|
2644
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
2645
|
+
// Combine: completed subtasks + time progress for current subtask
|
|
2646
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
|
2647
|
+
if (status === 'FINISHED')
|
|
2648
|
+
percentRaw = 1;
|
|
2649
|
+
if (status === 'ERROR')
|
|
2650
|
+
percentRaw = 0;
|
|
2651
|
+
}
|
|
2652
|
+
// Clamp to [0,1]
|
|
2653
|
+
let percent = Number(percentRaw) || 0;
|
|
2654
|
+
if (percent < 0)
|
|
2655
|
+
percent = 0;
|
|
2656
|
+
if (percent > 1)
|
|
2657
|
+
percent = 1;
|
|
2658
|
+
// Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
|
|
2659
|
+
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;
|
|
2660
|
+
let message = messageFromResult;
|
|
2661
|
+
if (!message) {
|
|
2662
|
+
// If subtasks, show current subtask
|
|
2663
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
|
2664
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
|
2665
|
+
if (current && current.title) {
|
|
2666
|
+
message = `Working on ${current.title}`;
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
if (!message) {
|
|
2670
|
+
if (errors.length) {
|
|
2671
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
2672
|
+
}
|
|
2673
|
+
else if (warnings.length) {
|
|
2674
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
2675
|
+
}
|
|
2676
|
+
else if (status === 'FINISHED') {
|
|
2677
|
+
message = 'Finished';
|
|
2678
|
+
}
|
|
2679
|
+
else if (status === 'ERROR') {
|
|
2680
|
+
message = 'Error';
|
|
2681
|
+
}
|
|
2682
|
+
else {
|
|
2683
|
+
message = 'Running';
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
return {
|
|
2688
|
+
percent: percent,
|
|
2689
|
+
message,
|
|
2690
|
+
};
|
|
2691
|
+
},
|
|
2602
2692
|
get createdAt() {
|
|
2603
2693
|
return createdAt;
|
|
2604
2694
|
// <- Note: [1] --||--
|
|
@@ -2847,6 +2937,76 @@ function countUsage(llmTools) {
|
|
|
2847
2937
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2848
2938
|
*/
|
|
2849
2939
|
|
|
2940
|
+
/**
|
|
2941
|
+
* Predefined profiles for LLM providers to maintain consistency across the application
|
|
2942
|
+
* These profiles represent each provider as a virtual persona in chat interfaces
|
|
2943
|
+
*
|
|
2944
|
+
* @private !!!!
|
|
2945
|
+
*/
|
|
2946
|
+
const LLM_PROVIDER_PROFILES = {
|
|
2947
|
+
OPENAI: {
|
|
2948
|
+
name: 'OPENAI',
|
|
2949
|
+
fullname: 'OpenAI GPT',
|
|
2950
|
+
color: '#10a37f', // OpenAI's signature green
|
|
2951
|
+
// Note: avatarSrc could be added when we have provider logos available
|
|
2952
|
+
},
|
|
2953
|
+
ANTHROPIC: {
|
|
2954
|
+
name: 'ANTHROPIC',
|
|
2955
|
+
fullname: 'Anthropic Claude',
|
|
2956
|
+
color: '#d97706', // Anthropic's orange/amber color
|
|
2957
|
+
},
|
|
2958
|
+
AZURE_OPENAI: {
|
|
2959
|
+
name: 'AZURE_OPENAI',
|
|
2960
|
+
fullname: 'Azure OpenAI',
|
|
2961
|
+
color: '#0078d4', // Microsoft Azure blue
|
|
2962
|
+
},
|
|
2963
|
+
GOOGLE: {
|
|
2964
|
+
name: 'GOOGLE',
|
|
2965
|
+
fullname: 'Google Gemini',
|
|
2966
|
+
color: '#4285f4', // Google blue
|
|
2967
|
+
},
|
|
2968
|
+
DEEPSEEK: {
|
|
2969
|
+
name: 'DEEPSEEK',
|
|
2970
|
+
fullname: 'DeepSeek',
|
|
2971
|
+
color: '#7c3aed', // Purple color for DeepSeek
|
|
2972
|
+
},
|
|
2973
|
+
OLLAMA: {
|
|
2974
|
+
name: 'OLLAMA',
|
|
2975
|
+
fullname: 'Ollama',
|
|
2976
|
+
color: '#059669', // Emerald green for local models
|
|
2977
|
+
},
|
|
2978
|
+
REMOTE: {
|
|
2979
|
+
name: 'REMOTE',
|
|
2980
|
+
fullname: 'Remote Server',
|
|
2981
|
+
color: '#6b7280', // Gray for remote/proxy connections
|
|
2982
|
+
},
|
|
2983
|
+
MOCKED_ECHO: {
|
|
2984
|
+
name: 'MOCKED_ECHO',
|
|
2985
|
+
fullname: 'Echo (Test)',
|
|
2986
|
+
color: '#8b5cf6', // Purple for test/mock tools
|
|
2987
|
+
},
|
|
2988
|
+
MOCKED_FAKE: {
|
|
2989
|
+
name: 'MOCKED_FAKE',
|
|
2990
|
+
fullname: 'Fake LLM (Test)',
|
|
2991
|
+
color: '#ec4899', // Pink for fake/test tools
|
|
2992
|
+
},
|
|
2993
|
+
VERCEL: {
|
|
2994
|
+
name: 'VERCEL',
|
|
2995
|
+
fullname: 'Vercel AI',
|
|
2996
|
+
color: '#000000', // Vercel's black
|
|
2997
|
+
},
|
|
2998
|
+
MULTIPLE: {
|
|
2999
|
+
name: 'MULTIPLE',
|
|
3000
|
+
fullname: 'Multiple Providers',
|
|
3001
|
+
color: '#6366f1', // Indigo for combined/multiple providers
|
|
3002
|
+
},
|
|
3003
|
+
};
|
|
3004
|
+
/**
|
|
3005
|
+
* TODO: Refactor this - each profile must be alongside the provider definition
|
|
3006
|
+
* TODO: [🕛] Unite `AvatarProfileProps`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
|
|
3007
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3008
|
+
*/
|
|
3009
|
+
|
|
2850
3010
|
/**
|
|
2851
3011
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
2852
3012
|
*
|
|
@@ -2872,7 +3032,7 @@ class MultipleLlmExecutionTools {
|
|
|
2872
3032
|
}
|
|
2873
3033
|
return spaceTrim((block) => `
|
|
2874
3034
|
${headLine}
|
|
2875
|
-
|
|
3035
|
+
|
|
2876
3036
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
2877
3037
|
`);
|
|
2878
3038
|
})
|
|
@@ -2883,6 +3043,9 @@ class MultipleLlmExecutionTools {
|
|
|
2883
3043
|
${block(innerModelsTitlesAndDescriptions)}
|
|
2884
3044
|
`);
|
|
2885
3045
|
}
|
|
3046
|
+
get profile() {
|
|
3047
|
+
return LLM_PROVIDER_PROFILES.MULTIPLE;
|
|
3048
|
+
}
|
|
2886
3049
|
/**
|
|
2887
3050
|
* Check the configuration of all execution tools
|
|
2888
3051
|
*/
|
|
@@ -2927,25 +3090,22 @@ class MultipleLlmExecutionTools {
|
|
|
2927
3090
|
const errors = [];
|
|
2928
3091
|
llm: for (const llmExecutionTools of this.llmExecutionTools) {
|
|
2929
3092
|
try {
|
|
2930
|
-
|
|
3093
|
+
switch (prompt.modelRequirements.modelVariant) {
|
|
2931
3094
|
case 'CHAT':
|
|
2932
3095
|
if (llmExecutionTools.callChatModel === undefined) {
|
|
2933
3096
|
continue llm;
|
|
2934
3097
|
}
|
|
2935
3098
|
return await llmExecutionTools.callChatModel(prompt);
|
|
2936
|
-
break variant;
|
|
2937
3099
|
case 'COMPLETION':
|
|
2938
3100
|
if (llmExecutionTools.callCompletionModel === undefined) {
|
|
2939
3101
|
continue llm;
|
|
2940
3102
|
}
|
|
2941
3103
|
return await llmExecutionTools.callCompletionModel(prompt);
|
|
2942
|
-
break variant;
|
|
2943
3104
|
case 'EMBEDDING':
|
|
2944
3105
|
if (llmExecutionTools.callEmbeddingModel === undefined) {
|
|
2945
3106
|
continue llm;
|
|
2946
3107
|
}
|
|
2947
3108
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
2948
|
-
break variant;
|
|
2949
3109
|
// <- case [🤖]:
|
|
2950
3110
|
default:
|
|
2951
3111
|
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
@@ -3098,7 +3258,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
3098
3258
|
const result = await preparePersonaExecutor({
|
|
3099
3259
|
availableModels /* <- Note: Passing as JSON */,
|
|
3100
3260
|
personaDescription,
|
|
3101
|
-
}).asPromise();
|
|
3261
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3102
3262
|
const { outputParameters } = result;
|
|
3103
3263
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
3104
3264
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -3862,7 +4022,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
3862
4022
|
});
|
|
3863
4023
|
const result = await prepareTitleExecutor({
|
|
3864
4024
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
3865
|
-
}).asPromise();
|
|
4025
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3866
4026
|
const { outputParameters } = result;
|
|
3867
4027
|
const { title: titleRaw } = outputParameters;
|
|
3868
4028
|
if (isVerbose) {
|
|
@@ -4956,7 +5116,7 @@ function validatePromptResult(options) {
|
|
|
4956
5116
|
*/
|
|
4957
5117
|
async function executeAttempts(options) {
|
|
4958
5118
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
4959
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
|
|
5119
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
4960
5120
|
const $ongoingTaskResult = {
|
|
4961
5121
|
$result: null,
|
|
4962
5122
|
$resultString: null,
|
|
@@ -5200,6 +5360,10 @@ async function executeAttempts(options) {
|
|
|
5200
5360
|
result: $ongoingTaskResult.$resultString,
|
|
5201
5361
|
error: error,
|
|
5202
5362
|
});
|
|
5363
|
+
// Report failed attempt
|
|
5364
|
+
onProgress({
|
|
5365
|
+
errors: [error],
|
|
5366
|
+
});
|
|
5203
5367
|
}
|
|
5204
5368
|
finally {
|
|
5205
5369
|
if (!isJokerAttempt &&
|
|
@@ -6073,15 +6237,74 @@ function createPipelineExecutor(options) {
|
|
|
6073
6237
|
});
|
|
6074
6238
|
});
|
|
6075
6239
|
};
|
|
6076
|
-
const pipelineExecutor = (inputParameters) =>
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6240
|
+
const pipelineExecutor = (inputParameters) => {
|
|
6241
|
+
const startTime = new Date().getTime();
|
|
6242
|
+
return createTask({
|
|
6243
|
+
taskType: 'EXECUTION',
|
|
6244
|
+
title: pipeline.title,
|
|
6245
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6246
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6247
|
+
var _a, _b;
|
|
6248
|
+
updateOngoingResult(newOngoingResult);
|
|
6249
|
+
// Calculate and update tldr based on pipeline progress
|
|
6250
|
+
const cv = newOngoingResult;
|
|
6251
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
6252
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6253
|
+
let resolvedParameters = 0;
|
|
6254
|
+
let currentTaskTitle = '';
|
|
6255
|
+
// Get the resolved parameters from output parameters
|
|
6256
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6257
|
+
// Count how many output parameters have non-empty values
|
|
6258
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6259
|
+
}
|
|
6260
|
+
// Try to determine current task from execution report
|
|
6261
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
6262
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
6263
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
6264
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
6265
|
+
}
|
|
6266
|
+
}
|
|
6267
|
+
// Calculate base progress percentage
|
|
6268
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
6269
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
6270
|
+
if (resolvedParameters < totalParameters) {
|
|
6271
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
6272
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
6273
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
6274
|
+
// If we have time progress but no parameter progress, show time progress
|
|
6275
|
+
if (percent === 0 && timeProgress > 0) {
|
|
6276
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
6277
|
+
}
|
|
6278
|
+
else if (percent < 1) {
|
|
6279
|
+
// Add partial progress for current task
|
|
6280
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
6281
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
6282
|
+
}
|
|
6283
|
+
}
|
|
6284
|
+
// Clamp to [0,1]
|
|
6285
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6286
|
+
// Generate message
|
|
6287
|
+
let message = '';
|
|
6288
|
+
if (currentTaskTitle) {
|
|
6289
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
6290
|
+
}
|
|
6291
|
+
else if (resolvedParameters === 0) {
|
|
6292
|
+
message = 'Starting pipeline execution';
|
|
6293
|
+
}
|
|
6294
|
+
else if (resolvedParameters < totalParameters) {
|
|
6295
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
6296
|
+
}
|
|
6297
|
+
else {
|
|
6298
|
+
message = 'Completing pipeline execution';
|
|
6299
|
+
}
|
|
6300
|
+
updateTldr({
|
|
6301
|
+
percent: percent,
|
|
6302
|
+
message,
|
|
6303
|
+
});
|
|
6304
|
+
});
|
|
6305
|
+
},
|
|
6306
|
+
});
|
|
6307
|
+
};
|
|
6085
6308
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6086
6309
|
return pipelineExecutor;
|
|
6087
6310
|
}
|
|
@@ -6166,7 +6389,9 @@ class MarkdownScraper {
|
|
|
6166
6389
|
},
|
|
6167
6390
|
});
|
|
6168
6391
|
const knowledgeContent = await source.asText();
|
|
6169
|
-
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise(
|
|
6392
|
+
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
|
|
6393
|
+
isCrashedOnError: true,
|
|
6394
|
+
});
|
|
6170
6395
|
const { outputParameters } = result;
|
|
6171
6396
|
const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
|
|
6172
6397
|
const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
@@ -6190,12 +6415,16 @@ class MarkdownScraper {
|
|
|
6190
6415
|
];
|
|
6191
6416
|
*/
|
|
6192
6417
|
try {
|
|
6193
|
-
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise(
|
|
6418
|
+
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
|
|
6419
|
+
isCrashedOnError: true,
|
|
6420
|
+
});
|
|
6194
6421
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
6195
6422
|
title = spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
6196
6423
|
name = titleToName(title);
|
|
6197
6424
|
// --- Keywords
|
|
6198
|
-
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise(
|
|
6425
|
+
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
6426
|
+
isCrashedOnError: true,
|
|
6427
|
+
});
|
|
6199
6428
|
const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
|
|
6200
6429
|
keywords = (keywordsRaw || '')
|
|
6201
6430
|
.split(',')
|