Convert LiteLLM tool_calls to OpenAI message format.
(tool_calls)
| 53 | |
| 54 | |
| 55 | def _serialize_tool_calls(tool_calls) -> list[dict]: |
| 56 | """Convert LiteLLM tool_calls to OpenAI message format.""" |
| 57 | return [ |
| 58 | { |
| 59 | "id": tc.id, |
| 60 | "type": "function", |
| 61 | "function": { |
| 62 | "name": tc.function.name, |
| 63 | "arguments": tc.function.arguments, |
| 64 | }, |
| 65 | } |
| 66 | for tc in tool_calls |
| 67 | ] |
| 68 | |
| 69 | |
| 70 | def _format_mcp_result(tool_name: str, raw: Any) -> str: |