Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: New Feature: Support DateTime parameters in tools for Assistants API #9940

Open
joeyj opened this issue Dec 10, 2024 · 0 comments
Open
Labels
agents .NET Issue or Pull requests regarding .NET code

Comments

@joeyj
Copy link

joeyj commented Dec 10, 2024


name: Support DateTime parameter in tool definition for Assistants API

DateTime is currently converted to object which prevents the model from generating proper tool calls in Assistants API as object is defined as a dictionary or property bag in JSON Schema: https://json-schema.org/understanding-json-schema/reference/object

Current logic:

private static string ConvertType(Type? type)
{
if (type is null || type == typeof(string))
{
return "string";
}
if (type == typeof(bool))
{
return "boolean";
}
if (type.IsEnum)
{
return "enum";
}
if (type.IsArray)
{
return "array";
}
return Type.GetTypeCode(type) switch
{
TypeCode.SByte or TypeCode.Byte or
TypeCode.Int16 or TypeCode.UInt16 or
TypeCode.Int32 or TypeCode.UInt32 or
TypeCode.Int64 or TypeCode.UInt64 or
TypeCode.Single or TypeCode.Double or TypeCode.Decimal => "number",
_ => "object",
};
}

This can be worked around by changing the kernel function parameter type to string and handling type conversion manually.

By contrast, tool definitions generated for Chat Completion API are higher fidelity. For example, it converts DateTime to

{
  "type" : "string",
  "format": "date-time"
}
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage labels Dec 10, 2024
@github-actions github-actions bot changed the title New Feature: Support DateTime parameters in tools for Assistants API .Net: New Feature: Support DateTime parameters in tools for Assistants API Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents .NET Issue or Pull requests regarding .NET code
Projects
Status: Backlog
Development

No branches or pull requests

3 participants