@promptbook/ollama 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 +253 -10
- 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 -2
- package/umd/index.umd.js +253 -10
- 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/ollama`
|
|
33
33
|
|
|
34
34
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
@@ -64,8 +64,6 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
64
64
|
|
|
65
65
|
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**!
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
67
|
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!
|
|
70
68
|
|
|
71
69
|
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.
|
|
@@ -191,8 +189,6 @@ Join our growing community of developers and users:
|
|
|
191
189
|
|
|
192
190
|
_A concise, Markdown-based DSL for crafting AI workflows and automations._
|
|
193
191
|
|
|
194
|
-
|
|
195
|
-
|
|
196
192
|
### Introduction
|
|
197
193
|
|
|
198
194
|
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.
|
|
@@ -242,8 +238,6 @@ Personas can have access to different knowledge, tools and actions. They can als
|
|
|
242
238
|
|
|
243
239
|
- [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
|
|
244
240
|
|
|
245
|
-
|
|
246
|
-
|
|
247
241
|
### **3. How:** Knowledge, Instruments and Actions
|
|
248
242
|
|
|
249
243
|
The resources used by the personas are used to do the work.
|
|
@@ -318,6 +312,7 @@ Or you can install them separately:
|
|
|
318
312
|
- **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API
|
|
319
313
|
- **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Useful templates and examples of books which can be used as a starting point
|
|
320
314
|
- **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
|
|
315
|
+
- **[@promptbook/color](https://www.npmjs.com/package/@promptbook/color)** - Color manipulation library
|
|
321
316
|
- ⭐ **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
|
|
322
317
|
- 🐋 **[Docker image](https://hub.docker.com/r/hejny/promptbook/)** - Promptbook server
|
|
323
318
|
|
|
@@ -343,8 +338,6 @@ The following glossary is used to clarify certain concepts:
|
|
|
343
338
|
|
|
344
339
|
_Note: This section is not a complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
345
340
|
|
|
346
|
-
|
|
347
|
-
|
|
348
341
|
### 💯 Core concepts
|
|
349
342
|
|
|
350
343
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
package/esm/index.es.js
CHANGED
|
@@ -18,7 +18,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
18
18
|
* @generated
|
|
19
19
|
* @see https://github.com/webgptorg/promptbook
|
|
20
20
|
*/
|
|
21
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.
|
|
21
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.1';
|
|
22
22
|
/**
|
|
23
23
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
24
24
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -222,6 +222,13 @@ const VALUE_STRINGS = {
|
|
|
222
222
|
* @public exported from `@promptbook/utils`
|
|
223
223
|
*/
|
|
224
224
|
const SMALL_NUMBER = 0.001;
|
|
225
|
+
// <- TODO: [⏳] Standardize timeouts, Make DEFAULT_TIMEOUT_MS as global constant
|
|
226
|
+
/**
|
|
227
|
+
* How many times to retry the connections
|
|
228
|
+
*
|
|
229
|
+
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
230
|
+
*/
|
|
231
|
+
const CONNECTION_RETRIES_LIMIT = 5;
|
|
225
232
|
// <- TODO: [🧜♂️]
|
|
226
233
|
/**
|
|
227
234
|
* Default settings for parsing and generating CSV files in Promptbook.
|
|
@@ -242,6 +249,13 @@ Object.freeze({
|
|
|
242
249
|
* @public exported from `@promptbook/core`
|
|
243
250
|
*/
|
|
244
251
|
const DEFAULT_MAX_REQUESTS_PER_MINUTE = 60;
|
|
252
|
+
/**
|
|
253
|
+
* API request timeout in milliseconds
|
|
254
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
255
|
+
*
|
|
256
|
+
* @public exported from `@promptbook/core`
|
|
257
|
+
*/
|
|
258
|
+
const API_REQUEST_TIMEOUT = parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
245
259
|
/**
|
|
246
260
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
247
261
|
* TODO: [🧠][🧜♂️] Maybe join remoteServerUrl and path into single value
|
|
@@ -1069,7 +1083,7 @@ function pricing(value) {
|
|
|
1069
1083
|
/**
|
|
1070
1084
|
* List of available OpenAI models with pricing
|
|
1071
1085
|
*
|
|
1072
|
-
* Note:
|
|
1086
|
+
* Note: Synced with official API docs at 2025-08-20
|
|
1073
1087
|
*
|
|
1074
1088
|
* @see https://platform.openai.com/docs/models/
|
|
1075
1089
|
* @see https://openai.com/api/pricing/
|
|
@@ -1078,6 +1092,138 @@ function pricing(value) {
|
|
|
1078
1092
|
const OPENAI_MODELS = exportJson({
|
|
1079
1093
|
name: 'OPENAI_MODELS',
|
|
1080
1094
|
value: [
|
|
1095
|
+
/**/
|
|
1096
|
+
{
|
|
1097
|
+
modelVariant: 'CHAT',
|
|
1098
|
+
modelTitle: 'gpt-5',
|
|
1099
|
+
modelName: 'gpt-5',
|
|
1100
|
+
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.",
|
|
1101
|
+
pricing: {
|
|
1102
|
+
prompt: pricing(`$1.25 / 1M tokens`),
|
|
1103
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
1104
|
+
},
|
|
1105
|
+
},
|
|
1106
|
+
/**/
|
|
1107
|
+
/**/
|
|
1108
|
+
{
|
|
1109
|
+
modelVariant: 'CHAT',
|
|
1110
|
+
modelTitle: 'gpt-5-mini',
|
|
1111
|
+
modelName: 'gpt-5-mini',
|
|
1112
|
+
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.",
|
|
1113
|
+
pricing: {
|
|
1114
|
+
prompt: pricing(`$0.25 / 1M tokens`),
|
|
1115
|
+
output: pricing(`$2.00 / 1M tokens`),
|
|
1116
|
+
},
|
|
1117
|
+
},
|
|
1118
|
+
/**/
|
|
1119
|
+
/**/
|
|
1120
|
+
{
|
|
1121
|
+
modelVariant: 'CHAT',
|
|
1122
|
+
modelTitle: 'gpt-5-nano',
|
|
1123
|
+
modelName: 'gpt-5-nano',
|
|
1124
|
+
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.",
|
|
1125
|
+
pricing: {
|
|
1126
|
+
prompt: pricing(`$0.05 / 1M tokens`),
|
|
1127
|
+
output: pricing(`$0.40 / 1M tokens`),
|
|
1128
|
+
},
|
|
1129
|
+
},
|
|
1130
|
+
/**/
|
|
1131
|
+
/**/
|
|
1132
|
+
{
|
|
1133
|
+
modelVariant: 'CHAT',
|
|
1134
|
+
modelTitle: 'gpt-4.1',
|
|
1135
|
+
modelName: 'gpt-4.1',
|
|
1136
|
+
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.",
|
|
1137
|
+
pricing: {
|
|
1138
|
+
prompt: pricing(`$3.00 / 1M tokens`),
|
|
1139
|
+
output: pricing(`$12.00 / 1M tokens`),
|
|
1140
|
+
},
|
|
1141
|
+
},
|
|
1142
|
+
/**/
|
|
1143
|
+
/**/
|
|
1144
|
+
{
|
|
1145
|
+
modelVariant: 'CHAT',
|
|
1146
|
+
modelTitle: 'gpt-4.1-mini',
|
|
1147
|
+
modelName: 'gpt-4.1-mini',
|
|
1148
|
+
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.",
|
|
1149
|
+
pricing: {
|
|
1150
|
+
prompt: pricing(`$0.80 / 1M tokens`),
|
|
1151
|
+
output: pricing(`$3.20 / 1M tokens`),
|
|
1152
|
+
},
|
|
1153
|
+
},
|
|
1154
|
+
/**/
|
|
1155
|
+
/**/
|
|
1156
|
+
{
|
|
1157
|
+
modelVariant: 'CHAT',
|
|
1158
|
+
modelTitle: 'gpt-4.1-nano',
|
|
1159
|
+
modelName: 'gpt-4.1-nano',
|
|
1160
|
+
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.",
|
|
1161
|
+
pricing: {
|
|
1162
|
+
prompt: pricing(`$0.20 / 1M tokens`),
|
|
1163
|
+
output: pricing(`$0.80 / 1M tokens`),
|
|
1164
|
+
},
|
|
1165
|
+
},
|
|
1166
|
+
/**/
|
|
1167
|
+
/**/
|
|
1168
|
+
{
|
|
1169
|
+
modelVariant: 'CHAT',
|
|
1170
|
+
modelTitle: 'o3',
|
|
1171
|
+
modelName: 'o3',
|
|
1172
|
+
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.",
|
|
1173
|
+
pricing: {
|
|
1174
|
+
prompt: pricing(`$15.00 / 1M tokens`),
|
|
1175
|
+
output: pricing(`$60.00 / 1M tokens`),
|
|
1176
|
+
},
|
|
1177
|
+
},
|
|
1178
|
+
/**/
|
|
1179
|
+
/**/
|
|
1180
|
+
{
|
|
1181
|
+
modelVariant: 'CHAT',
|
|
1182
|
+
modelTitle: 'o3-pro',
|
|
1183
|
+
modelName: 'o3-pro',
|
|
1184
|
+
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.",
|
|
1185
|
+
pricing: {
|
|
1186
|
+
prompt: pricing(`$30.00 / 1M tokens`),
|
|
1187
|
+
output: pricing(`$120.00 / 1M tokens`),
|
|
1188
|
+
},
|
|
1189
|
+
},
|
|
1190
|
+
/**/
|
|
1191
|
+
/**/
|
|
1192
|
+
{
|
|
1193
|
+
modelVariant: 'CHAT',
|
|
1194
|
+
modelTitle: 'o4-mini',
|
|
1195
|
+
modelName: 'o4-mini',
|
|
1196
|
+
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.",
|
|
1197
|
+
pricing: {
|
|
1198
|
+
prompt: pricing(`$4.00 / 1M tokens`),
|
|
1199
|
+
output: pricing(`$16.00 / 1M tokens`),
|
|
1200
|
+
},
|
|
1201
|
+
},
|
|
1202
|
+
/**/
|
|
1203
|
+
/**/
|
|
1204
|
+
{
|
|
1205
|
+
modelVariant: 'CHAT',
|
|
1206
|
+
modelTitle: 'o3-deep-research',
|
|
1207
|
+
modelName: 'o3-deep-research',
|
|
1208
|
+
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.",
|
|
1209
|
+
pricing: {
|
|
1210
|
+
prompt: pricing(`$25.00 / 1M tokens`),
|
|
1211
|
+
output: pricing(`$100.00 / 1M tokens`),
|
|
1212
|
+
},
|
|
1213
|
+
},
|
|
1214
|
+
/**/
|
|
1215
|
+
/**/
|
|
1216
|
+
{
|
|
1217
|
+
modelVariant: 'CHAT',
|
|
1218
|
+
modelTitle: 'o4-mini-deep-research',
|
|
1219
|
+
modelName: 'o4-mini-deep-research',
|
|
1220
|
+
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.",
|
|
1221
|
+
pricing: {
|
|
1222
|
+
prompt: pricing(`$12.00 / 1M tokens`),
|
|
1223
|
+
output: pricing(`$48.00 / 1M tokens`),
|
|
1224
|
+
},
|
|
1225
|
+
},
|
|
1226
|
+
/**/
|
|
1081
1227
|
/*/
|
|
1082
1228
|
{
|
|
1083
1229
|
modelTitle: 'dall-e-3',
|
|
@@ -1784,7 +1930,18 @@ class OpenAiCompatibleExecutionTools {
|
|
|
1784
1930
|
const openAiOptions = { ...this.options };
|
|
1785
1931
|
delete openAiOptions.isVerbose;
|
|
1786
1932
|
delete openAiOptions.userId;
|
|
1787
|
-
|
|
1933
|
+
// Enhanced configuration for better ECONNRESET handling
|
|
1934
|
+
const enhancedOptions = {
|
|
1935
|
+
...openAiOptions,
|
|
1936
|
+
timeout: API_REQUEST_TIMEOUT,
|
|
1937
|
+
maxRetries: CONNECTION_RETRIES_LIMIT,
|
|
1938
|
+
defaultHeaders: {
|
|
1939
|
+
Connection: 'keep-alive',
|
|
1940
|
+
'Keep-Alive': 'timeout=30, max=100',
|
|
1941
|
+
...openAiOptions.defaultHeaders,
|
|
1942
|
+
},
|
|
1943
|
+
};
|
|
1944
|
+
this.client = new OpenAI(enhancedOptions);
|
|
1788
1945
|
}
|
|
1789
1946
|
return this.client;
|
|
1790
1947
|
}
|
|
@@ -1837,7 +1994,6 @@ class OpenAiCompatibleExecutionTools {
|
|
|
1837
1994
|
const modelSettings = {
|
|
1838
1995
|
model: modelName,
|
|
1839
1996
|
max_tokens: modelRequirements.maxTokens,
|
|
1840
|
-
// <- TODO: [🌾] Make some global max cap for maxTokens
|
|
1841
1997
|
temperature: modelRequirements.temperature,
|
|
1842
1998
|
// <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
1843
1999
|
// <- Note: [🧆]
|
|
@@ -1873,7 +2029,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
1873
2029
|
console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
1874
2030
|
}
|
|
1875
2031
|
const rawResponse = await this.limiter
|
|
1876
|
-
.schedule(() => client.chat.completions.create(rawRequest))
|
|
2032
|
+
.schedule(() => this.makeRequestWithRetry(() => client.chat.completions.create(rawRequest)))
|
|
1877
2033
|
.catch((error) => {
|
|
1878
2034
|
assertsError(error);
|
|
1879
2035
|
if (this.options.isVerbose) {
|
|
@@ -1933,8 +2089,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
1933
2089
|
const modelName = modelRequirements.modelName || this.getDefaultCompletionModel().modelName;
|
|
1934
2090
|
const modelSettings = {
|
|
1935
2091
|
model: modelName,
|
|
1936
|
-
max_tokens: modelRequirements.maxTokens
|
|
1937
|
-
// <- TODO: [🌾] Make some global max cap for maxTokens
|
|
2092
|
+
max_tokens: modelRequirements.maxTokens,
|
|
1938
2093
|
temperature: modelRequirements.temperature,
|
|
1939
2094
|
// <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
1940
2095
|
// <- Note: [🧆]
|
|
@@ -1950,7 +2105,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
1950
2105
|
console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
1951
2106
|
}
|
|
1952
2107
|
const rawResponse = await this.limiter
|
|
1953
|
-
.schedule(() => client.completions.create(rawRequest))
|
|
2108
|
+
.schedule(() => this.makeRequestWithRetry(() => client.completions.create(rawRequest)))
|
|
1954
2109
|
.catch((error) => {
|
|
1955
2110
|
assertsError(error);
|
|
1956
2111
|
if (this.options.isVerbose) {
|
|
@@ -2014,7 +2169,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
2014
2169
|
console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
2015
2170
|
}
|
|
2016
2171
|
const rawResponse = await this.limiter
|
|
2017
|
-
.schedule(() => client.embeddings.create(rawRequest))
|
|
2172
|
+
.schedule(() => this.makeRequestWithRetry(() => client.embeddings.create(rawRequest)))
|
|
2018
2173
|
.catch((error) => {
|
|
2019
2174
|
assertsError(error);
|
|
2020
2175
|
if (this.options.isVerbose) {
|
|
@@ -2072,6 +2227,76 @@ class OpenAiCompatibleExecutionTools {
|
|
|
2072
2227
|
}
|
|
2073
2228
|
return model;
|
|
2074
2229
|
}
|
|
2230
|
+
// <- Note: [🤖] getDefaultXxxModel
|
|
2231
|
+
/**
|
|
2232
|
+
* Makes a request with retry logic for network errors like ECONNRESET
|
|
2233
|
+
*/
|
|
2234
|
+
async makeRequestWithRetry(requestFn) {
|
|
2235
|
+
let lastError;
|
|
2236
|
+
for (let attempt = 1; attempt <= CONNECTION_RETRIES_LIMIT; attempt++) {
|
|
2237
|
+
try {
|
|
2238
|
+
return await requestFn();
|
|
2239
|
+
}
|
|
2240
|
+
catch (error) {
|
|
2241
|
+
assertsError(error);
|
|
2242
|
+
lastError = error;
|
|
2243
|
+
// Check if this is a retryable network error
|
|
2244
|
+
const isRetryableError = this.isRetryableNetworkError(error);
|
|
2245
|
+
if (!isRetryableError || attempt === CONNECTION_RETRIES_LIMIT) {
|
|
2246
|
+
if (this.options.isVerbose) {
|
|
2247
|
+
console.info(colors.bgRed('Final error after retries'), `Attempt ${attempt}/${CONNECTION_RETRIES_LIMIT}:`, error);
|
|
2248
|
+
}
|
|
2249
|
+
throw error;
|
|
2250
|
+
}
|
|
2251
|
+
// Calculate exponential backoff delay
|
|
2252
|
+
const baseDelay = 1000; // 1 second
|
|
2253
|
+
const backoffDelay = baseDelay * Math.pow(2, attempt - 1);
|
|
2254
|
+
const jitterDelay = Math.random() * 500; // Add some randomness
|
|
2255
|
+
const totalDelay = backoffDelay + jitterDelay;
|
|
2256
|
+
if (this.options.isVerbose) {
|
|
2257
|
+
console.info(colors.bgYellow('Retrying request'), `Attempt ${attempt}/${CONNECTION_RETRIES_LIMIT}, waiting ${Math.round(totalDelay)}ms:`, error.message);
|
|
2258
|
+
}
|
|
2259
|
+
// Wait before retrying
|
|
2260
|
+
await new Promise((resolve) => setTimeout(resolve, totalDelay));
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
throw lastError;
|
|
2264
|
+
}
|
|
2265
|
+
/**
|
|
2266
|
+
* Determines if an error is retryable (network-related errors)
|
|
2267
|
+
*/
|
|
2268
|
+
isRetryableNetworkError(error) {
|
|
2269
|
+
const errorMessage = error.message.toLowerCase();
|
|
2270
|
+
const errorCode = error.code;
|
|
2271
|
+
// Network connection errors that should be retried
|
|
2272
|
+
const retryableErrors = [
|
|
2273
|
+
'econnreset',
|
|
2274
|
+
'enotfound',
|
|
2275
|
+
'econnrefused',
|
|
2276
|
+
'etimedout',
|
|
2277
|
+
'socket hang up',
|
|
2278
|
+
'network error',
|
|
2279
|
+
'fetch failed',
|
|
2280
|
+
'connection reset',
|
|
2281
|
+
'connection refused',
|
|
2282
|
+
'timeout',
|
|
2283
|
+
];
|
|
2284
|
+
// Check error message
|
|
2285
|
+
if (retryableErrors.some((retryableError) => errorMessage.includes(retryableError))) {
|
|
2286
|
+
return true;
|
|
2287
|
+
}
|
|
2288
|
+
// Check error code
|
|
2289
|
+
if (errorCode && retryableErrors.includes(errorCode.toLowerCase())) {
|
|
2290
|
+
return true;
|
|
2291
|
+
}
|
|
2292
|
+
// Check for specific HTTP status codes that are retryable
|
|
2293
|
+
const errorWithStatus = error;
|
|
2294
|
+
const httpStatus = errorWithStatus.status || errorWithStatus.statusCode;
|
|
2295
|
+
if (httpStatus && [429, 500, 502, 503, 504].includes(httpStatus)) {
|
|
2296
|
+
return true;
|
|
2297
|
+
}
|
|
2298
|
+
return false;
|
|
2299
|
+
}
|
|
2075
2300
|
}
|
|
2076
2301
|
/**
|
|
2077
2302
|
* TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
|
|
@@ -2083,7 +2308,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
2083
2308
|
/**
|
|
2084
2309
|
* List of available models in Ollama library
|
|
2085
2310
|
*
|
|
2086
|
-
* Note:
|
|
2311
|
+
* Note: Synced with official API docs at 2025-08-20
|
|
2087
2312
|
*
|
|
2088
2313
|
* @see https://ollama.com/library
|
|
2089
2314
|
* @public exported from `@promptbook/ollama`
|
|
@@ -2091,6 +2316,24 @@ class OpenAiCompatibleExecutionTools {
|
|
|
2091
2316
|
const OLLAMA_MODELS = exportJson({
|
|
2092
2317
|
name: 'OLLAMA_MODELS',
|
|
2093
2318
|
value: [
|
|
2319
|
+
{
|
|
2320
|
+
modelVariant: 'CHAT',
|
|
2321
|
+
modelTitle: 'llama3.3',
|
|
2322
|
+
modelName: 'llama3.3',
|
|
2323
|
+
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.',
|
|
2324
|
+
},
|
|
2325
|
+
{
|
|
2326
|
+
modelVariant: 'CHAT',
|
|
2327
|
+
modelTitle: 'llama3.2',
|
|
2328
|
+
modelName: 'llama3.2',
|
|
2329
|
+
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.',
|
|
2330
|
+
},
|
|
2331
|
+
{
|
|
2332
|
+
modelVariant: 'CHAT',
|
|
2333
|
+
modelTitle: 'llama3.1',
|
|
2334
|
+
modelName: 'llama3.1',
|
|
2335
|
+
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.',
|
|
2336
|
+
},
|
|
2094
2337
|
{
|
|
2095
2338
|
modelVariant: 'CHAT',
|
|
2096
2339
|
modelTitle: 'llama3',
|