MCPcopy Index your code
hub / github.com/simstudioai/sim / convertToolsToResponses

Function convertToolsToResponses

apps/sim/providers/openai/utils.ts:101–125  ·  view source on GitHub ↗
(
  tools: Array<{
    type?: string
    name?: string
    description?: string
    parameters?: Record<string, unknown>
    function?: { name: string; description?: string; parameters?: Record<string, unknown> }
  }>
)

Source from the content-addressed store, hash-verified

99 * Converts tool definitions to the Responses API format.
100 */
101export 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.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected