GenkitG
Genkit12mo ago
5 replies
clean-aquamarine

JSON output in Claude model

Running into some circles with Claude's lack of json mode. I've got a common generate function (takes in <T> types) that I use in all my flows and across LLM's (gemini, openai)

However I can't seem to get it to work with tools (the workaround for claude). Using genkitx-anthropic but I can't even get that far.

I can't use ai.define_tool at runtime (genkit limitation) and I'd like to avoid having to pre create tools for all flows

Just passing in a literal object (into tools array in the generate call) that fits ToolDefinition type name, description, inputSchema gives me this exception:
Error: Unable to determine type of of tool: answer
    at /workspace/node_modules/@genkit-ai/ai/lib/generate.js:276:13
    at Generator.next (<anonymous>)
    at fulfilled (/workspace/node_modules/@genkit-ai/ai/lib/generate.js:41:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

looking for that string in the genkit repo it looks like a failed tool registry lookup (generate.ts line 345). Is there anyway to pass in a non predefined tool?
Was this page helpful?