@contentgrowth/llm-service 1.2.3 → 1.2.4

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
@@ -777,8 +777,20 @@ ${msg.content}`;
777
777
  const isLastAssistantMessage = index === geminiMessages.map((m, i) => m.role === "assistant" ? i : -1).filter((i) => i >= 0).pop();
778
778
  if (msg.tool_calls) {
779
779
  parts2 = msg.tool_calls.map((tc) => {
780
+ let args = tc.function.args;
781
+ if (tc.function.arguments) {
782
+ if (typeof tc.function.arguments === "string") {
783
+ try {
784
+ args = JSON.parse(tc.function.arguments);
785
+ } catch (e) {
786
+ args = {};
787
+ }
788
+ } else {
789
+ args = tc.function.arguments;
790
+ }
791
+ }
780
792
  const part = {
781
- functionCall: { name: tc.function.name, args: tc.function.arguments || tc.function.args }
793
+ functionCall: { name: tc.function.name, args }
782
794
  };
783
795
  if (tc.thought_signature) {
784
796
  part.thoughtSignature = tc.thought_signature;
@@ -863,7 +875,10 @@ ${msg.content}`;
863
875
  thought_signature: responseThoughtSignature,
864
876
  tool_calls: toolCalls ? (Array.isArray(toolCalls) ? toolCalls : [toolCalls]).map((fc) => ({
865
877
  type: "function",
866
- function: fc,
878
+ function: {
879
+ name: fc.name,
880
+ arguments: JSON.stringify(fc.args || {})
881
+ },
867
882
  thought_signature: fc.thought_signature
868
883
  })) : null,
869
884
  finishReason: normalizedFinishReason,