refactor: remove ParseParams() from Tool interface (#2375)

The `ParseParams` Tool interface is only passing the tool's parameter
into a generic `parameters.ParseParams()` helper. Instead of keeping it
as a tool interface, we add a `GetParameters()` method
(https://github.com/googleapis/genai-toolbox/pull/2374) to the tool
interface and call it directly from the API handlers. This way we keep
the parameter parsing logic independent from the tools.
This commit is contained in:
Wenxin Du
2026-01-28 18:01:13 -05:00
committed by GitHub
parent 252fc3091a
commit 2d5d33388c
193 changed files with 14 additions and 776 deletions

View File

@@ -145,11 +145,6 @@ func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, para
return source.CreateUsers(ctx, project, instance, name, password, iamUser, string(accessToken))
}
// ParseParams parses the parameters for the tool.
func (t Tool) ParseParams(data map[string]any, claims map[string]map[string]any) (parameters.ParamValues, error) {
return parameters.ParseParams(t.AllParams, data, claims)
}
func (t Tool) EmbedParams(ctx context.Context, paramValues parameters.ParamValues, embeddingModelsMap map[string]embeddingmodels.EmbeddingModel) (parameters.ParamValues, error) {
return parameters.EmbedParams(ctx, t.AllParams, paramValues, embeddingModelsMap, nil)
}