@promptbook/ollama 0.104.0-9 → 0.105.0-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.
Files changed (66) hide show
  1. package/esm/index.es.js +276 -110
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/components.index.d.ts +0 -6
  4. package/esm/typings/src/_packages/core.index.d.ts +10 -6
  5. package/esm/typings/src/_packages/types.index.d.ts +8 -0
  6. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  7. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +24 -0
  8. package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +16 -2
  9. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.tools.test.d.ts +1 -0
  10. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +1 -1
  11. package/esm/typings/src/book-components/Chat/save/_common/string_chat_format_name.d.ts +1 -1
  12. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +23 -3
  13. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +5 -1
  14. package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +5 -1
  15. package/esm/typings/src/book-components/icons/AboutIcon.d.ts +5 -1
  16. package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +6 -2
  17. package/esm/typings/src/book-components/icons/CameraIcon.d.ts +6 -2
  18. package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +5 -1
  19. package/esm/typings/src/book-components/icons/MenuIcon.d.ts +5 -1
  20. package/esm/typings/src/book-components/icons/SaveIcon.d.ts +6 -2
  21. package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +1 -1
  22. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +9 -7
  23. package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
  24. package/esm/typings/src/commitments/IMPORT/IMPORT.d.ts +34 -0
  25. package/esm/typings/src/commitments/META/META_DESCRIPTION.d.ts +41 -0
  26. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +2 -2
  27. package/esm/typings/src/commitments/_base/BookCommitment.d.ts +1 -1
  28. package/esm/typings/src/commitments/index.d.ts +2 -1
  29. package/esm/typings/src/config.d.ts +14 -1
  30. package/esm/typings/src/errors/utils/deserializeError.d.ts +1 -1
  31. package/esm/typings/src/execution/PromptResult.d.ts +24 -1
  32. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +1 -1
  33. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  34. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
  35. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +1 -1
  36. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +8 -4
  37. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +1 -1
  38. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -1
  39. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +12 -8
  40. package/esm/typings/src/llm-providers/agent/Agent.d.ts +7 -1
  41. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
  42. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionToolsOptions.d.ts +5 -0
  43. package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
  44. package/esm/typings/src/remote-server/ui/ServerApp.d.ts +5 -1
  45. package/esm/typings/src/scrapers/_common/utils/promptbookFetch.test.d.ts +1 -0
  46. package/esm/typings/src/search-engines/SearchEngine.d.ts +9 -0
  47. package/esm/typings/src/search-engines/SearchResult.d.ts +18 -0
  48. package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +15 -0
  49. package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +15 -0
  50. package/esm/typings/src/types/LlmToolDefinition.d.ts +27 -0
  51. package/esm/typings/src/types/ModelRequirements.d.ts +13 -0
  52. package/esm/typings/src/types/Prompt.d.ts +13 -0
  53. package/esm/typings/src/types/typeAliasEmoji.d.ts +2 -2
  54. package/esm/typings/src/utils/misc/parseNumber.d.ts +1 -1
  55. package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +7 -2
  56. package/esm/typings/src/utils/random/$randomItem.d.ts +1 -1
  57. package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
  58. package/esm/typings/src/utils/validators/url/isValidAgentUrl.d.ts +16 -0
  59. package/esm/typings/src/utils/validators/url/isValidAgentUrl.test.d.ts +1 -0
  60. package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
  61. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +4 -3
  62. package/esm/typings/src/version.d.ts +1 -1
  63. package/package.json +2 -2
  64. package/umd/index.umd.js +276 -110
  65. package/umd/index.umd.js.map +1 -1
  66. package/esm/typings/servers.d.ts +0 -50
package/esm/index.es.js CHANGED
@@ -18,7 +18,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
18
18
  * @generated
19
19
  * @see https://github.com/webgptorg/promptbook
20
20
  */
21
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-9';
21
+ const PROMPTBOOK_ENGINE_VERSION = '0.105.0-0';
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
@@ -109,7 +109,7 @@ const UNCERTAIN_ZERO_VALUE = $deepFreeze({ value: 0, isUncertain: true });
109
109
  *
110
110
  * @public exported from `@promptbook/core`
111
111
  */
112
- $deepFreeze({
112
+ const ZERO_USAGE = $deepFreeze({
113
113
  price: ZERO_VALUE,
114
114
  input: {
115
115
  tokensCount: ZERO_VALUE,
@@ -1941,8 +1941,8 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
1941
1941
  */
1942
1942
  function removeDiacritics(input) {
1943
1943
  /*eslint no-control-regex: "off"*/
1944
- return input.replace(/[^\u0000-\u007E]/g, (a) => {
1945
- return DIACRITIC_VARIANTS_LETTERS[a] || a;
1944
+ return input.replace(/[^\u0000-\u007E]/g, (character) => {
1945
+ return DIACRITIC_VARIANTS_LETTERS[character] || character;
1946
1946
  });
1947
1947
  }
1948
1948
  /**
@@ -2858,6 +2858,98 @@ function templateParameters(template, parameters) {
2858
2858
  return replacedTemplates;
2859
2859
  }
2860
2860
 
2861
+ /**
2862
+ * Function `addUsage` will add multiple usages into one
2863
+ *
2864
+ * Note: If you provide 0 values, it returns ZERO_USAGE
2865
+ *
2866
+ * @public exported from `@promptbook/core`
2867
+ */
2868
+ function addUsage(...usageItems) {
2869
+ return usageItems.reduce((acc, item) => {
2870
+ var _a;
2871
+ acc.price.value += ((_a = item.price) === null || _a === void 0 ? void 0 : _a.value) || 0;
2872
+ for (const key of Object.keys(acc.input)) {
2873
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2874
+ //@ts-ignore
2875
+ if (item.input[key]) {
2876
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2877
+ //@ts-ignore
2878
+ acc.input[key].value += item.input[key].value || 0;
2879
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2880
+ //@ts-ignore
2881
+ if (item.input[key].isUncertain) {
2882
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2883
+ //@ts-ignore
2884
+ acc.input[key].isUncertain = true;
2885
+ }
2886
+ }
2887
+ }
2888
+ for (const key of Object.keys(acc.output)) {
2889
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2890
+ //@ts-ignore
2891
+ if (item.output[key]) {
2892
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2893
+ //@ts-ignore
2894
+ acc.output[key].value += item.output[key].value || 0;
2895
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2896
+ //@ts-ignore
2897
+ if (item.output[key].isUncertain) {
2898
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2899
+ //@ts-ignore
2900
+ acc.output[key].isUncertain = true;
2901
+ }
2902
+ }
2903
+ }
2904
+ return acc;
2905
+ }, deepClone(ZERO_USAGE));
2906
+ }
2907
+
2908
+ /**
2909
+ * Async version of Array.forEach
2910
+ *
2911
+ * @param array - Array to iterate over
2912
+ * @param options - Options for the function
2913
+ * @param callbackfunction - Function to call for each item
2914
+ * @public exported from `@promptbook/utils`
2915
+ * @deprecated [🪂] Use queues instead
2916
+ */
2917
+ async function forEachAsync(array, options, callbackfunction) {
2918
+ const { maxParallelCount = Infinity } = options;
2919
+ let index = 0;
2920
+ let runningTasks = [];
2921
+ const tasks = [];
2922
+ for (const item of array) {
2923
+ const currentIndex = index++;
2924
+ const task = callbackfunction(item, currentIndex, array);
2925
+ tasks.push(task);
2926
+ runningTasks.push(task);
2927
+ /* not await */ Promise.resolve(task).then(() => {
2928
+ runningTasks = runningTasks.filter((runningTask) => runningTask !== task);
2929
+ });
2930
+ if (maxParallelCount < runningTasks.length) {
2931
+ await Promise.race(runningTasks);
2932
+ }
2933
+ }
2934
+ await Promise.all(tasks);
2935
+ }
2936
+
2937
+ /**
2938
+ * Maps Promptbook tools to OpenAI tools.
2939
+ *
2940
+ * @private
2941
+ */
2942
+ function mapToolsToOpenAi(tools) {
2943
+ return tools.map((tool) => ({
2944
+ type: 'function',
2945
+ function: {
2946
+ name: tool.name,
2947
+ description: tool.description,
2948
+ parameters: tool.parameters,
2949
+ },
2950
+ }));
2951
+ }
2952
+
2861
2953
  /**
2862
2954
  * Parses an OpenAI error message to identify which parameter is unsupported
2863
2955
  *
@@ -3037,80 +3129,180 @@ class OpenAiCompatibleExecutionTools {
3037
3129
  content: msg.content,
3038
3130
  }));
3039
3131
  }
3040
- const rawRequest = {
3041
- ...modelSettings,
3042
- messages: [
3043
- ...(currentModelRequirements.systemMessage === undefined
3044
- ? []
3045
- : [
3046
- {
3047
- role: 'system',
3048
- content: currentModelRequirements.systemMessage,
3049
- },
3050
- ]),
3051
- ...threadMessages,
3052
- {
3053
- role: 'user',
3054
- content: rawPromptContent,
3055
- },
3056
- ],
3057
- user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
3132
+ const messages = [
3133
+ ...(currentModelRequirements.systemMessage === undefined
3134
+ ? []
3135
+ : [
3136
+ {
3137
+ role: 'system',
3138
+ content: currentModelRequirements.systemMessage,
3139
+ },
3140
+ ]),
3141
+ ...threadMessages,
3142
+ {
3143
+ role: 'user',
3144
+ content: rawPromptContent,
3145
+ },
3146
+ ];
3147
+ let totalUsage = {
3148
+ price: uncertainNumber(0),
3149
+ input: {
3150
+ tokensCount: uncertainNumber(0),
3151
+ charactersCount: uncertainNumber(0),
3152
+ wordsCount: uncertainNumber(0),
3153
+ sentencesCount: uncertainNumber(0),
3154
+ linesCount: uncertainNumber(0),
3155
+ paragraphsCount: uncertainNumber(0),
3156
+ pagesCount: uncertainNumber(0),
3157
+ },
3158
+ output: {
3159
+ tokensCount: uncertainNumber(0),
3160
+ charactersCount: uncertainNumber(0),
3161
+ wordsCount: uncertainNumber(0),
3162
+ sentencesCount: uncertainNumber(0),
3163
+ linesCount: uncertainNumber(0),
3164
+ paragraphsCount: uncertainNumber(0),
3165
+ pagesCount: uncertainNumber(0),
3166
+ },
3058
3167
  };
3168
+ const toolCalls = [];
3059
3169
  const start = $getCurrentDate();
3060
- if (this.options.isVerbose) {
3061
- console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
3062
- }
3063
- try {
3064
- const rawResponse = await this.limiter
3065
- .schedule(() => this.makeRequestWithNetworkRetry(() => client.chat.completions.create(rawRequest)))
3066
- .catch((error) => {
3067
- assertsError(error);
3068
- if (this.options.isVerbose) {
3069
- console.info(colors.bgRed('error'), error);
3070
- }
3071
- throw error;
3072
- });
3170
+ const tools = 'tools' in prompt && Array.isArray(prompt.tools) ? prompt.tools : currentModelRequirements.tools;
3171
+ let isLooping = true;
3172
+ while (isLooping) {
3173
+ const rawRequest = {
3174
+ ...modelSettings,
3175
+ messages,
3176
+ user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
3177
+ tools: tools === undefined ? undefined : mapToolsToOpenAi(tools),
3178
+ };
3073
3179
  if (this.options.isVerbose) {
3074
- console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
3180
+ console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
3075
3181
  }
3076
- const complete = $getCurrentDate();
3077
- if (!rawResponse.choices[0]) {
3078
- throw new PipelineExecutionError(`No choises from ${this.title}`);
3079
- }
3080
- if (rawResponse.choices.length > 1) {
3081
- // TODO: This should be maybe only warning
3082
- throw new PipelineExecutionError(`More than one choise from ${this.title}`);
3083
- }
3084
- const resultContent = rawResponse.choices[0].message.content;
3085
- const usage = this.computeUsage(content || '', resultContent || '', rawResponse);
3086
- if (resultContent === null) {
3087
- throw new PipelineExecutionError(`No response message from ${this.title}`);
3088
- }
3089
- return exportJson({
3090
- name: 'promptResult',
3091
- message: `Result of \`OpenAiCompatibleExecutionTools.callChatModel\``,
3092
- order: [],
3093
- value: {
3094
- content: resultContent,
3095
- modelName: rawResponse.model || modelName,
3096
- timing: {
3097
- start,
3098
- complete,
3182
+ try {
3183
+ const rawResponse = await this.limiter
3184
+ .schedule(() => this.makeRequestWithNetworkRetry(() => client.chat.completions.create(rawRequest)))
3185
+ .catch((error) => {
3186
+ assertsError(error);
3187
+ if (this.options.isVerbose) {
3188
+ console.info(colors.bgRed('error'), error);
3189
+ }
3190
+ throw error;
3191
+ });
3192
+ if (this.options.isVerbose) {
3193
+ console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
3194
+ }
3195
+ if (!rawResponse.choices[0]) {
3196
+ throw new PipelineExecutionError(`No choises from ${this.title}`);
3197
+ }
3198
+ const responseMessage = rawResponse.choices[0].message;
3199
+ messages.push(responseMessage);
3200
+ const usage = this.computeUsage(content || '', responseMessage.content || '', rawResponse);
3201
+ totalUsage = addUsage(totalUsage, usage);
3202
+ if (responseMessage.tool_calls && responseMessage.tool_calls.length > 0) {
3203
+ await forEachAsync(responseMessage.tool_calls, {}, async (toolCall) => {
3204
+ const functionName = toolCall.function.name;
3205
+ const functionArgs = toolCall.function.arguments;
3206
+ const executionTools = this.options
3207
+ .executionTools;
3208
+ if (!executionTools || !executionTools.script) {
3209
+ throw new PipelineExecutionError(`Model requested tool '${functionName}' but no executionTools.script were provided in OpenAiCompatibleExecutionTools options`);
3210
+ }
3211
+ // TODO: [DRY] Use some common tool caller
3212
+ const scriptTools = Array.isArray(executionTools.script)
3213
+ ? executionTools.script
3214
+ : [executionTools.script];
3215
+ let functionResponse;
3216
+ try {
3217
+ const scriptTool = scriptTools[0]; // <- TODO: [🧠] Which script tool to use?
3218
+ functionResponse = await scriptTool.execute({
3219
+ scriptLanguage: 'javascript',
3220
+ script: `
3221
+ const args = ${functionArgs};
3222
+ return await ${functionName}(args);
3223
+ `,
3224
+ parameters: {}, // <- TODO: [🧠] What parameters to pass?
3225
+ });
3226
+ }
3227
+ catch (error) {
3228
+ assertsError(error);
3229
+ functionResponse = `Error: ${error.message}`;
3230
+ }
3231
+ messages.push({
3232
+ role: 'tool',
3233
+ tool_call_id: toolCall.id,
3234
+ content: functionResponse,
3235
+ });
3236
+ toolCalls.push({
3237
+ name: functionName,
3238
+ arguments: functionArgs,
3239
+ result: functionResponse,
3240
+ rawToolCall: toolCall,
3241
+ });
3242
+ });
3243
+ continue;
3244
+ }
3245
+ const complete = $getCurrentDate();
3246
+ const resultContent = responseMessage.content;
3247
+ if (resultContent === null) {
3248
+ throw new PipelineExecutionError(`No response message from ${this.title}`);
3249
+ }
3250
+ isLooping = false;
3251
+ return exportJson({
3252
+ name: 'promptResult',
3253
+ message: `Result of \`OpenAiCompatibleExecutionTools.callChatModel\``,
3254
+ order: [],
3255
+ value: {
3256
+ content: resultContent,
3257
+ modelName: rawResponse.model || modelName,
3258
+ timing: {
3259
+ start,
3260
+ complete,
3261
+ },
3262
+ usage: totalUsage,
3263
+ toolCalls,
3264
+ rawPromptContent,
3265
+ rawRequest,
3266
+ rawResponse,
3099
3267
  },
3100
- usage,
3101
- rawPromptContent,
3102
- rawRequest,
3103
- rawResponse,
3104
- // <- [🗯]
3105
- },
3106
- });
3107
- }
3108
- catch (error) {
3109
- assertsError(error);
3110
- // Check if this is an unsupported parameter error
3111
- if (!isUnsupportedParameterError(error)) {
3112
- // If we have attemptStack, include it in the error message
3113
- if (attemptStack.length > 0) {
3268
+ });
3269
+ }
3270
+ catch (error) {
3271
+ isLooping = false;
3272
+ assertsError(error);
3273
+ // Check if this is an unsupported parameter error
3274
+ if (!isUnsupportedParameterError(error)) {
3275
+ // If we have attemptStack, include it in the error message
3276
+ if (attemptStack.length > 0) {
3277
+ throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
3278
+ attemptStack
3279
+ .map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
3280
+ (a.unsupportedParameter ? `, Stripped: ${a.unsupportedParameter}` : '') +
3281
+ `, Error: ${a.errorMessage}` +
3282
+ (a.stripped ? ' (stripped and retried)' : ''))
3283
+ .join('\n') +
3284
+ `\nFinal error: ${error.message}`);
3285
+ }
3286
+ throw error;
3287
+ }
3288
+ // Parse which parameter is unsupported
3289
+ const unsupportedParameter = parseUnsupportedParameterError(error.message);
3290
+ if (!unsupportedParameter) {
3291
+ if (this.options.isVerbose) {
3292
+ console.warn(colors.bgYellow('Warning'), 'Could not parse unsupported parameter from error:', error.message);
3293
+ }
3294
+ throw error;
3295
+ }
3296
+ // Create a unique key for this model + parameter combination to prevent infinite loops
3297
+ const retryKey = `${modelName}-${unsupportedParameter}`;
3298
+ if (retriedUnsupportedParameters.has(retryKey)) {
3299
+ // Already retried this parameter, throw the error with attemptStack
3300
+ attemptStack.push({
3301
+ modelName,
3302
+ unsupportedParameter,
3303
+ errorMessage: error.message,
3304
+ stripped: true,
3305
+ });
3114
3306
  throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
3115
3307
  attemptStack
3116
3308
  .map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
@@ -3120,52 +3312,25 @@ class OpenAiCompatibleExecutionTools {
3120
3312
  .join('\n') +
3121
3313
  `\nFinal error: ${error.message}`);
3122
3314
  }
3123
- throw error;
3124
- }
3125
- // Parse which parameter is unsupported
3126
- const unsupportedParameter = parseUnsupportedParameterError(error.message);
3127
- if (!unsupportedParameter) {
3315
+ // Mark this parameter as retried
3316
+ retriedUnsupportedParameters.add(retryKey);
3317
+ // Log warning in verbose mode
3128
3318
  if (this.options.isVerbose) {
3129
- console.warn(colors.bgYellow('Warning'), 'Could not parse unsupported parameter from error:', error.message);
3319
+ console.warn(colors.bgYellow('Warning'), `Removing unsupported parameter '${unsupportedParameter}' for model '${modelName}' and retrying request`);
3130
3320
  }
3131
- throw error;
3132
- }
3133
- // Create a unique key for this model + parameter combination to prevent infinite loops
3134
- const retryKey = `${modelName}-${unsupportedParameter}`;
3135
- if (retriedUnsupportedParameters.has(retryKey)) {
3136
- // Already retried this parameter, throw the error with attemptStack
3321
+ // Add to attemptStack
3137
3322
  attemptStack.push({
3138
3323
  modelName,
3139
3324
  unsupportedParameter,
3140
3325
  errorMessage: error.message,
3141
3326
  stripped: true,
3142
3327
  });
3143
- throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
3144
- attemptStack
3145
- .map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
3146
- (a.unsupportedParameter ? `, Stripped: ${a.unsupportedParameter}` : '') +
3147
- `, Error: ${a.errorMessage}` +
3148
- (a.stripped ? ' (stripped and retried)' : ''))
3149
- .join('\n') +
3150
- `\nFinal error: ${error.message}`);
3151
- }
3152
- // Mark this parameter as retried
3153
- retriedUnsupportedParameters.add(retryKey);
3154
- // Log warning in verbose mode
3155
- if (this.options.isVerbose) {
3156
- console.warn(colors.bgYellow('Warning'), `Removing unsupported parameter '${unsupportedParameter}' for model '${modelName}' and retrying request`);
3328
+ // Remove the unsupported parameter and retry
3329
+ const modifiedModelRequirements = removeUnsupportedModelRequirement(currentModelRequirements, unsupportedParameter);
3330
+ return this.callChatModelWithRetry(prompt, modifiedModelRequirements, attemptStack, retriedUnsupportedParameters);
3157
3331
  }
3158
- // Add to attemptStack
3159
- attemptStack.push({
3160
- modelName,
3161
- unsupportedParameter,
3162
- errorMessage: error.message,
3163
- stripped: true,
3164
- });
3165
- // Remove the unsupported parameter and retry
3166
- const modifiedModelRequirements = removeUnsupportedModelRequirement(currentModelRequirements, unsupportedParameter);
3167
- return this.callChatModelWithRetry(prompt, modifiedModelRequirements, attemptStack, retriedUnsupportedParameters);
3168
3332
  }
3333
+ throw new PipelineExecutionError(`Tool calling loop did not return a result from ${this.title}`);
3169
3334
  }
3170
3335
  /**
3171
3336
  * Calls OpenAI API to use a complete model.
@@ -3199,6 +3364,7 @@ class OpenAiCompatibleExecutionTools {
3199
3364
  const rawPromptContent = templateParameters(content, { ...parameters, modelName });
3200
3365
  const rawRequest = {
3201
3366
  ...modelSettings,
3367
+ model: modelName,
3202
3368
  prompt: rawPromptContent,
3203
3369
  user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
3204
3370
  };
@@ -3453,8 +3619,8 @@ class OpenAiCompatibleExecutionTools {
3453
3619
  const rawPromptContent = templateParameters(content, { ...parameters, modelName });
3454
3620
  const rawRequest = {
3455
3621
  ...modelSettings,
3456
- size: modelSettings.size || '1024x1024',
3457
3622
  prompt: rawPromptContent,
3623
+ size: modelSettings.size || '1024x1024',
3458
3624
  user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
3459
3625
  response_format: 'url', // TODO: [🧠] Maybe allow b64_json
3460
3626
  };