@promptbook/ollama 0.102.0-5 → 0.102.0-7

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.
Files changed (98) hide show
  1. package/esm/index.es.js +121 -56
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/books/index.d.ts +81 -0
  4. package/esm/typings/src/_packages/components.index.d.ts +2 -0
  5. package/esm/typings/src/_packages/markdown-utils.index.d.ts +4 -0
  6. package/esm/typings/src/_packages/types.index.d.ts +8 -6
  7. package/esm/typings/src/_packages/utils.index.d.ts +12 -14
  8. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +1 -1
  9. package/esm/typings/src/book-2.0/utils/generateGravatarUrl.d.ts +1 -1
  10. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +1 -1
  11. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +1 -1
  12. package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +1 -1
  13. package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +1 -5
  14. package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +27 -0
  15. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +13 -6
  16. package/esm/typings/src/book-components/Chat/Chat/constants.d.ts +7 -0
  17. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +1 -1
  18. package/esm/typings/src/book-components/Chat/MockedChat/MockedChat.d.ts +1 -1
  19. package/esm/typings/src/book-components/Chat/MockedChat/constants.d.ts +1 -1
  20. package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
  21. package/esm/typings/src/book-components/Chat/save/_common/getChatSaveFormatDefinitions.d.ts +2 -2
  22. package/esm/typings/src/book-components/Chat/save/_common/string_chat_format_name.d.ts +1 -1
  23. package/esm/typings/src/execution/LlmExecutionToolsConstructor.d.ts +1 -1
  24. package/esm/typings/src/execution/execution-report/countWorkingDuration.d.ts +1 -1
  25. package/esm/typings/src/llm-providers/_common/register/$llmToolsMetadataRegister.d.ts +1 -1
  26. package/esm/typings/src/llm-providers/_common/register/$llmToolsRegister.d.ts +1 -1
  27. package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +1 -2
  28. package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +1 -1
  29. package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
  30. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -1
  31. package/esm/typings/src/llm-providers/agent/register-configuration.d.ts +1 -1
  32. package/esm/typings/src/llm-providers/agent/register-constructor.d.ts +1 -1
  33. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -1
  34. package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +1 -1
  35. package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +1 -1
  36. package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -1
  37. package/esm/typings/src/llm-providers/deepseek/register-configuration.d.ts +1 -1
  38. package/esm/typings/src/llm-providers/deepseek/register-constructor.d.ts +1 -1
  39. package/esm/typings/src/llm-providers/google/register-configuration.d.ts +1 -1
  40. package/esm/typings/src/llm-providers/google/register-constructor.d.ts +1 -1
  41. package/esm/typings/src/llm-providers/ollama/register-configuration.d.ts +1 -1
  42. package/esm/typings/src/llm-providers/ollama/register-constructor.d.ts +1 -1
  43. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +1 -3
  44. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +0 -4
  45. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +1 -1
  46. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +1 -1
  47. package/esm/typings/src/scrapers/_boilerplate/register-constructor.d.ts +1 -1
  48. package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -1
  49. package/esm/typings/src/scrapers/_common/register/$scrapersMetadataRegister.d.ts +1 -1
  50. package/esm/typings/src/scrapers/_common/register/$scrapersRegister.d.ts +1 -1
  51. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +2 -4
  52. package/esm/typings/src/scrapers/_common/register/ScraperConstructor.d.ts +1 -1
  53. package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -1
  54. package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -1
  55. package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -1
  56. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -1
  57. package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -1
  58. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -1
  59. package/esm/typings/src/scrapers/markitdown/register-constructor.d.ts +1 -1
  60. package/esm/typings/src/scrapers/markitdown/register-metadata.d.ts +1 -1
  61. package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -1
  62. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -1
  63. package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -1
  64. package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -1
  65. package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +6 -6
  66. package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +1 -1
  67. package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +1 -1
  68. package/esm/typings/src/utils/markdown/humanizeAiTextEllipsis.d.ts +1 -1
  69. package/esm/typings/src/utils/markdown/humanizeAiTextEmdashed.d.ts +1 -1
  70. package/esm/typings/src/utils/markdown/humanizeAiTextQuotes.d.ts +1 -1
  71. package/esm/typings/src/utils/markdown/humanizeAiTextWhitespace.d.ts +1 -1
  72. package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +1 -1
  73. package/esm/typings/src/utils/{trimCodeBlock.d.ts → markdown/trimCodeBlock.d.ts} +1 -1
  74. package/esm/typings/src/utils/{trimEndOfCodeBlock.d.ts → markdown/trimEndOfCodeBlock.d.ts} +1 -1
  75. package/esm/typings/src/utils/{$Register.d.ts → misc/$Register.d.ts} +2 -2
  76. package/esm/typings/src/utils/{$getCurrentDate.d.ts → misc/$getCurrentDate.d.ts} +1 -1
  77. package/esm/typings/src/utils/{arrayableToArray.d.ts → misc/arrayableToArray.d.ts} +1 -1
  78. package/esm/typings/src/utils/misc/debounce.d.ts +5 -0
  79. package/esm/typings/src/utils/{emojis.d.ts → misc/emojis.d.ts} +1 -1
  80. package/esm/typings/src/utils/misc/injectCssModuleIntoShadowRoot.d.ts +20 -0
  81. package/esm/typings/src/version.d.ts +1 -1
  82. package/package.json +2 -2
  83. package/umd/index.umd.js +121 -56
  84. package/umd/index.umd.js.map +1 -1
  85. package/esm/typings/src/book-components/BookEditor/injectCssModuleIntoShadowRoot.d.ts +0 -11
  86. package/esm/typings/src/book-components/BookEditor/utils.d.ts +0 -8
  87. /package/esm/typings/src/utils/{trimCodeBlock.test.d.ts → markdown/trimCodeBlock.test.d.ts} +0 -0
  88. /package/esm/typings/src/utils/{trimEndOfCodeBlock.test.d.ts → markdown/trimEndOfCodeBlock.test.d.ts} +0 -0
  89. /package/esm/typings/src/utils/{FromtoItems.d.ts → misc/FromtoItems.d.ts} +0 -0
  90. /package/esm/typings/src/utils/{arrayableToArray.test.d.ts → misc/arrayableToArray.test.d.ts} +0 -0
  91. /package/esm/typings/src/utils/{parseNumber.d.ts → misc/parseNumber.d.ts} +0 -0
  92. /package/esm/typings/src/utils/{parseNumber.test.d.ts → misc/parseNumber.test.d.ts} +0 -0
  93. /package/esm/typings/src/utils/{removeEmojis.d.ts → normalization/removeEmojis.d.ts} +0 -0
  94. /package/esm/typings/src/utils/{removeEmojis.test.d.ts → normalization/removeEmojis.test.d.ts} +0 -0
  95. /package/esm/typings/src/utils/{removeQuotes.d.ts → normalization/removeQuotes.d.ts} +0 -0
  96. /package/esm/typings/src/utils/{removeQuotes.test.d.ts → normalization/removeQuotes.test.d.ts} +0 -0
  97. /package/esm/typings/src/utils/{unwrapResult.d.ts → normalization/unwrapResult.d.ts} +0 -0
  98. /package/esm/typings/src/utils/{unwrapResult.test.d.ts → normalization/unwrapResult.test.d.ts} +0 -0
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.102.0-5';
21
+ const PROMPTBOOK_ENGINE_VERSION = '0.102.0-7';
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
@@ -1974,6 +1974,7 @@ function isUnsupportedParameterError(error) {
1974
1974
  * @public exported from `@promptbook/openai`
1975
1975
  */
1976
1976
  class OpenAiCompatibleExecutionTools {
1977
+ // Removed retriedUnsupportedParameters and attemptHistory instance fields
1977
1978
  /**
1978
1979
  * Creates OpenAI compatible Execution Tools.
1979
1980
  *
@@ -1985,10 +1986,6 @@ class OpenAiCompatibleExecutionTools {
1985
1986
  * OpenAI API client.
1986
1987
  */
1987
1988
  this.client = null;
1988
- /**
1989
- * Tracks models and parameters that have already been retried to prevent infinite loops
1990
- */
1991
- this.retriedUnsupportedParameters = new Set();
1992
1989
  // TODO: Allow configuring rate limits via options
1993
1990
  this.limiter = new Bottleneck({
1994
1991
  minTime: 60000 / (this.options.maxRequestsPerMinute || DEFAULT_MAX_REQUESTS_PER_MINUTE),
@@ -2050,12 +2047,16 @@ class OpenAiCompatibleExecutionTools {
2050
2047
  * Calls OpenAI compatible API to use a chat model.
2051
2048
  */
2052
2049
  async callChatModel(prompt) {
2053
- return this.callChatModelWithRetry(prompt, prompt.modelRequirements);
2050
+ // Deep clone prompt and modelRequirements to avoid mutation across calls
2051
+ const clonedPrompt = JSON.parse(JSON.stringify(prompt));
2052
+ // Use local Set for retried parameters to ensure independence and thread safety
2053
+ const retriedUnsupportedParameters = new Set();
2054
+ return this.callChatModelWithRetry(clonedPrompt, clonedPrompt.modelRequirements, [], retriedUnsupportedParameters);
2054
2055
  }
2055
2056
  /**
2056
2057
  * Internal method that handles parameter retry for chat model calls
2057
2058
  */
2058
- async callChatModelWithRetry(prompt, currentModelRequirements) {
2059
+ async callChatModelWithRetry(prompt, currentModelRequirements, attemptStack = [], retriedUnsupportedParameters = new Set()) {
2059
2060
  var _a;
2060
2061
  if (this.options.isVerbose) {
2061
2062
  console.info(`💬 ${this.title} callChatModel call`, { prompt, currentModelRequirements });
@@ -2162,6 +2163,17 @@ class OpenAiCompatibleExecutionTools {
2162
2163
  assertsError(error);
2163
2164
  // Check if this is an unsupported parameter error
2164
2165
  if (!isUnsupportedParameterError(error)) {
2166
+ // If we have attemptStack, include it in the error message
2167
+ if (attemptStack.length > 0) {
2168
+ throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
2169
+ attemptStack
2170
+ .map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
2171
+ (a.unsupportedParameter ? `, Stripped: ${a.unsupportedParameter}` : '') +
2172
+ `, Error: ${a.errorMessage}` +
2173
+ (a.stripped ? ' (stripped and retried)' : ''))
2174
+ .join('\n') +
2175
+ `\nFinal error: ${error.message}`);
2176
+ }
2165
2177
  throw error;
2166
2178
  }
2167
2179
  // Parse which parameter is unsupported
@@ -2174,34 +2186,54 @@ class OpenAiCompatibleExecutionTools {
2174
2186
  }
2175
2187
  // Create a unique key for this model + parameter combination to prevent infinite loops
2176
2188
  const retryKey = `${modelName}-${unsupportedParameter}`;
2177
- if (this.retriedUnsupportedParameters.has(retryKey)) {
2178
- // Already retried this parameter, throw the error
2179
- if (this.options.isVerbose) {
2180
- console.warn(colors.bgRed('Error'), `Parameter '${unsupportedParameter}' for model '${modelName}' already retried once, throwing error:`, error.message);
2181
- }
2182
- throw error;
2189
+ if (retriedUnsupportedParameters.has(retryKey)) {
2190
+ // Already retried this parameter, throw the error with attemptStack
2191
+ attemptStack.push({
2192
+ modelName,
2193
+ unsupportedParameter,
2194
+ errorMessage: error.message,
2195
+ stripped: true,
2196
+ });
2197
+ throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
2198
+ attemptStack
2199
+ .map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
2200
+ (a.unsupportedParameter ? `, Stripped: ${a.unsupportedParameter}` : '') +
2201
+ `, Error: ${a.errorMessage}` +
2202
+ (a.stripped ? ' (stripped and retried)' : ''))
2203
+ .join('\n') +
2204
+ `\nFinal error: ${error.message}`);
2183
2205
  }
2184
2206
  // Mark this parameter as retried
2185
- this.retriedUnsupportedParameters.add(retryKey);
2207
+ retriedUnsupportedParameters.add(retryKey);
2186
2208
  // Log warning in verbose mode
2187
2209
  if (this.options.isVerbose) {
2188
2210
  console.warn(colors.bgYellow('Warning'), `Removing unsupported parameter '${unsupportedParameter}' for model '${modelName}' and retrying request`);
2189
2211
  }
2212
+ // Add to attemptStack
2213
+ attemptStack.push({
2214
+ modelName,
2215
+ unsupportedParameter,
2216
+ errorMessage: error.message,
2217
+ stripped: true,
2218
+ });
2190
2219
  // Remove the unsupported parameter and retry
2191
2220
  const modifiedModelRequirements = removeUnsupportedModelRequirement(currentModelRequirements, unsupportedParameter);
2192
- return this.callChatModelWithRetry(prompt, modifiedModelRequirements);
2221
+ return this.callChatModelWithRetry(prompt, modifiedModelRequirements, attemptStack, retriedUnsupportedParameters);
2193
2222
  }
2194
2223
  }
2195
2224
  /**
2196
2225
  * Calls OpenAI API to use a complete model.
2197
2226
  */
2198
2227
  async callCompletionModel(prompt) {
2199
- return this.callCompletionModelWithRetry(prompt, prompt.modelRequirements);
2228
+ // Deep clone prompt and modelRequirements to avoid mutation across calls
2229
+ const clonedPrompt = JSON.parse(JSON.stringify(prompt));
2230
+ const retriedUnsupportedParameters = new Set();
2231
+ return this.callCompletionModelWithRetry(clonedPrompt, clonedPrompt.modelRequirements, [], retriedUnsupportedParameters);
2200
2232
  }
2201
2233
  /**
2202
2234
  * Internal method that handles parameter retry for completion model calls
2203
2235
  */
2204
- async callCompletionModelWithRetry(prompt, currentModelRequirements) {
2236
+ async callCompletionModelWithRetry(prompt, currentModelRequirements, attemptStack = [], retriedUnsupportedParameters = new Set()) {
2205
2237
  var _a;
2206
2238
  if (this.options.isVerbose) {
2207
2239
  console.info(`🖋 ${this.title} callCompletionModel call`, { prompt, currentModelRequirements });
@@ -2217,8 +2249,6 @@ class OpenAiCompatibleExecutionTools {
2217
2249
  model: modelName,
2218
2250
  max_tokens: currentModelRequirements.maxTokens,
2219
2251
  temperature: currentModelRequirements.temperature,
2220
- // <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
2221
- // <- Note: [🧆]
2222
2252
  };
2223
2253
  const rawPromptContent = templateParameters(content, { ...parameters, modelName });
2224
2254
  const rawRequest = {
@@ -2248,7 +2278,6 @@ class OpenAiCompatibleExecutionTools {
2248
2278
  throw new PipelineExecutionError(`No choises from ${this.title}`);
2249
2279
  }
2250
2280
  if (rawResponse.choices.length > 1) {
2251
- // TODO: This should be maybe only warning
2252
2281
  throw new PipelineExecutionError(`More than one choise from ${this.title}`);
2253
2282
  }
2254
2283
  const resultContent = rawResponse.choices[0].text;
@@ -2268,17 +2297,24 @@ class OpenAiCompatibleExecutionTools {
2268
2297
  rawPromptContent,
2269
2298
  rawRequest,
2270
2299
  rawResponse,
2271
- // <- [🗯]
2272
2300
  },
2273
2301
  });
2274
2302
  }
2275
2303
  catch (error) {
2276
2304
  assertsError(error);
2277
- // Check if this is an unsupported parameter error
2278
2305
  if (!isUnsupportedParameterError(error)) {
2306
+ if (attemptStack.length > 0) {
2307
+ throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
2308
+ attemptStack
2309
+ .map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
2310
+ (a.unsupportedParameter ? `, Stripped: ${a.unsupportedParameter}` : '') +
2311
+ `, Error: ${a.errorMessage}` +
2312
+ (a.stripped ? ' (stripped and retried)' : ''))
2313
+ .join('\n') +
2314
+ `\nFinal error: ${error.message}`);
2315
+ }
2279
2316
  throw error;
2280
2317
  }
2281
- // Parse which parameter is unsupported
2282
2318
  const unsupportedParameter = parseUnsupportedParameterError(error.message);
2283
2319
  if (!unsupportedParameter) {
2284
2320
  if (this.options.isVerbose) {
@@ -2286,42 +2322,55 @@ class OpenAiCompatibleExecutionTools {
2286
2322
  }
2287
2323
  throw error;
2288
2324
  }
2289
- // Create a unique key for this model + parameter combination to prevent infinite loops
2290
2325
  const retryKey = `${modelName}-${unsupportedParameter}`;
2291
- if (this.retriedUnsupportedParameters.has(retryKey)) {
2292
- // Already retried this parameter, throw the error
2293
- if (this.options.isVerbose) {
2294
- console.warn(colors.bgRed('Error'), `Parameter '${unsupportedParameter}' for model '${modelName}' already retried once, throwing error:`, error.message);
2295
- }
2296
- throw error;
2326
+ if (retriedUnsupportedParameters.has(retryKey)) {
2327
+ attemptStack.push({
2328
+ modelName,
2329
+ unsupportedParameter,
2330
+ errorMessage: error.message,
2331
+ stripped: true,
2332
+ });
2333
+ throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
2334
+ attemptStack
2335
+ .map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
2336
+ (a.unsupportedParameter ? `, Stripped: ${a.unsupportedParameter}` : '') +
2337
+ `, Error: ${a.errorMessage}` +
2338
+ (a.stripped ? ' (stripped and retried)' : ''))
2339
+ .join('\n') +
2340
+ `\nFinal error: ${error.message}`);
2297
2341
  }
2298
- // Mark this parameter as retried
2299
- this.retriedUnsupportedParameters.add(retryKey);
2300
- // Log warning in verbose mode
2342
+ retriedUnsupportedParameters.add(retryKey);
2301
2343
  if (this.options.isVerbose) {
2302
2344
  console.warn(colors.bgYellow('Warning'), `Removing unsupported parameter '${unsupportedParameter}' for model '${modelName}' and retrying request`);
2303
2345
  }
2304
- // Remove the unsupported parameter and retry
2346
+ attemptStack.push({
2347
+ modelName,
2348
+ unsupportedParameter,
2349
+ errorMessage: error.message,
2350
+ stripped: true,
2351
+ });
2305
2352
  const modifiedModelRequirements = removeUnsupportedModelRequirement(currentModelRequirements, unsupportedParameter);
2306
- return this.callCompletionModelWithRetry(prompt, modifiedModelRequirements);
2353
+ return this.callCompletionModelWithRetry(prompt, modifiedModelRequirements, attemptStack, retriedUnsupportedParameters);
2307
2354
  }
2308
2355
  }
2309
2356
  /**
2310
2357
  * Calls OpenAI compatible API to use a embedding model
2311
2358
  */
2312
2359
  async callEmbeddingModel(prompt) {
2313
- return this.callEmbeddingModelWithRetry(prompt, prompt.modelRequirements);
2360
+ // Deep clone prompt and modelRequirements to avoid mutation across calls
2361
+ const clonedPrompt = JSON.parse(JSON.stringify(prompt));
2362
+ const retriedUnsupportedParameters = new Set();
2363
+ return this.callEmbeddingModelWithRetry(clonedPrompt, clonedPrompt.modelRequirements, [], retriedUnsupportedParameters);
2314
2364
  }
2315
2365
  /**
2316
2366
  * Internal method that handles parameter retry for embedding model calls
2317
2367
  */
2318
- async callEmbeddingModelWithRetry(prompt, currentModelRequirements) {
2368
+ async callEmbeddingModelWithRetry(prompt, currentModelRequirements, attemptStack = [], retriedUnsupportedParameters = new Set()) {
2319
2369
  if (this.options.isVerbose) {
2320
2370
  console.info(`🖋 ${this.title} embedding call`, { prompt, currentModelRequirements });
2321
2371
  }
2322
2372
  const { content, parameters } = prompt;
2323
2373
  const client = await this.getClient();
2324
- // TODO: [☂] Use here more modelRequirements
2325
2374
  if (currentModelRequirements.modelVariant !== 'EMBEDDING') {
2326
2375
  throw new PipelineExecutionError('Use embed only for EMBEDDING variant');
2327
2376
  }
@@ -2353,9 +2402,7 @@ class OpenAiCompatibleExecutionTools {
2353
2402
  throw new PipelineExecutionError(`Expected exactly 1 data item in response, got ${rawResponse.data.length}`);
2354
2403
  }
2355
2404
  const resultContent = rawResponse.data[0].embedding;
2356
- const usage = this.computeUsage(content || '', '',
2357
- // <- Note: Embedding does not have result content
2358
- rawResponse);
2405
+ const usage = this.computeUsage(content || '', '', rawResponse);
2359
2406
  return exportJson({
2360
2407
  name: 'promptResult',
2361
2408
  message: `Result of \`OpenAiCompatibleExecutionTools.callEmbeddingModel\``,
@@ -2371,17 +2418,24 @@ class OpenAiCompatibleExecutionTools {
2371
2418
  rawPromptContent,
2372
2419
  rawRequest,
2373
2420
  rawResponse,
2374
- // <- [🗯]
2375
2421
  },
2376
2422
  });
2377
2423
  }
2378
2424
  catch (error) {
2379
2425
  assertsError(error);
2380
- // Check if this is an unsupported parameter error
2381
2426
  if (!isUnsupportedParameterError(error)) {
2427
+ if (attemptStack.length > 0) {
2428
+ throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
2429
+ attemptStack
2430
+ .map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
2431
+ (a.unsupportedParameter ? `, Stripped: ${a.unsupportedParameter}` : '') +
2432
+ `, Error: ${a.errorMessage}` +
2433
+ (a.stripped ? ' (stripped and retried)' : ''))
2434
+ .join('\n') +
2435
+ `\nFinal error: ${error.message}`);
2436
+ }
2382
2437
  throw error;
2383
2438
  }
2384
- // Parse which parameter is unsupported
2385
2439
  const unsupportedParameter = parseUnsupportedParameterError(error.message);
2386
2440
  if (!unsupportedParameter) {
2387
2441
  if (this.options.isVerbose) {
@@ -2389,24 +2443,35 @@ class OpenAiCompatibleExecutionTools {
2389
2443
  }
2390
2444
  throw error;
2391
2445
  }
2392
- // Create a unique key for this model + parameter combination to prevent infinite loops
2393
2446
  const retryKey = `${modelName}-${unsupportedParameter}`;
2394
- if (this.retriedUnsupportedParameters.has(retryKey)) {
2395
- // Already retried this parameter, throw the error
2396
- if (this.options.isVerbose) {
2397
- console.warn(colors.bgRed('Error'), `Parameter '${unsupportedParameter}' for model '${modelName}' already retried once, throwing error:`, error.message);
2398
- }
2399
- throw error;
2447
+ if (retriedUnsupportedParameters.has(retryKey)) {
2448
+ attemptStack.push({
2449
+ modelName,
2450
+ unsupportedParameter,
2451
+ errorMessage: error.message,
2452
+ stripped: true,
2453
+ });
2454
+ throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
2455
+ attemptStack
2456
+ .map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
2457
+ (a.unsupportedParameter ? `, Stripped: ${a.unsupportedParameter}` : '') +
2458
+ `, Error: ${a.errorMessage}` +
2459
+ (a.stripped ? ' (stripped and retried)' : ''))
2460
+ .join('\n') +
2461
+ `\nFinal error: ${error.message}`);
2400
2462
  }
2401
- // Mark this parameter as retried
2402
- this.retriedUnsupportedParameters.add(retryKey);
2403
- // Log warning in verbose mode
2463
+ retriedUnsupportedParameters.add(retryKey);
2404
2464
  if (this.options.isVerbose) {
2405
2465
  console.warn(colors.bgYellow('Warning'), `Removing unsupported parameter '${unsupportedParameter}' for model '${modelName}' and retrying request`);
2406
2466
  }
2407
- // Remove the unsupported parameter and retry
2467
+ attemptStack.push({
2468
+ modelName,
2469
+ unsupportedParameter,
2470
+ errorMessage: error.message,
2471
+ stripped: true,
2472
+ });
2408
2473
  const modifiedModelRequirements = removeUnsupportedModelRequirement(currentModelRequirements, unsupportedParameter);
2409
- return this.callEmbeddingModelWithRetry(prompt, modifiedModelRequirements);
2474
+ return this.callEmbeddingModelWithRetry(prompt, modifiedModelRequirements, attemptStack, retriedUnsupportedParameters);
2410
2475
  }
2411
2476
  }
2412
2477
  // <- Note: [🤖] callXxxModel