MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / convertToolsForAiSdk

Function convertToolsForAiSdk

src/api/transform/ai-sdk.ts:161–180  ·  view source on GitHub ↗
(
	tools: OpenAI.Chat.ChatCompletionTool[] | undefined,
)

Source from the content-addressed store, hash-verified

159 * @returns Record of AI SDK tools keyed by tool name, or undefined if no tools
160 */
161export 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

Callers 3

createMessageFunction · 0.90
createMessageMethod · 0.90
ai-sdk.spec.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected