@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
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.104.0-8`).
18
+ * It follows semantic versioning (e.g., `0.104.0`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/ollama",
3
- "version": "0.104.0-9",
3
+ "version": "0.105.0-0",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -94,7 +94,7 @@
94
94
  "module": "./esm/index.es.js",
95
95
  "typings": "./esm/typings/src/_packages/ollama.index.d.ts",
96
96
  "peerDependencies": {
97
- "@promptbook/core": "0.104.0-9"
97
+ "@promptbook/core": "0.105.0-0"
98
98
  },
99
99
  "dependencies": {
100
100
  "bottleneck": "2.19.5",
package/umd/index.umd.js CHANGED
@@ -25,7 +25,7 @@
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-9';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.105.0-0';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -116,7 +116,7 @@
116
116
  *
117
117
  * @public exported from `@promptbook/core`
118
118
  */
119
- $deepFreeze({
119
+ const ZERO_USAGE = $deepFreeze({
120
120
  price: ZERO_VALUE,
121
121
  input: {
122
122
  tokensCount: ZERO_VALUE,
@@ -1948,8 +1948,8 @@
1948
1948
  */
1949
1949
  function removeDiacritics(input) {
1950
1950
  /*eslint no-control-regex: "off"*/
1951
- return input.replace(/[^\u0000-\u007E]/g, (a) => {
1952
- return DIACRITIC_VARIANTS_LETTERS[a] || a;
1951
+ return input.replace(/[^\u0000-\u007E]/g, (character) => {
1952
+ return DIACRITIC_VARIANTS_LETTERS[character] || character;
1953
1953
  });
1954
1954
  }
1955
1955
  /**
@@ -2865,6 +2865,98 @@
2865
2865
  return replacedTemplates;
2866
2866
  }
2867
2867
 
2868
+ /**
2869
+ * Function `addUsage` will add multiple usages into one
2870
+ *
2871
+ * Note: If you provide 0 values, it returns ZERO_USAGE
2872
+ *
2873
+ * @public exported from `@promptbook/core`
2874
+ */
2875
+ function addUsage(...usageItems) {
2876
+ return usageItems.reduce((acc, item) => {
2877
+ var _a;
2878
+ acc.price.value += ((_a = item.price) === null || _a === void 0 ? void 0 : _a.value) || 0;
2879
+ for (const key of Object.keys(acc.input)) {
2880
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2881
+ //@ts-ignore
2882
+ if (item.input[key]) {
2883
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2884
+ //@ts-ignore
2885
+ acc.input[key].value += item.input[key].value || 0;
2886
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2887
+ //@ts-ignore
2888
+ if (item.input[key].isUncertain) {
2889
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2890
+ //@ts-ignore
2891
+ acc.input[key].isUncertain = true;
2892
+ }
2893
+ }
2894
+ }
2895
+ for (const key of Object.keys(acc.output)) {
2896
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2897
+ //@ts-ignore
2898
+ if (item.output[key]) {
2899
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2900
+ //@ts-ignore
2901
+ acc.output[key].value += item.output[key].value || 0;
2902
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2903
+ //@ts-ignore
2904
+ if (item.output[key].isUncertain) {
2905
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2906
+ //@ts-ignore
2907
+ acc.output[key].isUncertain = true;
2908
+ }
2909
+ }
2910
+ }
2911
+ return acc;
2912
+ }, deepClone(ZERO_USAGE));
2913
+ }
2914
+
2915
+ /**
2916
+ * Async version of Array.forEach
2917
+ *
2918
+ * @param array - Array to iterate over
2919
+ * @param options - Options for the function
2920
+ * @param callbackfunction - Function to call for each item
2921
+ * @public exported from `@promptbook/utils`
2922
+ * @deprecated [🪂] Use queues instead
2923
+ */
2924
+ async function forEachAsync(array, options, callbackfunction) {
2925
+ const { maxParallelCount = Infinity } = options;
2926
+ let index = 0;
2927
+ let runningTasks = [];
2928
+ const tasks = [];
2929
+ for (const item of array) {
2930
+ const currentIndex = index++;
2931
+ const task = callbackfunction(item, currentIndex, array);
2932
+ tasks.push(task);
2933
+ runningTasks.push(task);
2934
+ /* not await */ Promise.resolve(task).then(() => {
2935
+ runningTasks = runningTasks.filter((runningTask) => runningTask !== task);
2936
+ });
2937
+ if (maxParallelCount < runningTasks.length) {
2938
+ await Promise.race(runningTasks);
2939
+ }
2940
+ }
2941
+ await Promise.all(tasks);
2942
+ }
2943
+
2944
+ /**
2945
+ * Maps Promptbook tools to OpenAI tools.
2946
+ *
2947
+ * @private
2948
+ */
2949
+ function mapToolsToOpenAi(tools) {
2950
+ return tools.map((tool) => ({
2951
+ type: 'function',
2952
+ function: {
2953
+ name: tool.name,
2954
+ description: tool.description,
2955
+ parameters: tool.parameters,
2956
+ },
2957
+ }));
2958
+ }
2959
+
2868
2960
  /**
2869
2961
  * Parses an OpenAI error message to identify which parameter is unsupported
2870
2962
  *
@@ -3044,80 +3136,180 @@
3044
3136
  content: msg.content,
3045
3137
  }));
3046
3138
  }
3047
- const rawRequest = {
3048
- ...modelSettings,
3049
- messages: [
3050
- ...(currentModelRequirements.systemMessage === undefined
3051
- ? []
3052
- : [
3053
- {
3054
- role: 'system',
3055
- content: currentModelRequirements.systemMessage,
3056
- },
3057
- ]),
3058
- ...threadMessages,
3059
- {
3060
- role: 'user',
3061
- content: rawPromptContent,
3062
- },
3063
- ],
3064
- user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
3139
+ const messages = [
3140
+ ...(currentModelRequirements.systemMessage === undefined
3141
+ ? []
3142
+ : [
3143
+ {
3144
+ role: 'system',
3145
+ content: currentModelRequirements.systemMessage,
3146
+ },
3147
+ ]),
3148
+ ...threadMessages,
3149
+ {
3150
+ role: 'user',
3151
+ content: rawPromptContent,
3152
+ },
3153
+ ];
3154
+ let totalUsage = {
3155
+ price: uncertainNumber(0),
3156
+ input: {
3157
+ tokensCount: uncertainNumber(0),
3158
+ charactersCount: uncertainNumber(0),
3159
+ wordsCount: uncertainNumber(0),
3160
+ sentencesCount: uncertainNumber(0),
3161
+ linesCount: uncertainNumber(0),
3162
+ paragraphsCount: uncertainNumber(0),
3163
+ pagesCount: uncertainNumber(0),
3164
+ },
3165
+ output: {
3166
+ tokensCount: uncertainNumber(0),
3167
+ charactersCount: uncertainNumber(0),
3168
+ wordsCount: uncertainNumber(0),
3169
+ sentencesCount: uncertainNumber(0),
3170
+ linesCount: uncertainNumber(0),
3171
+ paragraphsCount: uncertainNumber(0),
3172
+ pagesCount: uncertainNumber(0),
3173
+ },
3065
3174
  };
3175
+ const toolCalls = [];
3066
3176
  const start = $getCurrentDate();
3067
- if (this.options.isVerbose) {
3068
- console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
3069
- }
3070
- try {
3071
- const rawResponse = await this.limiter
3072
- .schedule(() => this.makeRequestWithNetworkRetry(() => client.chat.completions.create(rawRequest)))
3073
- .catch((error) => {
3074
- assertsError(error);
3075
- if (this.options.isVerbose) {
3076
- console.info(colors__default["default"].bgRed('error'), error);
3077
- }
3078
- throw error;
3079
- });
3177
+ const tools = 'tools' in prompt && Array.isArray(prompt.tools) ? prompt.tools : currentModelRequirements.tools;
3178
+ let isLooping = true;
3179
+ while (isLooping) {
3180
+ const rawRequest = {
3181
+ ...modelSettings,
3182
+ messages,
3183
+ user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
3184
+ tools: tools === undefined ? undefined : mapToolsToOpenAi(tools),
3185
+ };
3080
3186
  if (this.options.isVerbose) {
3081
- console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
3187
+ console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
3082
3188
  }
3083
- const complete = $getCurrentDate();
3084
- if (!rawResponse.choices[0]) {
3085
- throw new PipelineExecutionError(`No choises from ${this.title}`);
3086
- }
3087
- if (rawResponse.choices.length > 1) {
3088
- // TODO: This should be maybe only warning
3089
- throw new PipelineExecutionError(`More than one choise from ${this.title}`);
3090
- }
3091
- const resultContent = rawResponse.choices[0].message.content;
3092
- const usage = this.computeUsage(content || '', resultContent || '', rawResponse);
3093
- if (resultContent === null) {
3094
- throw new PipelineExecutionError(`No response message from ${this.title}`);
3095
- }
3096
- return exportJson({
3097
- name: 'promptResult',
3098
- message: `Result of \`OpenAiCompatibleExecutionTools.callChatModel\``,
3099
- order: [],
3100
- value: {
3101
- content: resultContent,
3102
- modelName: rawResponse.model || modelName,
3103
- timing: {
3104
- start,
3105
- complete,
3189
+ try {
3190
+ const rawResponse = await this.limiter
3191
+ .schedule(() => this.makeRequestWithNetworkRetry(() => client.chat.completions.create(rawRequest)))
3192
+ .catch((error) => {
3193
+ assertsError(error);
3194
+ if (this.options.isVerbose) {
3195
+ console.info(colors__default["default"].bgRed('error'), error);
3196
+ }
3197
+ throw error;
3198
+ });
3199
+ if (this.options.isVerbose) {
3200
+ console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
3201
+ }
3202
+ if (!rawResponse.choices[0]) {
3203
+ throw new PipelineExecutionError(`No choises from ${this.title}`);
3204
+ }
3205
+ const responseMessage = rawResponse.choices[0].message;
3206
+ messages.push(responseMessage);
3207
+ const usage = this.computeUsage(content || '', responseMessage.content || '', rawResponse);
3208
+ totalUsage = addUsage(totalUsage, usage);
3209
+ if (responseMessage.tool_calls && responseMessage.tool_calls.length > 0) {
3210
+ await forEachAsync(responseMessage.tool_calls, {}, async (toolCall) => {
3211
+ const functionName = toolCall.function.name;
3212
+ const functionArgs = toolCall.function.arguments;
3213
+ const executionTools = this.options
3214
+ .executionTools;
3215
+ if (!executionTools || !executionTools.script) {
3216
+ throw new PipelineExecutionError(`Model requested tool '${functionName}' but no executionTools.script were provided in OpenAiCompatibleExecutionTools options`);
3217
+ }
3218
+ // TODO: [DRY] Use some common tool caller
3219
+ const scriptTools = Array.isArray(executionTools.script)
3220
+ ? executionTools.script
3221
+ : [executionTools.script];
3222
+ let functionResponse;
3223
+ try {
3224
+ const scriptTool = scriptTools[0]; // <- TODO: [🧠] Which script tool to use?
3225
+ functionResponse = await scriptTool.execute({
3226
+ scriptLanguage: 'javascript',
3227
+ script: `
3228
+ const args = ${functionArgs};
3229
+ return await ${functionName}(args);
3230
+ `,
3231
+ parameters: {}, // <- TODO: [🧠] What parameters to pass?
3232
+ });
3233
+ }
3234
+ catch (error) {
3235
+ assertsError(error);
3236
+ functionResponse = `Error: ${error.message}`;
3237
+ }
3238
+ messages.push({
3239
+ role: 'tool',
3240
+ tool_call_id: toolCall.id,
3241
+ content: functionResponse,
3242
+ });
3243
+ toolCalls.push({
3244
+ name: functionName,
3245
+ arguments: functionArgs,
3246
+ result: functionResponse,
3247
+ rawToolCall: toolCall,
3248
+ });
3249
+ });
3250
+ continue;
3251
+ }
3252
+ const complete = $getCurrentDate();
3253
+ const resultContent = responseMessage.content;
3254
+ if (resultContent === null) {
3255
+ throw new PipelineExecutionError(`No response message from ${this.title}`);
3256
+ }
3257
+ isLooping = false;
3258
+ return exportJson({
3259
+ name: 'promptResult',
3260
+ message: `Result of \`OpenAiCompatibleExecutionTools.callChatModel\``,
3261
+ order: [],
3262
+ value: {
3263
+ content: resultContent,
3264
+ modelName: rawResponse.model || modelName,
3265
+ timing: {
3266
+ start,
3267
+ complete,
3268
+ },
3269
+ usage: totalUsage,
3270
+ toolCalls,
3271
+ rawPromptContent,
3272
+ rawRequest,
3273
+ rawResponse,
3106
3274
  },
3107
- usage,
3108
- rawPromptContent,
3109
- rawRequest,
3110
- rawResponse,
3111
- // <- [🗯]
3112
- },
3113
- });
3114
- }
3115
- catch (error) {
3116
- assertsError(error);
3117
- // Check if this is an unsupported parameter error
3118
- if (!isUnsupportedParameterError(error)) {
3119
- // If we have attemptStack, include it in the error message
3120
- if (attemptStack.length > 0) {
3275
+ });
3276
+ }
3277
+ catch (error) {
3278
+ isLooping = false;
3279
+ assertsError(error);
3280
+ // Check if this is an unsupported parameter error
3281
+ if (!isUnsupportedParameterError(error)) {
3282
+ // If we have attemptStack, include it in the error message
3283
+ if (attemptStack.length > 0) {
3284
+ throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
3285
+ attemptStack
3286
+ .map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
3287
+ (a.unsupportedParameter ? `, Stripped: ${a.unsupportedParameter}` : '') +
3288
+ `, Error: ${a.errorMessage}` +
3289
+ (a.stripped ? ' (stripped and retried)' : ''))
3290
+ .join('\n') +
3291
+ `\nFinal error: ${error.message}`);
3292
+ }
3293
+ throw error;
3294
+ }
3295
+ // Parse which parameter is unsupported
3296
+ const unsupportedParameter = parseUnsupportedParameterError(error.message);
3297
+ if (!unsupportedParameter) {
3298
+ if (this.options.isVerbose) {
3299
+ console.warn(colors__default["default"].bgYellow('Warning'), 'Could not parse unsupported parameter from error:', error.message);
3300
+ }
3301
+ throw error;
3302
+ }
3303
+ // Create a unique key for this model + parameter combination to prevent infinite loops
3304
+ const retryKey = `${modelName}-${unsupportedParameter}`;
3305
+ if (retriedUnsupportedParameters.has(retryKey)) {
3306
+ // Already retried this parameter, throw the error with attemptStack
3307
+ attemptStack.push({
3308
+ modelName,
3309
+ unsupportedParameter,
3310
+ errorMessage: error.message,
3311
+ stripped: true,
3312
+ });
3121
3313
  throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
3122
3314
  attemptStack
3123
3315
  .map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
@@ -3127,52 +3319,25 @@
3127
3319
  .join('\n') +
3128
3320
  `\nFinal error: ${error.message}`);
3129
3321
  }
3130
- throw error;
3131
- }
3132
- // Parse which parameter is unsupported
3133
- const unsupportedParameter = parseUnsupportedParameterError(error.message);
3134
- if (!unsupportedParameter) {
3322
+ // Mark this parameter as retried
3323
+ retriedUnsupportedParameters.add(retryKey);
3324
+ // Log warning in verbose mode
3135
3325
  if (this.options.isVerbose) {
3136
- console.warn(colors__default["default"].bgYellow('Warning'), 'Could not parse unsupported parameter from error:', error.message);
3326
+ console.warn(colors__default["default"].bgYellow('Warning'), `Removing unsupported parameter '${unsupportedParameter}' for model '${modelName}' and retrying request`);
3137
3327
  }
3138
- throw error;
3139
- }
3140
- // Create a unique key for this model + parameter combination to prevent infinite loops
3141
- const retryKey = `${modelName}-${unsupportedParameter}`;
3142
- if (retriedUnsupportedParameters.has(retryKey)) {
3143
- // Already retried this parameter, throw the error with attemptStack
3328
+ // Add to attemptStack
3144
3329
  attemptStack.push({
3145
3330
  modelName,
3146
3331
  unsupportedParameter,
3147
3332
  errorMessage: error.message,
3148
3333
  stripped: true,
3149
3334
  });
3150
- throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
3151
- attemptStack
3152
- .map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
3153
- (a.unsupportedParameter ? `, Stripped: ${a.unsupportedParameter}` : '') +
3154
- `, Error: ${a.errorMessage}` +
3155
- (a.stripped ? ' (stripped and retried)' : ''))
3156
- .join('\n') +
3157
- `\nFinal error: ${error.message}`);
3158
- }
3159
- // Mark this parameter as retried
3160
- retriedUnsupportedParameters.add(retryKey);
3161
- // Log warning in verbose mode
3162
- if (this.options.isVerbose) {
3163
- console.warn(colors__default["default"].bgYellow('Warning'), `Removing unsupported parameter '${unsupportedParameter}' for model '${modelName}' and retrying request`);
3335
+ // Remove the unsupported parameter and retry
3336
+ const modifiedModelRequirements = removeUnsupportedModelRequirement(currentModelRequirements, unsupportedParameter);
3337
+ return this.callChatModelWithRetry(prompt, modifiedModelRequirements, attemptStack, retriedUnsupportedParameters);
3164
3338
  }
3165
- // Add to attemptStack
3166
- attemptStack.push({
3167
- modelName,
3168
- unsupportedParameter,
3169
- errorMessage: error.message,
3170
- stripped: true,
3171
- });
3172
- // Remove the unsupported parameter and retry
3173
- const modifiedModelRequirements = removeUnsupportedModelRequirement(currentModelRequirements, unsupportedParameter);
3174
- return this.callChatModelWithRetry(prompt, modifiedModelRequirements, attemptStack, retriedUnsupportedParameters);
3175
3339
  }
3340
+ throw new PipelineExecutionError(`Tool calling loop did not return a result from ${this.title}`);
3176
3341
  }
3177
3342
  /**
3178
3343
  * Calls OpenAI API to use a complete model.
@@ -3206,6 +3371,7 @@
3206
3371
  const rawPromptContent = templateParameters(content, { ...parameters, modelName });
3207
3372
  const rawRequest = {
3208
3373
  ...modelSettings,
3374
+ model: modelName,
3209
3375
  prompt: rawPromptContent,
3210
3376
  user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
3211
3377
  };
@@ -3460,8 +3626,8 @@
3460
3626
  const rawPromptContent = templateParameters(content, { ...parameters, modelName });
3461
3627
  const rawRequest = {
3462
3628
  ...modelSettings,
3463
- size: modelSettings.size || '1024x1024',
3464
3629
  prompt: rawPromptContent,
3630
+ size: modelSettings.size || '1024x1024',
3465
3631
  user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
3466
3632
  response_format: 'url', // TODO: [🧠] Maybe allow b64_json
3467
3633
  };