Skip to content

Name preprocessor

Utility functions for name preprocessing.

This module provides functions to preprocess names according to Google's name requirements.

References

https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/function-calling

Rules: - For GoogleADK Agent Name: - Must start with a letter (a-z, A-Z) or an underscore (), - Can only contain letters, digits (0-9), and underscores. - Has no length limit. - For Tool Name: - Must start with a letter (a-z, A-Z) or an underscore (), - Can only contain letters, digits (0-9), underscores, and dashes. - Has a length limit of 64 characters, but google throws error if the length is exactly 64, so cut to 63. - For OpenAI, - they only have rule for tool name, and it is the same as Google's tool name rule, - except it can start with any character as long as it is a valid character (alphanumeric, _, -)

Authors

Putu Ravindra Wiguna (putu.r.wiguna@gdplabs.id)

NamePreprocessor(provider)

Name Preprocessor for Google ADK and OpenAI compatible models.

Parameters:

Name Type Description Default
provider str

The provider of the model.

required

Initialize the name preprocessor.

Parameters:

Name Type Description Default
provider str

The provider of the model.

required

sanitize_agent_name(name)

Preprocess an input name according to the rules of the name processor.

Parameters:

Name Type Description Default
name str

The input name to preprocess.

required

Returns:

Type Description
str

A name that is valid for the name processor.

sanitize_tool_name(name)

Preprocess an input name according to the rules of the name processor.

Parameters:

Name Type Description Default
name str

The input name to preprocess.

required

Returns:

Type Description
str

A name that is valid for the name processor.