mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-19 04:04:58 +00:00
fix(ai): use parametersJsonSchema for Google tool declarations, revert Antigravity opus model
- Use parametersJsonSchema instead of parameters for Gemini tool declarations to support full JSON Schema (anyOf, oneOf, const, etc.) - Keep legacy parameters field for Claude models on Cloud Code Assist, where the API translates parameters into Anthropic's input_schema - Revert claude-opus-4-6-thinking back to claude-opus-4-5-thinking (model doesn't exist on the Antigravity endpoint) fixes #1398
This commit is contained in:
parent
82caf064e0
commit
1caadb2e2a
6 changed files with 26 additions and 12 deletions
|
|
@ -2,7 +2,7 @@
|
|||
* Shared utilities for Google Generative AI and Google Cloud Code Assist providers.
|
||||
*/
|
||||
|
||||
import { type Content, FinishReason, FunctionCallingConfigMode, type Part, type Schema } from "@google/genai";
|
||||
import { type Content, FinishReason, FunctionCallingConfigMode, type Part } from "@google/genai";
|
||||
import type { Context, ImageContent, Model, StopReason, TextContent, Tool } from "../types.js";
|
||||
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
||||
import { transformMessages } from "./transform-messages.js";
|
||||
|
|
@ -232,17 +232,23 @@ export function convertMessages<T extends GoogleApiType>(model: Model<T>, contex
|
|||
|
||||
/**
|
||||
* Convert tools to Gemini function declarations format.
|
||||
*
|
||||
* By default uses `parametersJsonSchema` which supports full JSON Schema (including
|
||||
* anyOf, oneOf, const, etc.). Set `useParameters` to true to use the legacy `parameters`
|
||||
* field instead (OpenAPI 3.03 Schema). This is needed for Cloud Code Assist with Claude
|
||||
* models, where the API translates `parameters` into Anthropic's `input_schema`.
|
||||
*/
|
||||
export function convertTools(
|
||||
tools: Tool[],
|
||||
): { functionDeclarations: { name: string; description?: string; parameters: Schema }[] }[] | undefined {
|
||||
useParameters = false,
|
||||
): { functionDeclarations: Record<string, unknown>[] }[] | undefined {
|
||||
if (tools.length === 0) return undefined;
|
||||
return [
|
||||
{
|
||||
functionDeclarations: tools.map((tool) => ({
|
||||
name: tool.name,
|
||||
description: tool.description,
|
||||
parameters: tool.parameters as Schema,
|
||||
...(useParameters ? { parameters: tool.parameters } : { parametersJsonSchema: tool.parameters }),
|
||||
})),
|
||||
},
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue