mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-20 15:01:24 +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
|
|
@ -23,7 +23,7 @@ import type {
|
|||
} from "../types.js";
|
||||
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
||||
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
||||
import { validateToolArguments } from "../utils/validation.js";
|
||||
|
||||
import { transformMessages } from "./transorm-messages.js";
|
||||
|
||||
export interface GoogleOptions extends StreamOptions {
|
||||
|
|
@ -43,7 +43,6 @@ export const streamGoogle: StreamFunction<"google-generative-ai"> = (
|
|||
options?: GoogleOptions,
|
||||
): AssistantMessageEventStream => {
|
||||
const stream = new AssistantMessageEventStream();
|
||||
const shouldValidateToolCalls = options?.validateToolCallsAtProvider !== false;
|
||||
|
||||
(async () => {
|
||||
const output: AssistantMessage = {
|
||||
|
|
@ -167,14 +166,6 @@ export const streamGoogle: StreamFunction<"google-generative-ai"> = (
|
|||
...(part.thoughtSignature && { thoughtSignature: part.thoughtSignature }),
|
||||
};
|
||||
|
||||
// Validate tool arguments if tool definition is available
|
||||
if (shouldValidateToolCalls && context.tools) {
|
||||
const tool = context.tools.find((t) => t.name === toolCall.name);
|
||||
if (tool) {
|
||||
toolCall.arguments = validateToolArguments(tool, toolCall);
|
||||
}
|
||||
}
|
||||
|
||||
output.content.push(toolCall);
|
||||
stream.push({ type: "toolcall_start", contentIndex: blockIndex(), partial: output });
|
||||
stream.push({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue