Skip to content

Commit e0945ef

Browse files
trrwilsonharryli0108
authored andcommitted
a couple of representation tweaks for codegen (Azure#24847)
1 parent fa537fc commit e0945ef

File tree

7 files changed

+38
-26
lines changed

7 files changed

+38
-26
lines changed

specification/cognitiveservices/OpenAI.Inference/models/chat.completions.tsp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ model ChatMessage {
3232
@projectedName("json", "role")
3333
role: ChatRole;
3434

35+
#suppress "@azure-tools/typespec-azure-core/no-nullable" "we explicitly want a nullable string"
3536
@doc("The text associated with this message payload.")
3637
@projectedName("json", "content")
37-
content?: string;
38+
content: string | null;
3839

3940
@doc("""
4041
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 {
225226
represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970.
226227
""")
227228
@projectedName("json", "created")
228-
@projectedName("csharp", "InternalCreatedSecondsAfterUnixEpoch")
229229
@projectedName("java", "createdAt")
230-
created: int32;
230+
@encode(DateTimeKnownEncoding.unixTimestamp, int32)
231+
created: utcDateTime;
231232

232233
@doc("""
233234
The collection of completions choices associated with this completions response.

specification/cognitiveservices/OpenAI.Inference/models/completions.create.tsp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ model Completions {
158158
represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970.
159159
""")
160160
@projectedName("json", "created")
161-
@projectedName("csharp", "InternalCreatedSecondsAfterUnixEpoch")
162-
created: int32;
161+
@projectedName("java", "createdAt")
162+
@encode(DateTimeKnownEncoding.unixTimestamp, int32)
163+
created: utcDateTime;
163164

164165
@doc("""
165166
Content filtering results for zero or more prompts in the request. In a streaming request,

specification/cognitiveservices/OpenAI.Inference/models/images.tsp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ model ImagePayload {
7676
@added(ServiceApiVersions.v2023_06_01_Preview)
7777
model ImageGenerations {
7878
@doc("A timestamp when this job or item was created (in unix epochs).")
79-
@projectedName("csharp", "InternalCreatedSecondsAfterUnixEpoch")
80-
created: int64;
79+
@projectedName("json", "created")
80+
@projectedName("java", "createdAt")
81+
@encode(DateTimeKnownEncoding.unixTimestamp, int32)
82+
created: utcDateTime;
8183

8284
#suppress "@azure-tools/typespec-autorest/union-unsupported" "openapi v2 not required"
8385
@doc("The images generated by the operator.")
84-
@projectedName("csharp", "InternalEmittedImageResponseItems")
8586
data: ImageLocation[] | ImagePayload[];
8687
}
8788

@@ -96,7 +97,10 @@ model BatchImageGenerationOperationResponse {
9697
id: string;
9798

9899
@doc("A timestamp when this job or item was created (in unix epochs).")
99-
created: int64;
100+
@projectedName("json", "created")
101+
@projectedName("java", "createdAt")
102+
@encode(DateTimeKnownEncoding.unixTimestamp, int32)
103+
created: utcDateTime;
100104

101105
@doc("A timestamp when this operation and its associated images expire and will be deleted (in unix epochs).")
102106
expires?: int64;

specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-06-01-preview/generated.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@
421421
},
422422
"created": {
423423
"type": "integer",
424-
"format": "int64",
424+
"format": "unixtime",
425425
"description": "A timestamp when this job or item was created (in unix epochs)."
426426
},
427427
"expires": {
@@ -492,7 +492,7 @@
492492
},
493493
"created": {
494494
"type": "integer",
495-
"format": "int32",
495+
"format": "unixtime",
496496
"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."
497497
},
498498
"choices": {
@@ -613,11 +613,13 @@
613613
},
614614
"content": {
615615
"type": "string",
616-
"description": "The text associated with this message payload."
616+
"description": "The text associated with this message payload.",
617+
"x-nullable": true
617618
}
618619
},
619620
"required": [
620-
"role"
621+
"role",
622+
"content"
621623
]
622624
},
623625
"ChatRole": {
@@ -702,7 +704,7 @@
702704
},
703705
"created": {
704706
"type": "integer",
705-
"format": "int32",
707+
"format": "unixtime",
706708
"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."
707709
},
708710
"prompt_annotations": {
@@ -1164,7 +1166,7 @@
11641166
"properties": {
11651167
"created": {
11661168
"type": "integer",
1167-
"format": "int64",
1169+
"format": "unixtime",
11681170
"description": "A timestamp when this job or item was created (in unix epochs)."
11691171
},
11701172
"data": {

specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-07-01-preview/generated.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@
421421
},
422422
"created": {
423423
"type": "integer",
424-
"format": "int64",
424+
"format": "unixtime",
425425
"description": "A timestamp when this job or item was created (in unix epochs)."
426426
},
427427
"expires": {
@@ -492,7 +492,7 @@
492492
},
493493
"created": {
494494
"type": "integer",
495-
"format": "int32",
495+
"format": "unixtime",
496496
"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."
497497
},
498498
"choices": {
@@ -625,7 +625,8 @@
625625
},
626626
"content": {
627627
"type": "string",
628-
"description": "The text associated with this message payload."
628+
"description": "The text associated with this message payload.",
629+
"x-nullable": true
629630
},
630631
"name": {
631632
"type": "string",
@@ -638,7 +639,8 @@
638639
}
639640
},
640641
"required": [
641-
"role"
642+
"role",
643+
"content"
642644
]
643645
},
644646
"ChatRole": {
@@ -729,7 +731,7 @@
729731
},
730732
"created": {
731733
"type": "integer",
732-
"format": "int32",
734+
"format": "unixtime",
733735
"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."
734736
},
735737
"prompt_annotations": {
@@ -1235,7 +1237,7 @@
12351237
"properties": {
12361238
"created": {
12371239
"type": "integer",
1238-
"format": "int64",
1240+
"format": "unixtime",
12391241
"description": "A timestamp when this job or item was created (in unix epochs)."
12401242
},
12411243
"data": {

specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2022-12-01/generated.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
},
272272
"created": {
273273
"type": "integer",
274-
"format": "int32",
274+
"format": "unixtime",
275275
"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."
276276
},
277277
"choices": {

specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2023-05-15/generated.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@
314314
},
315315
"created": {
316316
"type": "integer",
317-
"format": "int32",
317+
"format": "unixtime",
318318
"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."
319319
},
320320
"choices": {
@@ -426,11 +426,13 @@
426426
},
427427
"content": {
428428
"type": "string",
429-
"description": "The text associated with this message payload."
429+
"description": "The text associated with this message payload.",
430+
"x-nullable": true
430431
}
431432
},
432433
"required": [
433-
"role"
434+
"role",
435+
"content"
434436
]
435437
},
436438
"ChatRole": {
@@ -510,7 +512,7 @@
510512
},
511513
"created": {
512514
"type": "integer",
513-
"format": "int32",
515+
"format": "unixtime",
514516
"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."
515517
},
516518
"choices": {

0 commit comments

Comments
 (0)