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

Function toResponsesToolChoice

apps/sim/providers/openai/utils.ts:130–153  ·  view source on GitHub ↗
(
  toolChoice:
    | 'auto'
    | 'none'
    | { type: 'function'; function?: { name: string }; name?: string }
    | { type: 'tool'; name: string }
    | { type: 'any'; any: { model: string; name: string } }
    | undefined
)

Source from the content-addressed store, hash-verified

128 * Converts tool_choice to the Responses API format.
129 */
130export function toResponsesToolChoice(
131 toolChoice:
132 | 'auto'
133 | 'none'
134 | { type: 'function'; function?: { name: string }; name?: string }
135 | { type: 'tool'; name: string }
136 | { type: 'any'; any: { model: string; name: string } }
137 | undefined
138): 'auto' | 'none' | { type: 'function'; name: string } | undefined {
139 if (!toolChoice) {
140 return undefined
141 }
142
143 if (typeof toolChoice === 'string') {
144 return toolChoice
145 }
146
147 if (toolChoice.type === 'function') {
148 const name = toolChoice.name ?? toolChoice.function?.name
149 return name ? { type: 'function', name } : undefined
150 }
151
152 return 'auto'
153}
154
155function isRecord(value: unknown): value is Record<string, unknown> {
156 return typeof value === 'object' && value !== null

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected