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

Azure OpenAI: fix object representation of response_format #26997

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,33 @@ using TypeSpec.Versioning;
namespace Azure.OpenAI;

@added(ServiceApiVersions.v2023_12_01_Preview)
@doc("The valid response formats Chat Completions can provide. Used to enable JSON mode.")
enum ChatCompletionsResponseFormat {
@doc("Use the default, plain text response format.")
text: "text",
@doc("""
An abstract representation of a response format configuration usable by Chat Completions. Can be used to enable JSON
mode.
""")
@discriminator("type")
model ChatCompletionsResponseFormat {
@doc("The discriminated type for the response format.")
type: string;
}

@doc("""
Use a response format that guarantees emission of a valid JSON object. Only structure is guaranteed and contents must
still be validated.
""")
jsonObject: "json_object",
@doc("""
The standard Chat Completions response format that can freely generate text and is not guaranteed to produce response
content that adheres to a specific schema.
""")
@added(ServiceApiVersions.v2023_12_01_Preview)
model ChatCompletionsTextResponseFormat extends ChatCompletionsResponseFormat {
@doc("The discriminated object type, which is always 'text' for this format.")
type: "text";
}

@doc("""
A response format for Chat Completions that restricts responses to emitting valid JSON objects.
""")
@added(ServiceApiVersions.v2023_12_01_Preview)
model ChatCompletionsJsonResponseFormat extends ChatCompletionsResponseFormat {
@doc("The discriminated object type, which is always 'json_object' for this format.")
type: "json_object";
}

@doc("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,16 @@
],
"x-ms-discriminator-value": "function"
},
"ChatCompletionsJsonResponseFormat": {
"type": "object",
"description": "A response format for Chat Completions that restricts responses to emitting valid JSON objects.",
"allOf": [
{
"$ref": "#/definitions/ChatCompletionsResponseFormat"
}
],
"x-ms-discriminator-value": "json_object"
},
"ChatCompletionsOptions": {
"type": "object",
"description": "The configuration information for a chat completions request.\nCompletions support a wide variety of tasks and generate text that continues from or \"completes\"\nprovided prompt data.",
Expand Down Expand Up @@ -1810,28 +1820,28 @@
]
},
"ChatCompletionsResponseFormat": {
"type": "string",
"description": "The valid response formats Chat Completions can provide. Used to enable JSON mode.",
"enum": [
"text",
"json_object"
"type": "object",
"description": "An abstract representation of a response format configuration usable by Chat Completions. Can be used to enable JSON\nmode.",
"properties": {
"type": {
"type": "string",
"description": "The discriminated type for the response format."
}
},
"discriminator": "type",
"required": [
"type"
]
},
"ChatCompletionsTextResponseFormat": {
"type": "object",
"description": "The standard Chat Completions response format that can freely generate text and is not guaranteed to produce response\ncontent that adheres to a specific schema.",
"allOf": [
{
"$ref": "#/definitions/ChatCompletionsResponseFormat"
}
],
"x-ms-enum": {
"name": "ChatCompletionsResponseFormat",
"modelAsString": true,
"values": [
{
"name": "text",
"value": "text",
"description": "Use the default, plain text response format."
},
{
"name": "jsonObject",
"value": "json_object",
"description": "Use a response format that guarantees emission of a valid JSON object. Only structure is guaranteed and contents must\nstill be validated."
}
]
}
"x-ms-discriminator-value": "text"
},
"ChatCompletionsToolCall": {
"type": "object",
Expand Down