(
tools: Array<{
type?: string
name?: string
description?: string
parameters?: Record<string, unknown>
function?: { name: string; description?: string; parameters?: Record<string, unknown> }
}>
)
| 99 | * Converts tool definitions to the Responses API format. |
| 100 | */ |
| 101 | export function convertToolsToResponses( |
| 102 | tools: Array<{ |
| 103 | type?: string |
| 104 | name?: string |
| 105 | description?: string |
| 106 | parameters?: Record<string, unknown> |
| 107 | function?: { name: string; description?: string; parameters?: Record<string, unknown> } |
| 108 | }> |
| 109 | ): ResponsesToolDefinition[] { |
| 110 | return tools |
| 111 | .map((tool) => { |
| 112 | const name = tool.function?.name ?? tool.name |
| 113 | if (!name) { |
| 114 | return null |
| 115 | } |
| 116 | |
| 117 | return { |
| 118 | type: 'function' as const, |
| 119 | name, |
| 120 | description: tool.function?.description ?? tool.description, |
| 121 | parameters: tool.function?.parameters ?? tool.parameters, |
| 122 | } |
| 123 | }) |
| 124 | .filter(Boolean) as ResponsesToolDefinition[] |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Converts tool_choice to the Responses API format. |
no outgoing calls
no test coverage detected