@promptbook/cli 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 +654 -151
- 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 +658 -155
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +0 -14
package/esm/index.es.js
CHANGED
|
@@ -13,8 +13,9 @@ import { io } from 'socket.io-client';
|
|
|
13
13
|
import { Subject } from 'rxjs';
|
|
14
14
|
import { spawn } from 'child_process';
|
|
15
15
|
import JSZip from 'jszip';
|
|
16
|
-
import { format } from 'prettier';
|
|
17
16
|
import parserHtml from 'prettier/parser-html';
|
|
17
|
+
import parserMarkdown from 'prettier/parser-markdown';
|
|
18
|
+
import { format } from 'prettier/standalone';
|
|
18
19
|
import { parse, unparse } from 'papaparse';
|
|
19
20
|
import { SHA256 } from 'crypto-js';
|
|
20
21
|
import { lookup, extension } from 'mime-types';
|
|
@@ -47,7 +48,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
47
48
|
* @generated
|
|
48
49
|
* @see https://github.com/webgptorg/promptbook
|
|
49
50
|
*/
|
|
50
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0
|
|
51
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0';
|
|
51
52
|
/**
|
|
52
53
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
53
54
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -356,6 +357,12 @@ let DEFAULT_IS_VERBOSE = false;
|
|
|
356
357
|
* @public exported from `@promptbook/core`
|
|
357
358
|
*/
|
|
358
359
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
360
|
+
/**
|
|
361
|
+
* Default simulated duration for a task in milliseconds (used for progress reporting)
|
|
362
|
+
*
|
|
363
|
+
* @public exported from `@promptbook/core`
|
|
364
|
+
*/
|
|
365
|
+
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
359
366
|
/**
|
|
360
367
|
* Function name for generated function via `ptbk make` to get the pipeline collection
|
|
361
368
|
*
|
|
@@ -370,6 +377,13 @@ const DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = `getPipelineCollection`;
|
|
|
370
377
|
* @public exported from `@promptbook/core`
|
|
371
378
|
*/
|
|
372
379
|
const DEFAULT_MAX_REQUESTS_PER_MINUTE = 60;
|
|
380
|
+
/**
|
|
381
|
+
* API request timeout in milliseconds
|
|
382
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
383
|
+
*
|
|
384
|
+
* @public exported from `@promptbook/core`
|
|
385
|
+
*/
|
|
386
|
+
const API_REQUEST_TIMEOUT = parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
373
387
|
/**
|
|
374
388
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
375
389
|
*
|
|
@@ -2543,6 +2557,76 @@ function deserializeError(error) {
|
|
|
2543
2557
|
return deserializedError;
|
|
2544
2558
|
}
|
|
2545
2559
|
|
|
2560
|
+
/**
|
|
2561
|
+
* Predefined profiles for LLM providers to maintain consistency across the application
|
|
2562
|
+
* These profiles represent each provider as a virtual persona in chat interfaces
|
|
2563
|
+
*
|
|
2564
|
+
* @private !!!!
|
|
2565
|
+
*/
|
|
2566
|
+
const LLM_PROVIDER_PROFILES = {
|
|
2567
|
+
OPENAI: {
|
|
2568
|
+
name: 'OPENAI',
|
|
2569
|
+
fullname: 'OpenAI GPT',
|
|
2570
|
+
color: '#10a37f', // OpenAI's signature green
|
|
2571
|
+
// Note: avatarSrc could be added when we have provider logos available
|
|
2572
|
+
},
|
|
2573
|
+
ANTHROPIC: {
|
|
2574
|
+
name: 'ANTHROPIC',
|
|
2575
|
+
fullname: 'Anthropic Claude',
|
|
2576
|
+
color: '#d97706', // Anthropic's orange/amber color
|
|
2577
|
+
},
|
|
2578
|
+
AZURE_OPENAI: {
|
|
2579
|
+
name: 'AZURE_OPENAI',
|
|
2580
|
+
fullname: 'Azure OpenAI',
|
|
2581
|
+
color: '#0078d4', // Microsoft Azure blue
|
|
2582
|
+
},
|
|
2583
|
+
GOOGLE: {
|
|
2584
|
+
name: 'GOOGLE',
|
|
2585
|
+
fullname: 'Google Gemini',
|
|
2586
|
+
color: '#4285f4', // Google blue
|
|
2587
|
+
},
|
|
2588
|
+
DEEPSEEK: {
|
|
2589
|
+
name: 'DEEPSEEK',
|
|
2590
|
+
fullname: 'DeepSeek',
|
|
2591
|
+
color: '#7c3aed', // Purple color for DeepSeek
|
|
2592
|
+
},
|
|
2593
|
+
OLLAMA: {
|
|
2594
|
+
name: 'OLLAMA',
|
|
2595
|
+
fullname: 'Ollama',
|
|
2596
|
+
color: '#059669', // Emerald green for local models
|
|
2597
|
+
},
|
|
2598
|
+
REMOTE: {
|
|
2599
|
+
name: 'REMOTE',
|
|
2600
|
+
fullname: 'Remote Server',
|
|
2601
|
+
color: '#6b7280', // Gray for remote/proxy connections
|
|
2602
|
+
},
|
|
2603
|
+
MOCKED_ECHO: {
|
|
2604
|
+
name: 'MOCKED_ECHO',
|
|
2605
|
+
fullname: 'Echo (Test)',
|
|
2606
|
+
color: '#8b5cf6', // Purple for test/mock tools
|
|
2607
|
+
},
|
|
2608
|
+
MOCKED_FAKE: {
|
|
2609
|
+
name: 'MOCKED_FAKE',
|
|
2610
|
+
fullname: 'Fake LLM (Test)',
|
|
2611
|
+
color: '#ec4899', // Pink for fake/test tools
|
|
2612
|
+
},
|
|
2613
|
+
VERCEL: {
|
|
2614
|
+
name: 'VERCEL',
|
|
2615
|
+
fullname: 'Vercel AI',
|
|
2616
|
+
color: '#000000', // Vercel's black
|
|
2617
|
+
},
|
|
2618
|
+
MULTIPLE: {
|
|
2619
|
+
name: 'MULTIPLE',
|
|
2620
|
+
fullname: 'Multiple Providers',
|
|
2621
|
+
color: '#6366f1', // Indigo for combined/multiple providers
|
|
2622
|
+
},
|
|
2623
|
+
};
|
|
2624
|
+
/**
|
|
2625
|
+
* TODO: Refactor this - each profile must be alongside the provider definition
|
|
2626
|
+
* TODO: Unite `AvatarProfileProps` and `ChatParticipant`
|
|
2627
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2628
|
+
*/
|
|
2629
|
+
|
|
2546
2630
|
/**
|
|
2547
2631
|
* Creates a connection to the remote proxy server.
|
|
2548
2632
|
*
|
|
@@ -2610,6 +2694,9 @@ class RemoteLlmExecutionTools {
|
|
|
2610
2694
|
get description() {
|
|
2611
2695
|
return `Models from Promptbook remote server ${this.options.remoteServerUrl}`;
|
|
2612
2696
|
}
|
|
2697
|
+
get profile() {
|
|
2698
|
+
return LLM_PROVIDER_PROFILES.REMOTE;
|
|
2699
|
+
}
|
|
2613
2700
|
/**
|
|
2614
2701
|
* Check the configuration of all execution tools
|
|
2615
2702
|
*/
|
|
@@ -3550,7 +3637,7 @@ class MultipleLlmExecutionTools {
|
|
|
3550
3637
|
}
|
|
3551
3638
|
return spaceTrim((block) => `
|
|
3552
3639
|
${headLine}
|
|
3553
|
-
|
|
3640
|
+
|
|
3554
3641
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
3555
3642
|
`);
|
|
3556
3643
|
})
|
|
@@ -3561,6 +3648,9 @@ class MultipleLlmExecutionTools {
|
|
|
3561
3648
|
${block(innerModelsTitlesAndDescriptions)}
|
|
3562
3649
|
`);
|
|
3563
3650
|
}
|
|
3651
|
+
get profile() {
|
|
3652
|
+
return LLM_PROVIDER_PROFILES.MULTIPLE;
|
|
3653
|
+
}
|
|
3564
3654
|
/**
|
|
3565
3655
|
* Check the configuration of all execution tools
|
|
3566
3656
|
*/
|
|
@@ -3605,25 +3695,22 @@ class MultipleLlmExecutionTools {
|
|
|
3605
3695
|
const errors = [];
|
|
3606
3696
|
llm: for (const llmExecutionTools of this.llmExecutionTools) {
|
|
3607
3697
|
try {
|
|
3608
|
-
|
|
3698
|
+
switch (prompt.modelRequirements.modelVariant) {
|
|
3609
3699
|
case 'CHAT':
|
|
3610
3700
|
if (llmExecutionTools.callChatModel === undefined) {
|
|
3611
3701
|
continue llm;
|
|
3612
3702
|
}
|
|
3613
3703
|
return await llmExecutionTools.callChatModel(prompt);
|
|
3614
|
-
break variant;
|
|
3615
3704
|
case 'COMPLETION':
|
|
3616
3705
|
if (llmExecutionTools.callCompletionModel === undefined) {
|
|
3617
3706
|
continue llm;
|
|
3618
3707
|
}
|
|
3619
3708
|
return await llmExecutionTools.callCompletionModel(prompt);
|
|
3620
|
-
break variant;
|
|
3621
3709
|
case 'EMBEDDING':
|
|
3622
3710
|
if (llmExecutionTools.callEmbeddingModel === undefined) {
|
|
3623
3711
|
continue llm;
|
|
3624
3712
|
}
|
|
3625
3713
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
3626
|
-
break variant;
|
|
3627
3714
|
// <- case [🤖]:
|
|
3628
3715
|
default:
|
|
3629
3716
|
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
@@ -5125,7 +5212,7 @@ function prettifyMarkdown(content) {
|
|
|
5125
5212
|
try {
|
|
5126
5213
|
return format(content, {
|
|
5127
5214
|
parser: 'markdown',
|
|
5128
|
-
plugins: [parserHtml],
|
|
5215
|
+
plugins: [parserMarkdown, parserHtml],
|
|
5129
5216
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
5130
5217
|
endOfLine: 'lf',
|
|
5131
5218
|
tabWidth: 4,
|
|
@@ -5597,6 +5684,7 @@ function createTask(options) {
|
|
|
5597
5684
|
const errors = [];
|
|
5598
5685
|
const warnings = [];
|
|
5599
5686
|
let currentValue = {};
|
|
5687
|
+
let customTldr = null;
|
|
5600
5688
|
const partialResultSubject = new Subject();
|
|
5601
5689
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
5602
5690
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -5607,6 +5695,9 @@ function createTask(options) {
|
|
|
5607
5695
|
Object.assign(currentValue, newOngoingResult);
|
|
5608
5696
|
// <- TODO: assign deep
|
|
5609
5697
|
partialResultSubject.next(newOngoingResult);
|
|
5698
|
+
}, (tldrInfo) => {
|
|
5699
|
+
customTldr = tldrInfo;
|
|
5700
|
+
updatedAt = new Date();
|
|
5610
5701
|
});
|
|
5611
5702
|
finalResultPromise
|
|
5612
5703
|
.catch((error) => {
|
|
@@ -5660,6 +5751,78 @@ function createTask(options) {
|
|
|
5660
5751
|
return status;
|
|
5661
5752
|
// <- Note: [1] --||--
|
|
5662
5753
|
},
|
|
5754
|
+
get tldr() {
|
|
5755
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
5756
|
+
// Use custom tldr if available
|
|
5757
|
+
if (customTldr) {
|
|
5758
|
+
return customTldr;
|
|
5759
|
+
}
|
|
5760
|
+
// Fallback to default implementation
|
|
5761
|
+
const cv = currentValue;
|
|
5762
|
+
// If explicit percent is provided, use it
|
|
5763
|
+
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;
|
|
5764
|
+
// Simulate progress if not provided
|
|
5765
|
+
if (typeof percentRaw !== 'number') {
|
|
5766
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
|
5767
|
+
const now = new Date();
|
|
5768
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
|
5769
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
|
5770
|
+
// If subtasks are defined, split progress evenly
|
|
5771
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
|
5772
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
|
5773
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
|
5774
|
+
: 0;
|
|
5775
|
+
// Progress from completed subtasks
|
|
5776
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
|
5777
|
+
// Progress from elapsed time for current subtask
|
|
5778
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
5779
|
+
// Combine: completed subtasks + time progress for current subtask
|
|
5780
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
|
5781
|
+
if (status === 'FINISHED')
|
|
5782
|
+
percentRaw = 1;
|
|
5783
|
+
if (status === 'ERROR')
|
|
5784
|
+
percentRaw = 0;
|
|
5785
|
+
}
|
|
5786
|
+
// Clamp to [0,1]
|
|
5787
|
+
let percent = Number(percentRaw) || 0;
|
|
5788
|
+
if (percent < 0)
|
|
5789
|
+
percent = 0;
|
|
5790
|
+
if (percent > 1)
|
|
5791
|
+
percent = 1;
|
|
5792
|
+
// Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
|
|
5793
|
+
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;
|
|
5794
|
+
let message = messageFromResult;
|
|
5795
|
+
if (!message) {
|
|
5796
|
+
// If subtasks, show current subtask
|
|
5797
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
|
5798
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
|
5799
|
+
if (current && current.title) {
|
|
5800
|
+
message = `Working on ${current.title}`;
|
|
5801
|
+
}
|
|
5802
|
+
}
|
|
5803
|
+
if (!message) {
|
|
5804
|
+
if (errors.length) {
|
|
5805
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
5806
|
+
}
|
|
5807
|
+
else if (warnings.length) {
|
|
5808
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
5809
|
+
}
|
|
5810
|
+
else if (status === 'FINISHED') {
|
|
5811
|
+
message = 'Finished';
|
|
5812
|
+
}
|
|
5813
|
+
else if (status === 'ERROR') {
|
|
5814
|
+
message = 'Error';
|
|
5815
|
+
}
|
|
5816
|
+
else {
|
|
5817
|
+
message = 'Running';
|
|
5818
|
+
}
|
|
5819
|
+
}
|
|
5820
|
+
}
|
|
5821
|
+
return {
|
|
5822
|
+
percent: percent,
|
|
5823
|
+
message,
|
|
5824
|
+
};
|
|
5825
|
+
},
|
|
5663
5826
|
get createdAt() {
|
|
5664
5827
|
return createdAt;
|
|
5665
5828
|
// <- Note: [1] --||--
|
|
@@ -6393,7 +6556,7 @@ function templateParameters(template, parameters) {
|
|
|
6393
6556
|
*/
|
|
6394
6557
|
async function executeAttempts(options) {
|
|
6395
6558
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
6396
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
|
|
6559
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
6397
6560
|
const $ongoingTaskResult = {
|
|
6398
6561
|
$result: null,
|
|
6399
6562
|
$resultString: null,
|
|
@@ -6637,6 +6800,10 @@ async function executeAttempts(options) {
|
|
|
6637
6800
|
result: $ongoingTaskResult.$resultString,
|
|
6638
6801
|
error: error,
|
|
6639
6802
|
});
|
|
6803
|
+
// Report failed attempt
|
|
6804
|
+
onProgress({
|
|
6805
|
+
errors: [error],
|
|
6806
|
+
});
|
|
6640
6807
|
}
|
|
6641
6808
|
finally {
|
|
6642
6809
|
if (!isJokerAttempt &&
|
|
@@ -7510,15 +7677,74 @@ function createPipelineExecutor(options) {
|
|
|
7510
7677
|
});
|
|
7511
7678
|
});
|
|
7512
7679
|
};
|
|
7513
|
-
const pipelineExecutor = (inputParameters) =>
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7680
|
+
const pipelineExecutor = (inputParameters) => {
|
|
7681
|
+
const startTime = new Date().getTime();
|
|
7682
|
+
return createTask({
|
|
7683
|
+
taskType: 'EXECUTION',
|
|
7684
|
+
title: pipeline.title,
|
|
7685
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
7686
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
7687
|
+
var _a, _b;
|
|
7688
|
+
updateOngoingResult(newOngoingResult);
|
|
7689
|
+
// Calculate and update tldr based on pipeline progress
|
|
7690
|
+
const cv = newOngoingResult;
|
|
7691
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
7692
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
7693
|
+
let resolvedParameters = 0;
|
|
7694
|
+
let currentTaskTitle = '';
|
|
7695
|
+
// Get the resolved parameters from output parameters
|
|
7696
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
7697
|
+
// Count how many output parameters have non-empty values
|
|
7698
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
7699
|
+
}
|
|
7700
|
+
// Try to determine current task from execution report
|
|
7701
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
7702
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
7703
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
7704
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
7705
|
+
}
|
|
7706
|
+
}
|
|
7707
|
+
// Calculate base progress percentage
|
|
7708
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
7709
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
7710
|
+
if (resolvedParameters < totalParameters) {
|
|
7711
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
7712
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
7713
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
7714
|
+
// If we have time progress but no parameter progress, show time progress
|
|
7715
|
+
if (percent === 0 && timeProgress > 0) {
|
|
7716
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
7717
|
+
}
|
|
7718
|
+
else if (percent < 1) {
|
|
7719
|
+
// Add partial progress for current task
|
|
7720
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
7721
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
7722
|
+
}
|
|
7723
|
+
}
|
|
7724
|
+
// Clamp to [0,1]
|
|
7725
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
7726
|
+
// Generate message
|
|
7727
|
+
let message = '';
|
|
7728
|
+
if (currentTaskTitle) {
|
|
7729
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
7730
|
+
}
|
|
7731
|
+
else if (resolvedParameters === 0) {
|
|
7732
|
+
message = 'Starting pipeline execution';
|
|
7733
|
+
}
|
|
7734
|
+
else if (resolvedParameters < totalParameters) {
|
|
7735
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
7736
|
+
}
|
|
7737
|
+
else {
|
|
7738
|
+
message = 'Completing pipeline execution';
|
|
7739
|
+
}
|
|
7740
|
+
updateTldr({
|
|
7741
|
+
percent: percent,
|
|
7742
|
+
message,
|
|
7743
|
+
});
|
|
7744
|
+
});
|
|
7745
|
+
},
|
|
7746
|
+
});
|
|
7747
|
+
};
|
|
7522
7748
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
7523
7749
|
return pipelineExecutor;
|
|
7524
7750
|
}
|
|
@@ -7581,7 +7807,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
7581
7807
|
const result = await preparePersonaExecutor({
|
|
7582
7808
|
availableModels /* <- Note: Passing as JSON */,
|
|
7583
7809
|
personaDescription,
|
|
7584
|
-
}).asPromise();
|
|
7810
|
+
}).asPromise({ isCrashedOnError: true });
|
|
7585
7811
|
const { outputParameters } = result;
|
|
7586
7812
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
7587
7813
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -8074,7 +8300,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
8074
8300
|
});
|
|
8075
8301
|
const result = await prepareTitleExecutor({
|
|
8076
8302
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
8077
|
-
}).asPromise();
|
|
8303
|
+
}).asPromise({ isCrashedOnError: true });
|
|
8078
8304
|
const { outputParameters } = result;
|
|
8079
8305
|
const { title: titleRaw } = outputParameters;
|
|
8080
8306
|
if (isVerbose) {
|
|
@@ -11989,31 +12215,23 @@ function extractBlock(markdown) {
|
|
|
11989
12215
|
return content;
|
|
11990
12216
|
}
|
|
11991
12217
|
|
|
12218
|
+
/**
|
|
12219
|
+
* @private internal for `preserve`
|
|
12220
|
+
*/
|
|
12221
|
+
const _preserved = [];
|
|
11992
12222
|
/**
|
|
11993
12223
|
* Does nothing, but preserves the function in the bundle
|
|
11994
12224
|
* Compiler is tricked into thinking the function is used
|
|
11995
12225
|
*
|
|
11996
12226
|
* @param value any function to preserve
|
|
11997
12227
|
* @returns nothing
|
|
11998
|
-
* @private
|
|
11999
|
-
*/
|
|
12000
|
-
function preserve(
|
|
12001
|
-
|
|
12002
|
-
(async () => {
|
|
12003
|
-
// TODO: [💩] Change to `await forEver` or `forTime(Infinity)`
|
|
12004
|
-
await forTime(100000000);
|
|
12005
|
-
// [1]
|
|
12006
|
-
try {
|
|
12007
|
-
await func();
|
|
12008
|
-
}
|
|
12009
|
-
finally {
|
|
12010
|
-
// do nothing
|
|
12011
|
-
}
|
|
12012
|
-
})();
|
|
12228
|
+
* @private within the repository
|
|
12229
|
+
*/
|
|
12230
|
+
function $preserve(...value) {
|
|
12231
|
+
_preserved.push(...value);
|
|
12013
12232
|
}
|
|
12014
12233
|
/**
|
|
12015
|
-
*
|
|
12016
|
-
* TODO: [1] This maybe does memory leak
|
|
12234
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
12017
12235
|
*/
|
|
12018
12236
|
|
|
12019
12237
|
// Note: [💎]
|
|
@@ -12041,25 +12259,25 @@ class JavascriptEvalExecutionTools {
|
|
|
12041
12259
|
// Note: [💎]
|
|
12042
12260
|
// Note: Using direct eval, following variables are in same scope as eval call so they are accessible from inside the evaluated script:
|
|
12043
12261
|
const spaceTrim$1 = (_) => spaceTrim(_);
|
|
12044
|
-
preserve(spaceTrim$1);
|
|
12262
|
+
$preserve(spaceTrim$1);
|
|
12045
12263
|
const removeQuotes$1 = removeQuotes;
|
|
12046
|
-
preserve(removeQuotes$1);
|
|
12264
|
+
$preserve(removeQuotes$1);
|
|
12047
12265
|
const unwrapResult$1 = unwrapResult;
|
|
12048
|
-
preserve(unwrapResult$1);
|
|
12266
|
+
$preserve(unwrapResult$1);
|
|
12049
12267
|
const trimEndOfCodeBlock$1 = trimEndOfCodeBlock;
|
|
12050
|
-
preserve(trimEndOfCodeBlock$1);
|
|
12268
|
+
$preserve(trimEndOfCodeBlock$1);
|
|
12051
12269
|
const trimCodeBlock$1 = trimCodeBlock;
|
|
12052
|
-
preserve(trimCodeBlock$1);
|
|
12270
|
+
$preserve(trimCodeBlock$1);
|
|
12053
12271
|
// TODO: DRY [🍯]
|
|
12054
12272
|
const trim = (str) => str.trim();
|
|
12055
|
-
preserve(trim);
|
|
12273
|
+
$preserve(trim);
|
|
12056
12274
|
// TODO: DRY [🍯]
|
|
12057
12275
|
const reverse = (str) => str.split('').reverse().join('');
|
|
12058
|
-
preserve(reverse);
|
|
12276
|
+
$preserve(reverse);
|
|
12059
12277
|
const removeEmojis$1 = removeEmojis;
|
|
12060
|
-
preserve(removeEmojis$1);
|
|
12278
|
+
$preserve(removeEmojis$1);
|
|
12061
12279
|
const prettifyMarkdown$1 = prettifyMarkdown;
|
|
12062
|
-
preserve(prettifyMarkdown$1);
|
|
12280
|
+
$preserve(prettifyMarkdown$1);
|
|
12063
12281
|
//-------[n12:]---
|
|
12064
12282
|
const capitalize$1 = capitalize;
|
|
12065
12283
|
const decapitalize$1 = decapitalize;
|
|
@@ -12075,18 +12293,18 @@ class JavascriptEvalExecutionTools {
|
|
|
12075
12293
|
// TODO: DRY [🍯]
|
|
12076
12294
|
Array.from(parseKeywordsFromString(input)).join(', '); /* <- TODO: [🧠] What is the best format comma list, bullet list,...? */
|
|
12077
12295
|
const normalizeTo_SCREAMING_CASE$1 = normalizeTo_SCREAMING_CASE;
|
|
12078
|
-
preserve(capitalize$1);
|
|
12079
|
-
preserve(decapitalize$1);
|
|
12080
|
-
preserve(nameToUriPart$1);
|
|
12081
|
-
preserve(nameToUriParts$1);
|
|
12082
|
-
preserve(removeDiacritics$1);
|
|
12083
|
-
preserve(normalizeWhitespaces$1);
|
|
12084
|
-
preserve(normalizeToKebabCase$1);
|
|
12085
|
-
preserve(normalizeTo_camelCase$1);
|
|
12086
|
-
preserve(normalizeTo_snake_case$1);
|
|
12087
|
-
preserve(normalizeTo_PascalCase$1);
|
|
12088
|
-
preserve(parseKeywords);
|
|
12089
|
-
preserve(normalizeTo_SCREAMING_CASE$1);
|
|
12296
|
+
$preserve(capitalize$1);
|
|
12297
|
+
$preserve(decapitalize$1);
|
|
12298
|
+
$preserve(nameToUriPart$1);
|
|
12299
|
+
$preserve(nameToUriParts$1);
|
|
12300
|
+
$preserve(removeDiacritics$1);
|
|
12301
|
+
$preserve(normalizeWhitespaces$1);
|
|
12302
|
+
$preserve(normalizeToKebabCase$1);
|
|
12303
|
+
$preserve(normalizeTo_camelCase$1);
|
|
12304
|
+
$preserve(normalizeTo_snake_case$1);
|
|
12305
|
+
$preserve(normalizeTo_PascalCase$1);
|
|
12306
|
+
$preserve(parseKeywords);
|
|
12307
|
+
$preserve(normalizeTo_SCREAMING_CASE$1);
|
|
12090
12308
|
//-------[/n12]---
|
|
12091
12309
|
if (!script.includes('return')) {
|
|
12092
12310
|
script = `return ${script}`;
|
|
@@ -13587,7 +13805,7 @@ async function runInteractiveChatbot(options) {
|
|
|
13587
13805
|
previousConversationSummary: conversationSummary,
|
|
13588
13806
|
userMessage,
|
|
13589
13807
|
};
|
|
13590
|
-
const result = await pipelineExecutor(inputParameters).asPromise();
|
|
13808
|
+
const result = await pipelineExecutor(inputParameters).asPromise({ isCrashedOnError: true });
|
|
13591
13809
|
console.info(`\n`);
|
|
13592
13810
|
console.info(spaceTrim((block) => `
|
|
13593
13811
|
|
|
@@ -14747,7 +14965,7 @@ function startRemoteServer(options) {
|
|
|
14747
14965
|
});
|
|
14748
14966
|
function exportExecutionTask(executionTask, isFull) {
|
|
14749
14967
|
// <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
|
|
14750
|
-
const { taskType, promptbookVersion, taskId, title, status, errors, warnings, createdAt, updatedAt, currentValue, } = executionTask;
|
|
14968
|
+
const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, } = executionTask;
|
|
14751
14969
|
if (isFull) {
|
|
14752
14970
|
return {
|
|
14753
14971
|
taskId,
|
|
@@ -14755,6 +14973,7 @@ function startRemoteServer(options) {
|
|
|
14755
14973
|
taskType,
|
|
14756
14974
|
promptbookVersion,
|
|
14757
14975
|
status,
|
|
14976
|
+
tldr,
|
|
14758
14977
|
errors: errors.map(serializeError),
|
|
14759
14978
|
warnings: warnings.map(serializeError),
|
|
14760
14979
|
createdAt,
|
|
@@ -14769,6 +14988,7 @@ function startRemoteServer(options) {
|
|
|
14769
14988
|
taskType,
|
|
14770
14989
|
promptbookVersion,
|
|
14771
14990
|
status,
|
|
14991
|
+
tldr,
|
|
14772
14992
|
createdAt,
|
|
14773
14993
|
updatedAt,
|
|
14774
14994
|
};
|
|
@@ -15335,7 +15555,7 @@ function pricing(value) {
|
|
|
15335
15555
|
/**
|
|
15336
15556
|
* List of available Anthropic Claude models with pricing
|
|
15337
15557
|
*
|
|
15338
|
-
* Note:
|
|
15558
|
+
* Note: Synced with official API docs at 2025-08-20
|
|
15339
15559
|
*
|
|
15340
15560
|
* @see https://docs.anthropic.com/en/docs/models-overview
|
|
15341
15561
|
* @public exported from `@promptbook/anthropic-claude`
|
|
@@ -15345,12 +15565,52 @@ const ANTHROPIC_CLAUDE_MODELS = exportJson({
|
|
|
15345
15565
|
value: [
|
|
15346
15566
|
{
|
|
15347
15567
|
modelVariant: 'CHAT',
|
|
15348
|
-
modelTitle: 'Claude
|
|
15349
|
-
modelName: 'claude-
|
|
15350
|
-
modelDescription: '
|
|
15568
|
+
modelTitle: 'Claude Opus 4.1',
|
|
15569
|
+
modelName: 'claude-opus-4-1-20250805',
|
|
15570
|
+
modelDescription: 'Most powerful and capable Claude model with 200K token context window. Features superior reasoning capabilities, exceptional coding abilities, and advanced multimodal understanding. Sets new standards in complex reasoning and analytical tasks with enhanced safety measures. Ideal for the most demanding enterprise applications requiring maximum intelligence.',
|
|
15351
15571
|
pricing: {
|
|
15352
|
-
prompt: pricing(`$
|
|
15353
|
-
output: pricing(`$
|
|
15572
|
+
prompt: pricing(`$15.00 / 1M tokens`),
|
|
15573
|
+
output: pricing(`$75.00 / 1M tokens`),
|
|
15574
|
+
},
|
|
15575
|
+
},
|
|
15576
|
+
{
|
|
15577
|
+
modelVariant: 'CHAT',
|
|
15578
|
+
modelTitle: 'Claude Opus 4',
|
|
15579
|
+
modelName: 'claude-opus-4-20250514',
|
|
15580
|
+
modelDescription: 'Previous flagship Claude model with 200K token context window. Features very high intelligence and capability with exceptional performance across reasoning, coding, and creative tasks. Maintains strong safety guardrails while delivering sophisticated outputs for complex professional applications.',
|
|
15581
|
+
pricing: {
|
|
15582
|
+
prompt: pricing(`$15.00 / 1M tokens`),
|
|
15583
|
+
output: pricing(`$75.00 / 1M tokens`),
|
|
15584
|
+
},
|
|
15585
|
+
},
|
|
15586
|
+
{
|
|
15587
|
+
modelVariant: 'CHAT',
|
|
15588
|
+
modelTitle: 'Claude Sonnet 4',
|
|
15589
|
+
modelName: 'claude-sonnet-4-20250514',
|
|
15590
|
+
modelDescription: 'High-performance Claude model with exceptional reasoning capabilities and 200K token context window (1M context beta available). Features balanced intelligence and efficiency with enhanced multimodal understanding. Offers optimal performance for most enterprise applications requiring sophisticated AI capabilities.',
|
|
15591
|
+
pricing: {
|
|
15592
|
+
prompt: pricing(`$3.00 / 1M tokens`),
|
|
15593
|
+
output: pricing(`$15.00 / 1M tokens`),
|
|
15594
|
+
},
|
|
15595
|
+
},
|
|
15596
|
+
{
|
|
15597
|
+
modelVariant: 'CHAT',
|
|
15598
|
+
modelTitle: 'Claude Sonnet 3.7',
|
|
15599
|
+
modelName: 'claude-3-7-sonnet-20250219',
|
|
15600
|
+
modelDescription: 'High-performance Claude model with early extended thinking capabilities and 200K token context window. Features enhanced reasoning chains, improved factual accuracy, and toggleable extended thinking for complex problem-solving. Ideal for applications requiring deep analytical capabilities.',
|
|
15601
|
+
pricing: {
|
|
15602
|
+
prompt: pricing(`$3.00 / 1M tokens`),
|
|
15603
|
+
output: pricing(`$15.00 / 1M tokens`),
|
|
15604
|
+
},
|
|
15605
|
+
},
|
|
15606
|
+
{
|
|
15607
|
+
modelVariant: 'CHAT',
|
|
15608
|
+
modelTitle: 'Claude Haiku 3.5',
|
|
15609
|
+
modelName: 'claude-3-5-haiku-20241022',
|
|
15610
|
+
modelDescription: 'Fastest Claude model with 200K token context window optimized for intelligence at blazing speeds. Features enhanced reasoning and contextual understanding while maintaining sub-second response times. Perfect for real-time applications, customer-facing deployments, and high-throughput services.',
|
|
15611
|
+
pricing: {
|
|
15612
|
+
prompt: pricing(`$0.80 / 1M tokens`),
|
|
15613
|
+
output: pricing(`$4.00 / 1M tokens`),
|
|
15354
15614
|
},
|
|
15355
15615
|
},
|
|
15356
15616
|
{
|
|
@@ -15573,6 +15833,9 @@ class AnthropicClaudeExecutionTools {
|
|
|
15573
15833
|
get description() {
|
|
15574
15834
|
return 'Use all models provided by Anthropic Claude';
|
|
15575
15835
|
}
|
|
15836
|
+
get profile() {
|
|
15837
|
+
return LLM_PROVIDER_PROFILES.ANTHROPIC;
|
|
15838
|
+
}
|
|
15576
15839
|
async getClient() {
|
|
15577
15840
|
if (this.client === null) {
|
|
15578
15841
|
// Note: Passing only Anthropic Claude relevant options to Anthropic constructor
|
|
@@ -15613,8 +15876,7 @@ class AnthropicClaudeExecutionTools {
|
|
|
15613
15876
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
15614
15877
|
const rawRequest = {
|
|
15615
15878
|
model: modelRequirements.modelName || this.getDefaultChatModel().modelName,
|
|
15616
|
-
max_tokens: modelRequirements.maxTokens ||
|
|
15617
|
-
// <- TODO: [🌾] Make some global max cap for maxTokens
|
|
15879
|
+
max_tokens: modelRequirements.maxTokens || 8192,
|
|
15618
15880
|
temperature: modelRequirements.temperature,
|
|
15619
15881
|
system: modelRequirements.systemMessage,
|
|
15620
15882
|
messages: [
|
|
@@ -15673,59 +15935,6 @@ class AnthropicClaudeExecutionTools {
|
|
|
15673
15935
|
},
|
|
15674
15936
|
});
|
|
15675
15937
|
}
|
|
15676
|
-
/**
|
|
15677
|
-
* Calls Anthropic Claude API to use a completion model.
|
|
15678
|
-
*/
|
|
15679
|
-
async callCompletionModel(prompt) {
|
|
15680
|
-
if (this.options.isVerbose) {
|
|
15681
|
-
console.info('🖋 Anthropic Claude callCompletionModel call');
|
|
15682
|
-
}
|
|
15683
|
-
const { content, parameters, modelRequirements } = prompt;
|
|
15684
|
-
if (modelRequirements.modelVariant !== 'COMPLETION') {
|
|
15685
|
-
throw new PipelineExecutionError('Use callCompletionModel only for COMPLETION variant');
|
|
15686
|
-
}
|
|
15687
|
-
const client = await this.getClient();
|
|
15688
|
-
const modelName = modelRequirements.modelName || this.getDefaultChatModel().modelName;
|
|
15689
|
-
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
15690
|
-
const rawRequest = {
|
|
15691
|
-
model: modelName,
|
|
15692
|
-
max_tokens_to_sample: modelRequirements.maxTokens || 2000,
|
|
15693
|
-
temperature: modelRequirements.temperature,
|
|
15694
|
-
prompt: rawPromptContent,
|
|
15695
|
-
};
|
|
15696
|
-
const start = $getCurrentDate();
|
|
15697
|
-
const rawResponse = await this.limiter
|
|
15698
|
-
.schedule(() => client.completions.create(rawRequest))
|
|
15699
|
-
.catch((error) => {
|
|
15700
|
-
if (this.options.isVerbose) {
|
|
15701
|
-
console.info(colors.bgRed('error'), error);
|
|
15702
|
-
}
|
|
15703
|
-
throw error;
|
|
15704
|
-
});
|
|
15705
|
-
if (this.options.isVerbose) {
|
|
15706
|
-
console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
15707
|
-
}
|
|
15708
|
-
if (!rawResponse.completion) {
|
|
15709
|
-
throw new PipelineExecutionError('No completion from Anthropic Claude');
|
|
15710
|
-
}
|
|
15711
|
-
const resultContent = rawResponse.completion;
|
|
15712
|
-
const complete = $getCurrentDate();
|
|
15713
|
-
const usage = computeAnthropicClaudeUsage(rawPromptContent, resultContent, rawResponse);
|
|
15714
|
-
return exportJson({
|
|
15715
|
-
name: 'promptResult',
|
|
15716
|
-
message: `Result of \`AnthropicClaudeExecutionTools.callCompletionModel\``,
|
|
15717
|
-
order: [],
|
|
15718
|
-
value: {
|
|
15719
|
-
content: resultContent,
|
|
15720
|
-
modelName: rawResponse.model || modelName,
|
|
15721
|
-
timing: { start, complete },
|
|
15722
|
-
usage,
|
|
15723
|
-
rawPromptContent,
|
|
15724
|
-
rawRequest,
|
|
15725
|
-
rawResponse,
|
|
15726
|
-
},
|
|
15727
|
-
});
|
|
15728
|
-
}
|
|
15729
15938
|
// <- Note: [🤖] callXxxModel
|
|
15730
15939
|
/**
|
|
15731
15940
|
* Get the model that should be used as default
|
|
@@ -15747,7 +15956,7 @@ class AnthropicClaudeExecutionTools {
|
|
|
15747
15956
|
* Default model for chat variant.
|
|
15748
15957
|
*/
|
|
15749
15958
|
getDefaultChatModel() {
|
|
15750
|
-
return this.getDefaultModel('claude-
|
|
15959
|
+
return this.getDefaultModel('claude-sonnet-4-20250514');
|
|
15751
15960
|
}
|
|
15752
15961
|
}
|
|
15753
15962
|
/**
|
|
@@ -15890,7 +16099,7 @@ const _AzureOpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
15890
16099
|
/**
|
|
15891
16100
|
* List of available OpenAI models with pricing
|
|
15892
16101
|
*
|
|
15893
|
-
* Note:
|
|
16102
|
+
* Note: Synced with official API docs at 2025-08-20
|
|
15894
16103
|
*
|
|
15895
16104
|
* @see https://platform.openai.com/docs/models/
|
|
15896
16105
|
* @see https://openai.com/api/pricing/
|
|
@@ -15899,6 +16108,138 @@ const _AzureOpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
15899
16108
|
const OPENAI_MODELS = exportJson({
|
|
15900
16109
|
name: 'OPENAI_MODELS',
|
|
15901
16110
|
value: [
|
|
16111
|
+
/**/
|
|
16112
|
+
{
|
|
16113
|
+
modelVariant: 'CHAT',
|
|
16114
|
+
modelTitle: 'gpt-5',
|
|
16115
|
+
modelName: 'gpt-5',
|
|
16116
|
+
modelDescription: "OpenAI's most advanced language model with unprecedented reasoning capabilities and 200K context window. Features revolutionary improvements in complex problem-solving, scientific reasoning, and creative tasks. Demonstrates human-level performance across diverse domains with enhanced safety measures and alignment. Represents the next generation of AI with superior understanding, nuanced responses, and advanced multimodal capabilities.",
|
|
16117
|
+
pricing: {
|
|
16118
|
+
prompt: pricing(`$1.25 / 1M tokens`),
|
|
16119
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
16120
|
+
},
|
|
16121
|
+
},
|
|
16122
|
+
/**/
|
|
16123
|
+
/**/
|
|
16124
|
+
{
|
|
16125
|
+
modelVariant: 'CHAT',
|
|
16126
|
+
modelTitle: 'gpt-5-mini',
|
|
16127
|
+
modelName: 'gpt-5-mini',
|
|
16128
|
+
modelDescription: "A faster, cost-efficient version of GPT-5 for well-defined tasks with 200K context window. Maintains core GPT-5 capabilities while offering 5x faster inference and significantly lower costs. Features enhanced instruction following and reduced latency for production applications requiring quick responses with high quality.",
|
|
16129
|
+
pricing: {
|
|
16130
|
+
prompt: pricing(`$0.25 / 1M tokens`),
|
|
16131
|
+
output: pricing(`$2.00 / 1M tokens`),
|
|
16132
|
+
},
|
|
16133
|
+
},
|
|
16134
|
+
/**/
|
|
16135
|
+
/**/
|
|
16136
|
+
{
|
|
16137
|
+
modelVariant: 'CHAT',
|
|
16138
|
+
modelTitle: 'gpt-5-nano',
|
|
16139
|
+
modelName: 'gpt-5-nano',
|
|
16140
|
+
modelDescription: "The fastest, most cost-efficient version of GPT-5 with 200K context window. Optimized for summarization, classification, and simple reasoning tasks. Features 10x faster inference than base GPT-5 while maintaining good quality for straightforward applications. Ideal for high-volume, cost-sensitive deployments.",
|
|
16141
|
+
pricing: {
|
|
16142
|
+
prompt: pricing(`$0.05 / 1M tokens`),
|
|
16143
|
+
output: pricing(`$0.40 / 1M tokens`),
|
|
16144
|
+
},
|
|
16145
|
+
},
|
|
16146
|
+
/**/
|
|
16147
|
+
/**/
|
|
16148
|
+
{
|
|
16149
|
+
modelVariant: 'CHAT',
|
|
16150
|
+
modelTitle: 'gpt-4.1',
|
|
16151
|
+
modelName: 'gpt-4.1',
|
|
16152
|
+
modelDescription: "Smartest non-reasoning model with 128K context window. Enhanced version of GPT-4 with improved instruction following, better factual accuracy, and reduced hallucinations. Features advanced function calling capabilities and superior performance on coding tasks. Ideal for applications requiring high intelligence without reasoning overhead.",
|
|
16153
|
+
pricing: {
|
|
16154
|
+
prompt: pricing(`$3.00 / 1M tokens`),
|
|
16155
|
+
output: pricing(`$12.00 / 1M tokens`),
|
|
16156
|
+
},
|
|
16157
|
+
},
|
|
16158
|
+
/**/
|
|
16159
|
+
/**/
|
|
16160
|
+
{
|
|
16161
|
+
modelVariant: 'CHAT',
|
|
16162
|
+
modelTitle: 'gpt-4.1-mini',
|
|
16163
|
+
modelName: 'gpt-4.1-mini',
|
|
16164
|
+
modelDescription: "Smaller, faster version of GPT-4.1 with 128K context window. Balances intelligence and efficiency with 3x faster inference than base GPT-4.1. Maintains strong capabilities across text generation, reasoning, and coding while offering better cost-performance ratio for most applications.",
|
|
16165
|
+
pricing: {
|
|
16166
|
+
prompt: pricing(`$0.80 / 1M tokens`),
|
|
16167
|
+
output: pricing(`$3.20 / 1M tokens`),
|
|
16168
|
+
},
|
|
16169
|
+
},
|
|
16170
|
+
/**/
|
|
16171
|
+
/**/
|
|
16172
|
+
{
|
|
16173
|
+
modelVariant: 'CHAT',
|
|
16174
|
+
modelTitle: 'gpt-4.1-nano',
|
|
16175
|
+
modelName: 'gpt-4.1-nano',
|
|
16176
|
+
modelDescription: "Fastest, most cost-efficient version of GPT-4.1 with 128K context window. Optimized for high-throughput applications requiring good quality at minimal cost. Features 5x faster inference than GPT-4.1 while maintaining adequate performance for most general-purpose tasks.",
|
|
16177
|
+
pricing: {
|
|
16178
|
+
prompt: pricing(`$0.20 / 1M tokens`),
|
|
16179
|
+
output: pricing(`$0.80 / 1M tokens`),
|
|
16180
|
+
},
|
|
16181
|
+
},
|
|
16182
|
+
/**/
|
|
16183
|
+
/**/
|
|
16184
|
+
{
|
|
16185
|
+
modelVariant: 'CHAT',
|
|
16186
|
+
modelTitle: 'o3',
|
|
16187
|
+
modelName: 'o3',
|
|
16188
|
+
modelDescription: "Advanced reasoning model with 128K context window specializing in complex logical, mathematical, and analytical tasks. Successor to o1 with enhanced step-by-step problem-solving capabilities and superior performance on STEM-focused problems. Ideal for professional applications requiring deep analytical thinking and precise reasoning.",
|
|
16189
|
+
pricing: {
|
|
16190
|
+
prompt: pricing(`$15.00 / 1M tokens`),
|
|
16191
|
+
output: pricing(`$60.00 / 1M tokens`),
|
|
16192
|
+
},
|
|
16193
|
+
},
|
|
16194
|
+
/**/
|
|
16195
|
+
/**/
|
|
16196
|
+
{
|
|
16197
|
+
modelVariant: 'CHAT',
|
|
16198
|
+
modelTitle: 'o3-pro',
|
|
16199
|
+
modelName: 'o3-pro',
|
|
16200
|
+
modelDescription: "Enhanced version of o3 with more compute allocated for better responses on the most challenging problems. Features extended reasoning time and improved accuracy on complex analytical tasks. Designed for applications where maximum reasoning quality is more important than response speed.",
|
|
16201
|
+
pricing: {
|
|
16202
|
+
prompt: pricing(`$30.00 / 1M tokens`),
|
|
16203
|
+
output: pricing(`$120.00 / 1M tokens`),
|
|
16204
|
+
},
|
|
16205
|
+
},
|
|
16206
|
+
/**/
|
|
16207
|
+
/**/
|
|
16208
|
+
{
|
|
16209
|
+
modelVariant: 'CHAT',
|
|
16210
|
+
modelTitle: 'o4-mini',
|
|
16211
|
+
modelName: 'o4-mini',
|
|
16212
|
+
modelDescription: "Fast, cost-efficient reasoning model with 128K context window. Successor to o1-mini with improved analytical capabilities while maintaining speed advantages. Features enhanced mathematical reasoning and logical problem-solving at significantly lower cost than full reasoning models.",
|
|
16213
|
+
pricing: {
|
|
16214
|
+
prompt: pricing(`$4.00 / 1M tokens`),
|
|
16215
|
+
output: pricing(`$16.00 / 1M tokens`),
|
|
16216
|
+
},
|
|
16217
|
+
},
|
|
16218
|
+
/**/
|
|
16219
|
+
/**/
|
|
16220
|
+
{
|
|
16221
|
+
modelVariant: 'CHAT',
|
|
16222
|
+
modelTitle: 'o3-deep-research',
|
|
16223
|
+
modelName: 'o3-deep-research',
|
|
16224
|
+
modelDescription: "Most powerful deep research model with 128K context window. Specialized for comprehensive research tasks, literature analysis, and complex information synthesis. Features advanced citation capabilities and enhanced factual accuracy for academic and professional research applications.",
|
|
16225
|
+
pricing: {
|
|
16226
|
+
prompt: pricing(`$25.00 / 1M tokens`),
|
|
16227
|
+
output: pricing(`$100.00 / 1M tokens`),
|
|
16228
|
+
},
|
|
16229
|
+
},
|
|
16230
|
+
/**/
|
|
16231
|
+
/**/
|
|
16232
|
+
{
|
|
16233
|
+
modelVariant: 'CHAT',
|
|
16234
|
+
modelTitle: 'o4-mini-deep-research',
|
|
16235
|
+
modelName: 'o4-mini-deep-research',
|
|
16236
|
+
modelDescription: "Faster, more affordable deep research model with 128K context window. Balances research capabilities with cost efficiency, offering good performance on literature review, fact-checking, and information synthesis tasks at a more accessible price point.",
|
|
16237
|
+
pricing: {
|
|
16238
|
+
prompt: pricing(`$12.00 / 1M tokens`),
|
|
16239
|
+
output: pricing(`$48.00 / 1M tokens`),
|
|
16240
|
+
},
|
|
16241
|
+
},
|
|
16242
|
+
/**/
|
|
15902
16243
|
/*/
|
|
15903
16244
|
{
|
|
15904
16245
|
modelTitle: 'dall-e-3',
|
|
@@ -16419,7 +16760,6 @@ class AzureOpenAiExecutionTools {
|
|
|
16419
16760
|
const modelName = prompt.modelRequirements.modelName || this.options.deploymentName;
|
|
16420
16761
|
const modelSettings = {
|
|
16421
16762
|
maxTokens: modelRequirements.maxTokens,
|
|
16422
|
-
// <- TODO: [🌾] Make some global max cap for maxTokens
|
|
16423
16763
|
temperature: modelRequirements.temperature,
|
|
16424
16764
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
16425
16765
|
// <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
@@ -16525,8 +16865,7 @@ class AzureOpenAiExecutionTools {
|
|
|
16525
16865
|
try {
|
|
16526
16866
|
const modelName = prompt.modelRequirements.modelName || this.options.deploymentName;
|
|
16527
16867
|
const modelSettings = {
|
|
16528
|
-
maxTokens: modelRequirements.maxTokens
|
|
16529
|
-
// <- TODO: [🌾] Make some global max cap for maxTokens
|
|
16868
|
+
maxTokens: modelRequirements.maxTokens,
|
|
16530
16869
|
temperature: modelRequirements.temperature,
|
|
16531
16870
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
16532
16871
|
// <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
@@ -16892,7 +17231,7 @@ function createExecutionToolsFromVercelProvider(options) {
|
|
|
16892
17231
|
/**
|
|
16893
17232
|
* List of available Deepseek models with descriptions
|
|
16894
17233
|
*
|
|
16895
|
-
* Note:
|
|
17234
|
+
* Note: Synced with official API docs at 2025-08-20
|
|
16896
17235
|
*
|
|
16897
17236
|
* @see https://www.deepseek.com/models
|
|
16898
17237
|
* @public exported from `@promptbook/deepseek`
|
|
@@ -16902,12 +17241,32 @@ const DEEPSEEK_MODELS = exportJson({
|
|
|
16902
17241
|
value: [
|
|
16903
17242
|
{
|
|
16904
17243
|
modelVariant: 'CHAT',
|
|
16905
|
-
modelTitle: '
|
|
16906
|
-
modelName: 'deepseek-chat
|
|
16907
|
-
modelDescription: 'Latest flagship general-purpose model with
|
|
17244
|
+
modelTitle: 'DeepSeek V3',
|
|
17245
|
+
modelName: 'deepseek-chat',
|
|
17246
|
+
modelDescription: 'Latest flagship general-purpose model with 128K context window. Features exceptional reasoning capabilities, advanced code generation, and strong performance across diverse domains. Offers competitive performance with leading models while maintaining cost efficiency. Ideal for complex reasoning, coding, and knowledge-intensive tasks.',
|
|
16908
17247
|
pricing: {
|
|
16909
|
-
prompt: pricing(`$
|
|
16910
|
-
output: pricing(`$
|
|
17248
|
+
prompt: pricing(`$0.14 / 1M tokens`),
|
|
17249
|
+
output: pricing(`$0.28 / 1M tokens`),
|
|
17250
|
+
},
|
|
17251
|
+
},
|
|
17252
|
+
{
|
|
17253
|
+
modelVariant: 'CHAT',
|
|
17254
|
+
modelTitle: 'DeepSeek R1',
|
|
17255
|
+
modelName: 'deepseek-reasoner',
|
|
17256
|
+
modelDescription: 'Advanced reasoning model with 128K context window specializing in complex problem-solving and analytical thinking. Features explicit reasoning chains, enhanced mathematical capabilities, and superior performance on STEM tasks. Designed for applications requiring deep analytical reasoning and step-by-step problem solving.',
|
|
17257
|
+
pricing: {
|
|
17258
|
+
prompt: pricing(`$0.55 / 1M tokens`),
|
|
17259
|
+
output: pricing(`$2.19 / 1M tokens`),
|
|
17260
|
+
},
|
|
17261
|
+
},
|
|
17262
|
+
{
|
|
17263
|
+
modelVariant: 'CHAT',
|
|
17264
|
+
modelTitle: 'DeepSeek Coder V2',
|
|
17265
|
+
modelName: 'deepseek-coder',
|
|
17266
|
+
modelDescription: 'Specialized coding model with 128K context window optimized for software development tasks. Features exceptional code generation, debugging, and refactoring capabilities across 40+ programming languages. Particularly strong in understanding complex codebases and implementing solutions based on natural language specifications.',
|
|
17267
|
+
pricing: {
|
|
17268
|
+
prompt: pricing(`$0.14 / 1M tokens`),
|
|
17269
|
+
output: pricing(`$0.28 / 1M tokens`),
|
|
16911
17270
|
},
|
|
16912
17271
|
},
|
|
16913
17272
|
{
|
|
@@ -17141,7 +17500,7 @@ const _GoogleMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
17141
17500
|
/**
|
|
17142
17501
|
* List of available Google models with descriptions
|
|
17143
17502
|
*
|
|
17144
|
-
* Note:
|
|
17503
|
+
* Note: Synced with official API docs at 2025-08-20
|
|
17145
17504
|
*
|
|
17146
17505
|
* @see https://ai.google.dev/models/gemini
|
|
17147
17506
|
* @public exported from `@promptbook/google`
|
|
@@ -17152,11 +17511,51 @@ const GOOGLE_MODELS = exportJson({
|
|
|
17152
17511
|
{
|
|
17153
17512
|
modelVariant: 'CHAT',
|
|
17154
17513
|
modelTitle: 'Gemini 2.5 Pro',
|
|
17155
|
-
modelName: 'gemini-2.5-pro
|
|
17156
|
-
modelDescription: '
|
|
17514
|
+
modelName: 'gemini-2.5-pro',
|
|
17515
|
+
modelDescription: 'State-of-the-art thinking model with 1M token context window capable of reasoning over complex problems in code, math, and STEM. Features enhanced thinking capabilities, advanced multimodal understanding, and superior performance on analytical tasks. Ideal for complex enterprise applications requiring maximum intelligence and reasoning.',
|
|
17157
17516
|
pricing: {
|
|
17158
|
-
prompt: pricing(`$
|
|
17159
|
-
output: pricing(`$
|
|
17517
|
+
prompt: pricing(`$7.00 / 1M tokens`),
|
|
17518
|
+
output: pricing(`$21.00 / 1M tokens`),
|
|
17519
|
+
},
|
|
17520
|
+
},
|
|
17521
|
+
{
|
|
17522
|
+
modelVariant: 'CHAT',
|
|
17523
|
+
modelTitle: 'Gemini 2.5 Flash',
|
|
17524
|
+
modelName: 'gemini-2.5-flash',
|
|
17525
|
+
modelDescription: 'Best model in terms of price-performance with 1M token context window offering well-rounded capabilities. Features adaptive thinking, cost efficiency, and enhanced reasoning for large-scale processing. Ideal for low-latency, high-volume tasks that require thinking and agentic use cases.',
|
|
17526
|
+
pricing: {
|
|
17527
|
+
prompt: pricing(`$0.35 / 1M tokens`),
|
|
17528
|
+
output: pricing(`$1.05 / 1M tokens`),
|
|
17529
|
+
},
|
|
17530
|
+
},
|
|
17531
|
+
{
|
|
17532
|
+
modelVariant: 'CHAT',
|
|
17533
|
+
modelTitle: 'Gemini 2.5 Flash Lite',
|
|
17534
|
+
modelName: 'gemini-2.5-flash-lite',
|
|
17535
|
+
modelDescription: 'Cost-efficient Gemini 2.5 Flash model optimized for high throughput with 1M token context window. Features thinking capabilities while maintaining the most cost-efficient pricing. Perfect for real-time, low-latency use cases requiring good quality at scale.',
|
|
17536
|
+
pricing: {
|
|
17537
|
+
prompt: pricing(`$0.20 / 1M tokens`),
|
|
17538
|
+
output: pricing(`$0.60 / 1M tokens`),
|
|
17539
|
+
},
|
|
17540
|
+
},
|
|
17541
|
+
{
|
|
17542
|
+
modelVariant: 'CHAT',
|
|
17543
|
+
modelTitle: 'Gemini 2.0 Flash',
|
|
17544
|
+
modelName: 'gemini-2.0-flash',
|
|
17545
|
+
modelDescription: 'Next-generation model with 1M token context window delivering improved capabilities, superior speed, and realtime streaming. Features enhanced function calling, code execution, and search capabilities. Ideal for applications requiring cutting-edge AI capabilities with fast response times.',
|
|
17546
|
+
pricing: {
|
|
17547
|
+
prompt: pricing(`$0.25 / 1M tokens`),
|
|
17548
|
+
output: pricing(`$0.75 / 1M tokens`),
|
|
17549
|
+
},
|
|
17550
|
+
},
|
|
17551
|
+
{
|
|
17552
|
+
modelVariant: 'CHAT',
|
|
17553
|
+
modelTitle: 'Gemini 2.0 Flash Lite',
|
|
17554
|
+
modelName: 'gemini-2.0-flash-lite',
|
|
17555
|
+
modelDescription: 'Cost-efficient Gemini 2.0 Flash model optimized for low latency with 1M token context window. Balances performance and cost with enhanced efficiency for high-volume applications. Perfect for applications requiring good quality responses at minimal cost.',
|
|
17556
|
+
pricing: {
|
|
17557
|
+
prompt: pricing(`$0.15 / 1M tokens`),
|
|
17558
|
+
output: pricing(`$0.45 / 1M tokens`),
|
|
17160
17559
|
},
|
|
17161
17560
|
},
|
|
17162
17561
|
{
|
|
@@ -17504,7 +17903,18 @@ class OpenAiCompatibleExecutionTools {
|
|
|
17504
17903
|
const openAiOptions = { ...this.options };
|
|
17505
17904
|
delete openAiOptions.isVerbose;
|
|
17506
17905
|
delete openAiOptions.userId;
|
|
17507
|
-
|
|
17906
|
+
// Enhanced configuration for better ECONNRESET handling
|
|
17907
|
+
const enhancedOptions = {
|
|
17908
|
+
...openAiOptions,
|
|
17909
|
+
timeout: API_REQUEST_TIMEOUT,
|
|
17910
|
+
maxRetries: CONNECTION_RETRIES_LIMIT,
|
|
17911
|
+
defaultHeaders: {
|
|
17912
|
+
Connection: 'keep-alive',
|
|
17913
|
+
'Keep-Alive': 'timeout=30, max=100',
|
|
17914
|
+
...openAiOptions.defaultHeaders,
|
|
17915
|
+
},
|
|
17916
|
+
};
|
|
17917
|
+
this.client = new OpenAI(enhancedOptions);
|
|
17508
17918
|
}
|
|
17509
17919
|
return this.client;
|
|
17510
17920
|
}
|
|
@@ -17557,7 +17967,6 @@ class OpenAiCompatibleExecutionTools {
|
|
|
17557
17967
|
const modelSettings = {
|
|
17558
17968
|
model: modelName,
|
|
17559
17969
|
max_tokens: modelRequirements.maxTokens,
|
|
17560
|
-
// <- TODO: [🌾] Make some global max cap for maxTokens
|
|
17561
17970
|
temperature: modelRequirements.temperature,
|
|
17562
17971
|
// <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
17563
17972
|
// <- Note: [🧆]
|
|
@@ -17593,7 +18002,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
17593
18002
|
console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
17594
18003
|
}
|
|
17595
18004
|
const rawResponse = await this.limiter
|
|
17596
|
-
.schedule(() => client.chat.completions.create(rawRequest))
|
|
18005
|
+
.schedule(() => this.makeRequestWithRetry(() => client.chat.completions.create(rawRequest)))
|
|
17597
18006
|
.catch((error) => {
|
|
17598
18007
|
assertsError(error);
|
|
17599
18008
|
if (this.options.isVerbose) {
|
|
@@ -17653,8 +18062,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
17653
18062
|
const modelName = modelRequirements.modelName || this.getDefaultCompletionModel().modelName;
|
|
17654
18063
|
const modelSettings = {
|
|
17655
18064
|
model: modelName,
|
|
17656
|
-
max_tokens: modelRequirements.maxTokens
|
|
17657
|
-
// <- TODO: [🌾] Make some global max cap for maxTokens
|
|
18065
|
+
max_tokens: modelRequirements.maxTokens,
|
|
17658
18066
|
temperature: modelRequirements.temperature,
|
|
17659
18067
|
// <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
17660
18068
|
// <- Note: [🧆]
|
|
@@ -17670,7 +18078,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
17670
18078
|
console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
17671
18079
|
}
|
|
17672
18080
|
const rawResponse = await this.limiter
|
|
17673
|
-
.schedule(() => client.completions.create(rawRequest))
|
|
18081
|
+
.schedule(() => this.makeRequestWithRetry(() => client.completions.create(rawRequest)))
|
|
17674
18082
|
.catch((error) => {
|
|
17675
18083
|
assertsError(error);
|
|
17676
18084
|
if (this.options.isVerbose) {
|
|
@@ -17734,7 +18142,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
17734
18142
|
console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
17735
18143
|
}
|
|
17736
18144
|
const rawResponse = await this.limiter
|
|
17737
|
-
.schedule(() => client.embeddings.create(rawRequest))
|
|
18145
|
+
.schedule(() => this.makeRequestWithRetry(() => client.embeddings.create(rawRequest)))
|
|
17738
18146
|
.catch((error) => {
|
|
17739
18147
|
assertsError(error);
|
|
17740
18148
|
if (this.options.isVerbose) {
|
|
@@ -17792,6 +18200,76 @@ class OpenAiCompatibleExecutionTools {
|
|
|
17792
18200
|
}
|
|
17793
18201
|
return model;
|
|
17794
18202
|
}
|
|
18203
|
+
// <- Note: [🤖] getDefaultXxxModel
|
|
18204
|
+
/**
|
|
18205
|
+
* Makes a request with retry logic for network errors like ECONNRESET
|
|
18206
|
+
*/
|
|
18207
|
+
async makeRequestWithRetry(requestFn) {
|
|
18208
|
+
let lastError;
|
|
18209
|
+
for (let attempt = 1; attempt <= CONNECTION_RETRIES_LIMIT; attempt++) {
|
|
18210
|
+
try {
|
|
18211
|
+
return await requestFn();
|
|
18212
|
+
}
|
|
18213
|
+
catch (error) {
|
|
18214
|
+
assertsError(error);
|
|
18215
|
+
lastError = error;
|
|
18216
|
+
// Check if this is a retryable network error
|
|
18217
|
+
const isRetryableError = this.isRetryableNetworkError(error);
|
|
18218
|
+
if (!isRetryableError || attempt === CONNECTION_RETRIES_LIMIT) {
|
|
18219
|
+
if (this.options.isVerbose) {
|
|
18220
|
+
console.info(colors.bgRed('Final error after retries'), `Attempt ${attempt}/${CONNECTION_RETRIES_LIMIT}:`, error);
|
|
18221
|
+
}
|
|
18222
|
+
throw error;
|
|
18223
|
+
}
|
|
18224
|
+
// Calculate exponential backoff delay
|
|
18225
|
+
const baseDelay = 1000; // 1 second
|
|
18226
|
+
const backoffDelay = baseDelay * Math.pow(2, attempt - 1);
|
|
18227
|
+
const jitterDelay = Math.random() * 500; // Add some randomness
|
|
18228
|
+
const totalDelay = backoffDelay + jitterDelay;
|
|
18229
|
+
if (this.options.isVerbose) {
|
|
18230
|
+
console.info(colors.bgYellow('Retrying request'), `Attempt ${attempt}/${CONNECTION_RETRIES_LIMIT}, waiting ${Math.round(totalDelay)}ms:`, error.message);
|
|
18231
|
+
}
|
|
18232
|
+
// Wait before retrying
|
|
18233
|
+
await new Promise((resolve) => setTimeout(resolve, totalDelay));
|
|
18234
|
+
}
|
|
18235
|
+
}
|
|
18236
|
+
throw lastError;
|
|
18237
|
+
}
|
|
18238
|
+
/**
|
|
18239
|
+
* Determines if an error is retryable (network-related errors)
|
|
18240
|
+
*/
|
|
18241
|
+
isRetryableNetworkError(error) {
|
|
18242
|
+
const errorMessage = error.message.toLowerCase();
|
|
18243
|
+
const errorCode = error.code;
|
|
18244
|
+
// Network connection errors that should be retried
|
|
18245
|
+
const retryableErrors = [
|
|
18246
|
+
'econnreset',
|
|
18247
|
+
'enotfound',
|
|
18248
|
+
'econnrefused',
|
|
18249
|
+
'etimedout',
|
|
18250
|
+
'socket hang up',
|
|
18251
|
+
'network error',
|
|
18252
|
+
'fetch failed',
|
|
18253
|
+
'connection reset',
|
|
18254
|
+
'connection refused',
|
|
18255
|
+
'timeout',
|
|
18256
|
+
];
|
|
18257
|
+
// Check error message
|
|
18258
|
+
if (retryableErrors.some((retryableError) => errorMessage.includes(retryableError))) {
|
|
18259
|
+
return true;
|
|
18260
|
+
}
|
|
18261
|
+
// Check error code
|
|
18262
|
+
if (errorCode && retryableErrors.includes(errorCode.toLowerCase())) {
|
|
18263
|
+
return true;
|
|
18264
|
+
}
|
|
18265
|
+
// Check for specific HTTP status codes that are retryable
|
|
18266
|
+
const errorWithStatus = error;
|
|
18267
|
+
const httpStatus = errorWithStatus.status || errorWithStatus.statusCode;
|
|
18268
|
+
if (httpStatus && [429, 500, 502, 503, 504].includes(httpStatus)) {
|
|
18269
|
+
return true;
|
|
18270
|
+
}
|
|
18271
|
+
return false;
|
|
18272
|
+
}
|
|
17795
18273
|
}
|
|
17796
18274
|
/**
|
|
17797
18275
|
* TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
|
|
@@ -17803,7 +18281,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
17803
18281
|
/**
|
|
17804
18282
|
* List of available models in Ollama library
|
|
17805
18283
|
*
|
|
17806
|
-
* Note:
|
|
18284
|
+
* Note: Synced with official API docs at 2025-08-20
|
|
17807
18285
|
*
|
|
17808
18286
|
* @see https://ollama.com/library
|
|
17809
18287
|
* @public exported from `@promptbook/ollama`
|
|
@@ -17811,6 +18289,24 @@ class OpenAiCompatibleExecutionTools {
|
|
|
17811
18289
|
const OLLAMA_MODELS = exportJson({
|
|
17812
18290
|
name: 'OLLAMA_MODELS',
|
|
17813
18291
|
value: [
|
|
18292
|
+
{
|
|
18293
|
+
modelVariant: 'CHAT',
|
|
18294
|
+
modelTitle: 'llama3.3',
|
|
18295
|
+
modelName: 'llama3.3',
|
|
18296
|
+
modelDescription: 'Meta Llama 3.3 (70B parameters) with 128K context window. Latest generation foundation model with significantly enhanced reasoning, instruction following, and multilingual capabilities. Features improved performance on complex tasks and better factual accuracy compared to Llama 3.1.',
|
|
18297
|
+
},
|
|
18298
|
+
{
|
|
18299
|
+
modelVariant: 'CHAT',
|
|
18300
|
+
modelTitle: 'llama3.2',
|
|
18301
|
+
modelName: 'llama3.2',
|
|
18302
|
+
modelDescription: 'Meta Llama 3.2 (1B-90B parameters) with 128K context window. Enhanced model with improved reasoning capabilities, better instruction following, and multimodal support in larger variants. Features significant performance improvements over Llama 3.1 across diverse tasks.',
|
|
18303
|
+
},
|
|
18304
|
+
{
|
|
18305
|
+
modelVariant: 'CHAT',
|
|
18306
|
+
modelTitle: 'llama3.1',
|
|
18307
|
+
modelName: 'llama3.1',
|
|
18308
|
+
modelDescription: 'Meta Llama 3.1 (8B-405B parameters) with 128K context window. Advanced foundation model with enhanced reasoning, improved multilingual capabilities, and better performance on complex tasks. Features significant improvements in code generation and mathematical reasoning.',
|
|
18309
|
+
},
|
|
17814
18310
|
{
|
|
17815
18311
|
modelVariant: 'CHAT',
|
|
17816
18312
|
modelTitle: 'llama3',
|
|
@@ -18281,6 +18777,9 @@ class OpenAiExecutionTools extends OpenAiCompatibleExecutionTools {
|
|
|
18281
18777
|
get description() {
|
|
18282
18778
|
return 'Use all models provided by OpenAI';
|
|
18283
18779
|
}
|
|
18780
|
+
get profile() {
|
|
18781
|
+
return LLM_PROVIDER_PROFILES.OPENAI;
|
|
18782
|
+
}
|
|
18284
18783
|
/*
|
|
18285
18784
|
Note: Commenting this out to avoid circular dependency
|
|
18286
18785
|
/**
|
|
@@ -18305,7 +18804,7 @@ class OpenAiExecutionTools extends OpenAiCompatibleExecutionTools {
|
|
|
18305
18804
|
* Default model for chat variant.
|
|
18306
18805
|
*/
|
|
18307
18806
|
getDefaultChatModel() {
|
|
18308
|
-
return this.getDefaultModel('gpt-
|
|
18807
|
+
return this.getDefaultModel('gpt-5');
|
|
18309
18808
|
}
|
|
18310
18809
|
/**
|
|
18311
18810
|
* Default model for completion variant.
|
|
@@ -18373,8 +18872,6 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
|
|
|
18373
18872
|
const modelName = modelRequirements.modelName || this.getDefaultChatModel().modelName;
|
|
18374
18873
|
const modelSettings = {
|
|
18375
18874
|
model: modelName,
|
|
18376
|
-
max_tokens: modelRequirements.maxTokens,
|
|
18377
|
-
// <- TODO: [🌾] Make some global max cap for maxTokens
|
|
18378
18875
|
|
|
18379
18876
|
temperature: modelRequirements.temperature,
|
|
18380
18877
|
|
|
@@ -18828,7 +19325,9 @@ class MarkdownScraper {
|
|
|
18828
19325
|
},
|
|
18829
19326
|
});
|
|
18830
19327
|
const knowledgeContent = await source.asText();
|
|
18831
|
-
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise(
|
|
19328
|
+
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
|
|
19329
|
+
isCrashedOnError: true,
|
|
19330
|
+
});
|
|
18832
19331
|
const { outputParameters } = result;
|
|
18833
19332
|
const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
|
|
18834
19333
|
const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
@@ -18852,12 +19351,16 @@ class MarkdownScraper {
|
|
|
18852
19351
|
];
|
|
18853
19352
|
*/
|
|
18854
19353
|
try {
|
|
18855
|
-
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise(
|
|
19354
|
+
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
|
|
19355
|
+
isCrashedOnError: true,
|
|
19356
|
+
});
|
|
18856
19357
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
18857
19358
|
title = spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
18858
19359
|
name = titleToName(title);
|
|
18859
19360
|
// --- Keywords
|
|
18860
|
-
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise(
|
|
19361
|
+
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
19362
|
+
isCrashedOnError: true,
|
|
19363
|
+
});
|
|
18861
19364
|
const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
|
|
18862
19365
|
keywords = (keywordsRaw || '')
|
|
18863
19366
|
.split(',')
|