mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-30 15:04:16 -07:00
refactor: use parametersJsonSchema consistently across tool definitions
This commit is contained in:
@@ -240,7 +240,6 @@ export class GeminiChat {
|
|||||||
private sendPromise: Promise<void> = Promise.resolve();
|
private sendPromise: Promise<void> = Promise.resolve();
|
||||||
private readonly chatRecordingService: ChatRecordingService;
|
private readonly chatRecordingService: ChatRecordingService;
|
||||||
private lastPromptTokenCount: number;
|
private lastPromptTokenCount: number;
|
||||||
private lastUsedModel?: string;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly config: Config,
|
private readonly config: Config,
|
||||||
@@ -582,10 +581,7 @@ export class GeminiChat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Track final request parameters for AfterModel hooks
|
// Track final request parameters for AfterModel hooks
|
||||||
if (modelToUse !== this.lastUsedModel) {
|
await this.config.getGeminiClient().setTools(modelToUse);
|
||||||
await this.config.getGeminiClient().setTools(modelToUse);
|
|
||||||
this.lastUsedModel = modelToUse;
|
|
||||||
}
|
|
||||||
lastModelToUse = modelToUse;
|
lastModelToUse = modelToUse;
|
||||||
lastConfig = config;
|
lastConfig = config;
|
||||||
lastContentsToUse = contentsToUse;
|
lastContentsToUse = contentsToUse;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export const READ_FILE_DEFINITION: ToolDefinition = {
|
|||||||
base: {
|
base: {
|
||||||
name: READ_FILE_TOOL_NAME,
|
name: READ_FILE_TOOL_NAME,
|
||||||
description: `Reads and returns the content of a specified file. If the file is large, the content will be truncated. The tool's response will clearly indicate if truncation has occurred and will provide details on how to read more of the file using the 'offset' and 'limit' parameters. Handles text, images (PNG, JPG, GIF, WEBP, SVG, BMP), audio files (MP3, WAV, AIFF, AAC, OGG, FLAC), and PDF files. For text files, it can read specific line ranges.`,
|
description: `Reads and returns the content of a specified file. If the file is large, the content will be truncated. The tool's response will clearly indicate if truncation has occurred and will provide details on how to read more of the file using the 'offset' and 'limit' parameters. Handles text, images (PNG, JPG, GIF, WEBP, SVG, BMP), audio files (MP3, WAV, AIFF, AAC, OGG, FLAC), and PDF files. For text files, it can read specific line ranges.`,
|
||||||
parameters: {
|
parametersJsonSchema: {
|
||||||
type: Type.OBJECT,
|
type: Type.OBJECT,
|
||||||
properties: {
|
properties: {
|
||||||
file_path: {
|
file_path: {
|
||||||
@@ -94,7 +94,7 @@ export function getShellDefinition(
|
|||||||
base: {
|
base: {
|
||||||
name: SHELL_TOOL_NAME,
|
name: SHELL_TOOL_NAME,
|
||||||
description: getShellToolDescription(enableInteractiveShell),
|
description: getShellToolDescription(enableInteractiveShell),
|
||||||
parameters: {
|
parametersJsonSchema: {
|
||||||
type: Type.OBJECT,
|
type: Type.OBJECT,
|
||||||
properties: {
|
properties: {
|
||||||
command: {
|
command: {
|
||||||
|
|||||||
@@ -237,9 +237,6 @@ export class ReadFileTool extends BaseDeclarativeTool<
|
|||||||
}
|
}
|
||||||
|
|
||||||
override getSchema(modelId?: string) {
|
override getSchema(modelId?: string) {
|
||||||
if (!modelId) {
|
|
||||||
return super.getSchema();
|
|
||||||
}
|
|
||||||
return resolveToolDeclaration(READ_FILE_DEFINITION, modelId);
|
return resolveToolDeclaration(READ_FILE_DEFINITION, modelId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -515,10 +515,6 @@ export class ShellTool extends BaseDeclarativeTool<
|
|||||||
const definition = getShellDefinition(
|
const definition = getShellDefinition(
|
||||||
this.config.getEnableInteractiveShell(),
|
this.config.getEnableInteractiveShell(),
|
||||||
);
|
);
|
||||||
if (!modelId) {
|
|
||||||
return super.getSchema();
|
|
||||||
}
|
|
||||||
|
|
||||||
return resolveToolDeclaration(definition, modelId);
|
return resolveToolDeclaration(definition, modelId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user