import OpenAI from "openai";
import type { ToolCall } from "./styles";

type OpenAIToolCalls = OpenAI.ChatCompletionAssistantMessageParam["tool_calls"];
export const formatToolCalls = (toolCalls: OpenAIToolCalls): ToolCall[] => {
  if (!toolCalls) return [];

  return toolCalls.map((toolCall) => ({
    name: toolCall.function.name,
    args: JSON.parse(toolCall.function.arguments),
  }));
};
