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

ToolConstraint Type Cannot Be Identified or Unboxed After API Call #291

Open
1 task done
sandrohanea opened this issue Nov 13, 2024 · 0 comments
Open
1 task done

Comments

@sandrohanea
Copy link

Confirm this is a feature request for the .NET library and not the underlying OpenAI API

  • This is a feature request for the .NET library

Describe the feature or improvement you are requesting

When creating an Assistant Run for a specific thread a tool constraint can be defined: auto, none or required.

However, when the run is retrieved, it is impossible to tell which type was deserialized as the instance contains no public properties and ToString() is not writing something special.

I tried to compare it with the static options (e.g. ToolConstraint.Auto) but the result is false, and no property is exposed to identify that specific tool constraint.

image

Here is some code sample:


var assistantsClient = new AssistantsClient("someApiKey");

var runResponse = await assistantsClient.GetRunAsync("thread_gA...kv2", "run_ecofR9n2oxKh...dWjM");

if (runResponse.Value.ToolConstraint == ToolConstraint.Auto)
{
    Console.WriteLine("ToolConstraint is Auto");
}
else if(runResponse.Value.ToolConstraint == ToolConstraint.None)
{
    Console.WriteLine("ToolConstraint is None");
}
else if (runResponse.Value.ToolConstraint == ToolConstraint.Required)
{
    Console.WriteLine("ToolConstraint is Required");
}
else
{
    Console.WriteLine("ToolConstraint is Unknown");
}

Console.WriteLine(runResponse.Value.ToolConstraint);

The above code will display

ToolConstraint is Unknown
OpenAI.Assistants.ToolConstraint
``

There is no way to unbox that information as type is private.

### Additional context

Same behavior is observed for other enum-like types: (e.g. `FileChunkingStrategy`)
@sandrohanea sandrohanea changed the title ToolConstraint is not unboxable after calling the API ToolConstraint Type Cannot Be Identified or Unboxed After API Call Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant