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: Fixed JSON schema name in Structured Outputs for generic types #9490

Merged

Conversation

dmytrostruk
Copy link
Member

Motivation and Context

Resolves: #9416

When C# type is passed as a response format to OpenAI chat completion service, we use the type name as JSON schema name. When the type is generic, its name will contain characters that are not allowed in JSON schema name according to OpenAI API. This PR fixes the issue by replacing invalid characters with empty string.

Contribution Checklist

@dmytrostruk dmytrostruk self-assigned this Oct 31, 2024
@dmytrostruk dmytrostruk requested a review from a team as a code owner October 31, 2024 18:07
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Oct 31, 2024
@asvishnyakov
Copy link

Wouldn't it better to use fully qualified type names, as they are truly unique, and because OpenAI doesn't support symbols, use for example hash of string?

@dmytrostruk
Copy link
Member Author

Wouldn't it better to use fully qualified type names, as they are truly unique, and because OpenAI doesn't support symbols, use for example hash of string?

@asvishnyakov Thanks for your feedback! I don't see a requirement for this property to be unique in OpenAI docs or usage of hash in their examples. It would be also nice to be consistent with Python implementation, which uses just a name.

@dmytrostruk dmytrostruk added this pull request to the merge queue Nov 1, 2024
Merged via the queue into microsoft:main with commit f80528f Nov 1, 2024
15 checks passed
@dmytrostruk dmytrostruk deleted the structured-outputs-schema-name-fix branch November 1, 2024 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP 400 error "Invalid 'response_format.json_schema.name'" when generic type is used for ResponseFormat
4 participants