Support lowercase data types for `FunctionDeclarationSchemaType`
Description of the feature request:
This is the current definition of FunctionDeclarationSchemaType used in tools config:
/**
* Contains the list of OpenAPI data types
* as defined by https://swagger.io/docs/specification/data-models/data-types/
* @public
*/
export declare enum FunctionDeclarationSchemaType {
/** String type. */
STRING = "STRING",
/** Number type. */
NUMBER = "NUMBER",
/** Integer type. */
INTEGER = "INTEGER",
/** Boolean type. */
BOOLEAN = "BOOLEAN",
/** Array type. */
ARRAY = "ARRAY",
/** Object type. */
OBJECT = "OBJECT"
}
However, this does not follow OpenAPI conventional (lowercase - which all other providers follow).
What problem are you trying to solve with this feature?
JSON schema compatibility between different providers (Google, OpenAI, Anthropic, Mistral, etc)
Any other information you'd like to share?
All other providers use lowercase data types https://docs.mistral.ai/capabilities/function_calling/#tools https://docs.anthropic.com/en/docs/tool-use
Current workaround is to write a helper method to convert all string values of key type to uppercase
function convertTypeToUpperCase(schema) {
// Helper function to recursively convert 'type' fields to uppercase
function processSchema(obj) {
if (Array.isArray(obj)) {
return obj.map(processSchema);
} else if (obj !== null && typeof obj === 'object') {
const newObj = {};
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
if (key === 'type' && typeof obj[key] === 'string') {
newObj[key] = obj[key].toUpperCase();
} else {
newObj[key] = processSchema(obj[key]);
}
}
}
return newObj;
}
return obj;
}
return processSchema(schema);
}
Looked into this and seems the backend is case-insensitive on enum fields. We should be able to change the enum values to lowercase. But I think this means that for now, if you're not making use of the enum, you don't need this helper method workaround unless you're using TypeScript and running into TypeScript errors on that field. But we can fix the enum so it's not misleading (makes it looks like only uppercase can be sent in those fields).
+1 to this. Please fix the TypeScript enum.