Files
page-agent/src/llms/utils.ts
T

22 lines
443 B
TypeScript
Raw Normal View History

2025-10-17 18:43:41 +08:00
/**
* Utility functions for LLM integration
*/
import { z } from 'zod'
import type { Tool } from './types'
/**
* Convert Zod schema to OpenAI tool format
* Uses Zod 4 native z.toJSONSchema()
*/
export function zodToOpenAITool(name: string, tool: Tool) {
return {
type: 'function' as const,
function: {
name,
description: tool.description,
parameters: z.toJSONSchema(tool.inputSchema, { target: 'openapi-3.0' }),
},
}
}