From e0945efafc50349fe36ee1869b129a1ed2e2c748 Mon Sep 17 00:00:00 2001 From: Travis Wilson <35748617+trrwilson@users.noreply.github.com> Date: Mon, 17 Jul 2023 15:02:28 -0700 Subject: [PATCH] a couple of representation tweaks for codegen (#24847) --- .../OpenAI.Inference/models/chat.completions.tsp | 7 ++++--- .../OpenAI.Inference/models/completions.create.tsp | 5 +++-- .../OpenAI.Inference/models/images.tsp | 12 ++++++++---- .../preview/2023-06-01-preview/generated.json | 14 ++++++++------ .../preview/2023-07-01-preview/generated.json | 14 ++++++++------ .../inference/stable/2022-12-01/generated.json | 2 +- .../inference/stable/2023-05-15/generated.json | 10 ++++++---- 7 files changed, 38 insertions(+), 26 deletions(-) diff --git a/specification/cognitiveservices/OpenAI.Inference/models/chat.completions.tsp b/specification/cognitiveservices/OpenAI.Inference/models/chat.completions.tsp index 16f2cbb66d4f..808bbbc8bb28 100644 --- a/specification/cognitiveservices/OpenAI.Inference/models/chat.completions.tsp +++ b/specification/cognitiveservices/OpenAI.Inference/models/chat.completions.tsp @@ -32,9 +32,10 @@ model ChatMessage { @projectedName("json", "role") role: ChatRole; + #suppress "@azure-tools/typespec-azure-core/no-nullable" "we explicitly want a nullable string" @doc("The text associated with this message payload.") @projectedName("json", "content") - content?: string; + content: string | null; @doc(""" The name of the author of this message. `name` is required if role is `function`, and it should be the name of the @@ -225,9 +226,9 @@ model ChatCompletions { represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970. """) @projectedName("json", "created") - @projectedName("csharp", "InternalCreatedSecondsAfterUnixEpoch") @projectedName("java", "createdAt") - created: int32; + @encode(DateTimeKnownEncoding.unixTimestamp, int32) + created: utcDateTime; @doc(""" The collection of completions choices associated with this completions response. diff --git a/specification/cognitiveservices/OpenAI.Inference/models/completions.create.tsp b/specification/cognitiveservices/OpenAI.Inference/models/completions.create.tsp index 82b8ed68cf14..e65c4c7f1967 100644 --- a/specification/cognitiveservices/OpenAI.Inference/models/completions.create.tsp +++ b/specification/cognitiveservices/OpenAI.Inference/models/completions.create.tsp @@ -158,8 +158,9 @@ model Completions { represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970. """) @projectedName("json", "created") - @projectedName("csharp", "InternalCreatedSecondsAfterUnixEpoch") - created: int32; + @projectedName("java", "createdAt") + @encode(DateTimeKnownEncoding.unixTimestamp, int32) + created: utcDateTime; @doc(""" Content filtering results for zero or more prompts in the request. In a streaming request, diff --git a/specification/cognitiveservices/OpenAI.Inference/models/images.tsp b/specification/cognitiveservices/OpenAI.Inference/models/images.tsp index cc9dffd6601d..6dc36991511e 100644 --- a/specification/cognitiveservices/OpenAI.Inference/models/images.tsp +++ b/specification/cognitiveservices/OpenAI.Inference/models/images.tsp @@ -76,12 +76,13 @@ model ImagePayload { @added(ServiceApiVersions.v2023_06_01_Preview) model ImageGenerations { @doc("A timestamp when this job or item was created (in unix epochs).") - @projectedName("csharp", "InternalCreatedSecondsAfterUnixEpoch") - created: int64; + @projectedName("json", "created") + @projectedName("java", "createdAt") + @encode(DateTimeKnownEncoding.unixTimestamp, int32) + created: utcDateTime; #suppress "@azure-tools/typespec-autorest/union-unsupported" "openapi v2 not required" @doc("The images generated by the operator.") - @projectedName("csharp", "InternalEmittedImageResponseItems") data: ImageLocation[] | ImagePayload[]; } @@ -96,7 +97,10 @@ model BatchImageGenerationOperationResponse { id: string; @doc("A timestamp when this job or item was created (in unix epochs).") - created: int64; + @projectedName("json", "created") + @projectedName("java", "createdAt") + @encode(DateTimeKnownEncoding.unixTimestamp, int32) + created: utcDateTime; @doc("A timestamp when this operation and its associated images expire and will be deleted (in unix epochs).") expires?: int64; diff --git a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-06-01-preview/generated.json b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-06-01-preview/generated.json index 576b78e8d966..cc8535b5e200 100644 --- a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-06-01-preview/generated.json +++ b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-06-01-preview/generated.json @@ -421,7 +421,7 @@ }, "created": { "type": "integer", - "format": "int64", + "format": "unixtime", "description": "A timestamp when this job or item was created (in unix epochs)." }, "expires": { @@ -492,7 +492,7 @@ }, "created": { "type": "integer", - "format": "int32", + "format": "unixtime", "description": "The first timestamp associated with generation activity for this completions response,\nrepresented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970." }, "choices": { @@ -613,11 +613,13 @@ }, "content": { "type": "string", - "description": "The text associated with this message payload." + "description": "The text associated with this message payload.", + "x-nullable": true } }, "required": [ - "role" + "role", + "content" ] }, "ChatRole": { @@ -702,7 +704,7 @@ }, "created": { "type": "integer", - "format": "int32", + "format": "unixtime", "description": "The first timestamp associated with generation activity for this completions response,\nrepresented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970." }, "prompt_annotations": { @@ -1164,7 +1166,7 @@ "properties": { "created": { "type": "integer", - "format": "int64", + "format": "unixtime", "description": "A timestamp when this job or item was created (in unix epochs)." }, "data": { diff --git a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-07-01-preview/generated.json b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-07-01-preview/generated.json index 411186ce784d..2ddf16cdaf9b 100644 --- a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-07-01-preview/generated.json +++ b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-07-01-preview/generated.json @@ -421,7 +421,7 @@ }, "created": { "type": "integer", - "format": "int64", + "format": "unixtime", "description": "A timestamp when this job or item was created (in unix epochs)." }, "expires": { @@ -492,7 +492,7 @@ }, "created": { "type": "integer", - "format": "int32", + "format": "unixtime", "description": "The first timestamp associated with generation activity for this completions response,\nrepresented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970." }, "choices": { @@ -625,7 +625,8 @@ }, "content": { "type": "string", - "description": "The text associated with this message payload." + "description": "The text associated with this message payload.", + "x-nullable": true }, "name": { "type": "string", @@ -638,7 +639,8 @@ } }, "required": [ - "role" + "role", + "content" ] }, "ChatRole": { @@ -729,7 +731,7 @@ }, "created": { "type": "integer", - "format": "int32", + "format": "unixtime", "description": "The first timestamp associated with generation activity for this completions response,\nrepresented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970." }, "prompt_annotations": { @@ -1235,7 +1237,7 @@ "properties": { "created": { "type": "integer", - "format": "int64", + "format": "unixtime", "description": "A timestamp when this job or item was created (in unix epochs)." }, "data": { diff --git a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2022-12-01/generated.json b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2022-12-01/generated.json index 62a5ec0b2eee..4817ba7a5ee3 100644 --- a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2022-12-01/generated.json +++ b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2022-12-01/generated.json @@ -271,7 +271,7 @@ }, "created": { "type": "integer", - "format": "int32", + "format": "unixtime", "description": "The first timestamp associated with generation activity for this completions response,\nrepresented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970." }, "choices": { diff --git a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2023-05-15/generated.json b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2023-05-15/generated.json index e667090697f3..b7c515db0245 100644 --- a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2023-05-15/generated.json +++ b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2023-05-15/generated.json @@ -314,7 +314,7 @@ }, "created": { "type": "integer", - "format": "int32", + "format": "unixtime", "description": "The first timestamp associated with generation activity for this completions response,\nrepresented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970." }, "choices": { @@ -426,11 +426,13 @@ }, "content": { "type": "string", - "description": "The text associated with this message payload." + "description": "The text associated with this message payload.", + "x-nullable": true } }, "required": [ - "role" + "role", + "content" ] }, "ChatRole": { @@ -510,7 +512,7 @@ }, "created": { "type": "integer", - "format": "int32", + "format": "unixtime", "description": "The first timestamp associated with generation activity for this completions response,\nrepresented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970." }, "choices": {