@contentgrowth/llm-service 1.3.2 → 1.3.3

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/dist/index.cjs CHANGED
@@ -1012,13 +1012,21 @@ ${msg.content}`;
1012
1012
  const tool = toolImplementations[toolName];
1013
1013
  const tool_call_id = `gemini-tool-call-${index}`;
1014
1014
  toolCall.id = tool_call_id;
1015
- console.log(`[Tool Call] > ${toolName}:`, JSON.stringify(toolCall.function.args));
1015
+ let toolArgs = toolCall.function.args;
1016
+ if (toolArgs === void 0 && toolCall.function.arguments) {
1017
+ try {
1018
+ toolArgs = typeof toolCall.function.arguments === "string" ? JSON.parse(toolCall.function.arguments) : toolCall.function.arguments;
1019
+ } catch (e) {
1020
+ toolArgs = {};
1021
+ }
1022
+ }
1023
+ console.log(`[Tool Call] > ${toolName}:`, JSON.stringify(toolArgs));
1016
1024
  if (!tool) {
1017
1025
  console.error(`[Tool Error] Tool '${toolName}' not found`);
1018
1026
  return { tool_call_id, output: JSON.stringify({ error: `Tool '${toolName}' not found.` }) };
1019
1027
  }
1020
1028
  try {
1021
- const output = await tool(toolCall.function.args, { env, tenantId });
1029
+ const output = await tool(toolArgs, { env, tenantId });
1022
1030
  const preview = typeof output === "string" ? output.length > 200 ? output.substring(0, 200) + "..." : output : JSON.stringify(output).substring(0, 200) + "...";
1023
1031
  console.log(`[Tool Result] < ${toolName}: ${preview}`);
1024
1032
  return { tool_call_id, output };