( tools: OpenAI.Chat.ChatCompletionTool[] | undefined, )
| 159 | * @returns Record of AI SDK tools keyed by tool name, or undefined if no tools |
| 160 | */ |
| 161 | export function convertToolsForAiSdk( |
| 162 | tools: OpenAI.Chat.ChatCompletionTool[] | undefined, |
| 163 | ): Record<string, ReturnType<typeof createTool>> | undefined { |
| 164 | if (!tools || tools.length === 0) { |
| 165 | return undefined |
| 166 | } |
| 167 | |
| 168 | const toolSet: Record<string, ReturnType<typeof createTool>> = {} |
| 169 | |
| 170 | for (const t of tools) { |
| 171 | if (t.type === "function") { |
| 172 | toolSet[t.function.name] = createTool({ |
| 173 | description: t.function.description, |
| 174 | inputSchema: jsonSchema(t.function.parameters as any), |
| 175 | }) |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | return toolSet |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Extended stream part type that includes additional fullStream event types |
no outgoing calls
no test coverage detected