mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 11:02:06 +00:00
Remove provider-level tool validation, add validateToolCall helper
This commit is contained in:
parent
0196308266
commit
8bec289dc6
14 changed files with 59 additions and 68 deletions
|
|
@ -27,6 +27,21 @@ if (!isBrowserExtension) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a tool by name and validates the tool call arguments against its TypeBox schema
|
||||
* @param tools Array of tool definitions
|
||||
* @param toolCall The tool call from the LLM
|
||||
* @returns The validated arguments
|
||||
* @throws Error if tool is not found or validation fails
|
||||
*/
|
||||
export function validateToolCall(tools: Tool[], toolCall: ToolCall): any {
|
||||
const tool = tools.find((t) => t.name === toolCall.name);
|
||||
if (!tool) {
|
||||
throw new Error(`Tool "${toolCall.name}" not found`);
|
||||
}
|
||||
return validateToolArguments(tool, toolCall);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates tool call arguments against the tool's TypeBox schema
|
||||
* @param tool The tool definition with TypeBox schema
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue