Files
agent-chat-ui/agent/find-tool-call.ts

15 lines
342 B
TypeScript
Raw Normal View History

2025-02-27 15:41:47 -08:00
import { z, ZodTypeAny } from "zod";
interface ToolCall {
name: string;
args: Record<string, any>;
id?: string;
type?: "tool_call";
}
export function findToolCall<Name extends string>(name: Name) {
return <Args extends ZodTypeAny>(
x: ToolCall,
2025-03-06 11:42:39 -08:00
): x is { name: Name; args: z.infer<Args>; id?: string } => x.name === name;
2025-02-27 15:41:47 -08:00
}