diff options
Diffstat (limited to 'packages/core/src/tools/web-search.ts')
| -rw-r--r-- | packages/core/src/tools/web-search.ts | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/packages/core/src/tools/web-search.ts b/packages/core/src/tools/web-search.ts index 5ee8e85c..98be1f30 100644 --- a/packages/core/src/tools/web-search.ts +++ b/packages/core/src/tools/web-search.ts @@ -6,6 +6,7 @@ import { GroundingMetadata } from '@google/genai'; import { BaseTool, ToolResult } from './tools.js'; +import { Type } from '@google/genai'; import { SchemaValidator } from '../utils/schemaValidator.js'; import { getErrorMessage } from '../utils/errors.js'; @@ -69,10 +70,10 @@ export class WebSearchTool extends BaseTool< 'GoogleSearch', 'Performs a web search using Google Search (via the Gemini API) and returns the results. This tool is useful for finding information on the internet based on a query.', { - type: 'object', + type: Type.OBJECT, properties: { query: { - type: 'string', + type: Type.STRING, description: 'The search query to find information on the web.', }, }, @@ -86,16 +87,12 @@ export class WebSearchTool extends BaseTool< * @param params The parameters to validate * @returns An error message string if validation fails, null if valid */ - validateToolParams(params: WebSearchToolParams): string | null { - if ( - this.schema.parameters && - !SchemaValidator.validate( - this.schema.parameters as Record<string, unknown>, - params, - ) - ) { - return "Parameters failed schema validation. Ensure 'query' is a string."; + validateParams(params: WebSearchToolParams): string | null { + const errors = SchemaValidator.validate(this.schema.parameters, params); + if (errors) { + return errors; } + if (!params.query || params.query.trim() === '') { return "The 'query' parameter cannot be empty."; } |
