Skip to content

Commit 9aec843

Browse files
authored
Fixing enum to have the proper values + reenabling csharp generation. (#24538)
1 parent c7f3e60 commit 9aec843

File tree

9 files changed

+298
-13
lines changed

9 files changed

+298
-13
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import "./completions.common.tsp";
55
using TypeSpec.Rest;
66
using TypeSpec.Http;
77

8+
namespace Azure.OpenAI;
9+
810
@doc("A description of the intended purpose of a message within a chat completions interaction.")
911
enum ChatRole {
1012
@doc("The role that instructs or sets the behavior of the assistant.")

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
namespace Azure.OpenAI;
2+
13
@doc("""
24
Representation of the token counts processed for a completions request.
35
Counts consider all tokens across prompts, choices, choice alternates, best_of generations, and
@@ -22,17 +24,14 @@ Representation of the manner in which a completions response concluded.
2224
""")
2325
enum CompletionsFinishReason {
2426
@doc("Completions ended normally and reached its end of token generation.")
25-
@projectedName("json", "stop")
26-
stopped,
27+
stopped: "stop",
2728

2829
@doc("Completions exhausted available token limits before generation could complete.")
29-
@projectedName("json", "length")
30-
tokenLimitReached,
30+
tokenLimitReached: "length",
3131

3232
@doc("""
3333
Completions generated a response that was identified as potentially sensitive per content
3434
moderation policies.
3535
""")
36-
@projectedName("json", "content_filter")
37-
contentFiltered,
36+
contentFiltered: "content_filter",
3837
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import "./completions.common.tsp";
55
using TypeSpec.Rest;
66
using TypeSpec.Http;
77

8+
namespace Azure.OpenAI;
9+
810
@doc("""
911
The configuration information for a completions request.
1012
Completions support a wide variety of tasks and generate text that continues from or "completes"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import "@typespec/http";
44
using TypeSpec.Rest;
55
using TypeSpec.Http;
66

7+
namespace Azure.OpenAI;
8+
79
@doc("""
810
The configuration information for an embeddings request.
911
Embeddings measure the relatedness of text strings and are commonly used for search, clustering,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ op OaiLongRunningRpcOperation<
126126
Azure.Core.Traits.TraitLocation.Parameters
127127
>,
128128
Azure.Core.Foundations.AcceptedResponse &
129-
ImageOperationResponse &
129+
TResponse &
130130
Foundations.LongRunningStatusLocation<TStatusResult> &
131131
Azure.Core.Traits.Private.TraitProperties<
132132
Traits,

specification/cognitiveservices/OpenAI.Inference/tspconfig.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ options:
2020
# Uncomment this line and add "@azure-tools/cadl-java" to your package.json to generate Java code
2121
# "@azure-tools/cadl-java": true
2222
# Uncomment this line and add "@azure-tools/cadl-csharp" to your package.json to generate C# code
23-
# https://github.com/Azure/azure-rest-api-specs/issues/24496
24-
# "@azure-tools/typespec-csharp":
25-
# package-dir: "Azure.AI.OpenAI"
26-
# namespace: "Azure.AI.OpenAI"
27-
# clear-output-folder: true
28-
# model-namespace: false
23+
"@azure-tools/typespec-csharp":
24+
package-dir: "Azure.AI.OpenAI"
25+
namespace: "Azure.AI.OpenAI"
26+
clear-output-folder: true
27+
model-namespace: false
2928
# https://github.com/Azure/azure-rest-api-specs/issues/24497
3029
# "@azure-tools/typespec-java":
3130
# package-dir: "azure-ai-openai"

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,36 @@
632632
"usage"
633633
]
634634
},
635+
"CompletionsFinishReason": {
636+
"type": "string",
637+
"description": "Representation of the manner in which a completions response concluded.",
638+
"enum": [
639+
"stop",
640+
"length",
641+
"content_filter"
642+
],
643+
"x-ms-enum": {
644+
"name": "CompletionsFinishReason",
645+
"modelAsString": true,
646+
"values": [
647+
{
648+
"name": "stopped",
649+
"value": "stop",
650+
"description": "Completions ended normally and reached its end of token generation."
651+
},
652+
{
653+
"name": "tokenLimitReached",
654+
"value": "length",
655+
"description": "Completions exhausted available token limits before generation could complete."
656+
},
657+
{
658+
"name": "contentFiltered",
659+
"value": "content_filter",
660+
"description": "Completions generated a response that was identified as potentially sensitive per content\nmoderation policies."
661+
}
662+
]
663+
}
664+
},
635665
"CompletionsLogProbabilityModel": {
636666
"type": "object",
637667
"properties": {

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

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,197 @@
225225
},
226226
"description": "An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses."
227227
},
228+
"ChatChoice": {
229+
"type": "object",
230+
"properties": {
231+
"message": {
232+
"$ref": "#/definitions/ChatMessage",
233+
"description": "The chat message for a given chat completions prompt."
234+
},
235+
"index": {
236+
"type": "integer",
237+
"format": "int32",
238+
"description": "The ordered index associated with this chat completions choice."
239+
},
240+
"finish_reason": {
241+
"x-typespec-name": "CompletionsFinishReason | null",
242+
"description": "The reason that this chat completions choice completed its generated.",
243+
"x-ms-client-name": "finishReason"
244+
},
245+
"delta": {
246+
"$ref": "#/definitions/ChatMessage",
247+
"description": "The delta message content for a streaming response."
248+
}
249+
},
250+
"description": "The representation of a single prompt completion as part of an overall chat completions request.\nGenerally, `n` choices are generated per provided prompt with a default value of 1.\nToken limits and other settings may limit the number of choices generated.",
251+
"required": [
252+
"index",
253+
"finish_reason"
254+
]
255+
},
256+
"ChatCompletions": {
257+
"type": "object",
258+
"properties": {
259+
"id": {
260+
"type": "string",
261+
"description": "A unique identifier associated with this chat completions response."
262+
},
263+
"created": {
264+
"type": "integer",
265+
"format": "int32",
266+
"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."
267+
},
268+
"choices": {
269+
"type": "array",
270+
"items": {
271+
"$ref": "#/definitions/ChatChoice"
272+
},
273+
"x-ms-identifiers": [],
274+
"description": "The collection of completions choices associated with this completions response.\nGenerally, `n` choices are generated per provided prompt with a default value of 1.\nToken limits and other settings may limit the number of choices generated.",
275+
"x-typespec-name": "ChatChoice[]"
276+
},
277+
"usage": {
278+
"$ref": "#/definitions/CompletionsUsage",
279+
"description": "Usage information for tokens processed and generated as part of this completions operation."
280+
}
281+
},
282+
"description": "Representation of the response data from a chat completions request.\nCompletions support a wide variety of tasks and generate text that continues from or \"completes\"\nprovided prompt data.",
283+
"required": [
284+
"id",
285+
"created",
286+
"choices",
287+
"usage"
288+
]
289+
},
290+
"ChatCompletionsOptions": {
291+
"type": "object",
292+
"properties": {
293+
"messages": {
294+
"type": "array",
295+
"items": {
296+
"$ref": "#/definitions/ChatMessage"
297+
},
298+
"x-ms-identifiers": [],
299+
"description": "The collection of context messages associated with this chat completions request.\nTypical usage begins with a chat message for the System role that provides instructions for\nthe behavior of the assistant, followed by alternating messages between the User and\nAssistant roles.",
300+
"x-typespec-name": "ChatMessage[]"
301+
},
302+
"max_tokens": {
303+
"type": "integer",
304+
"format": "int32",
305+
"description": "The maximum number of tokens to generate.",
306+
"x-ms-client-name": "maxTokens"
307+
},
308+
"temperature": {
309+
"type": "number",
310+
"format": "float",
311+
"description": "The sampling temperature to use that controls the apparent creativity of generated completions.\nHigher values will make output more random while lower values will make results more focused\nand deterministic.\nIt is not recommended to modify temperature and top_p for the same completions request as the\ninteraction of these two settings is difficult to predict."
312+
},
313+
"top_p": {
314+
"type": "number",
315+
"format": "float",
316+
"description": "An alternative to sampling with temperature called nucleus sampling. This value causes the\nmodel to consider the results of tokens with the provided probability mass. As an example, a\nvalue of 0.15 will cause only the tokens comprising the top 15% of probability mass to be\nconsidered.\nIt is not recommended to modify temperature and top_p for the same completions request as the\ninteraction of these two settings is difficult to predict.",
317+
"x-ms-client-name": "topP"
318+
},
319+
"logit_bias": {
320+
"type": "object",
321+
"additionalProperties": {
322+
"type": "integer",
323+
"format": "int32"
324+
},
325+
"description": "A map between GPT token IDs and bias scores that influences the probability of specific tokens\nappearing in a completions response. Token IDs are computed via external tokenizer tools, while\nbias scores reside in the range of -100 to 100 with minimum and maximum values corresponding to\na full ban or exclusive selection of a token, respectively. The exact behavior of a given bias\nscore varies by model.",
326+
"x-typespec-name": "Record<int32>",
327+
"x-ms-client-name": "logitBias"
328+
},
329+
"user": {
330+
"type": "string",
331+
"description": "An identifier for the caller or end user of the operation. This may be used for tracking\nor rate-limiting purposes."
332+
},
333+
"n": {
334+
"type": "integer",
335+
"format": "int32",
336+
"description": "The number of chat completions choices that should be generated for a chat completions\nresponse.\nBecause this setting can generate many completions, it may quickly consume your token quota.\nUse carefully and ensure reasonable settings for max_tokens and stop."
337+
},
338+
"stop": {
339+
"type": "array",
340+
"items": {
341+
"type": "string"
342+
},
343+
"description": "A collection of textual sequences that will end completions generation.",
344+
"x-typespec-name": "string[]"
345+
},
346+
"presence_penalty": {
347+
"type": "number",
348+
"format": "float",
349+
"description": "A value that influences the probability of generated tokens appearing based on their existing\npresence in generated text.\nPositive values will make tokens less likely to appear when they already exist and increase the\nmodel's likelihood to output new topics.",
350+
"x-ms-client-name": "presencePenalty"
351+
},
352+
"frequency_penalty": {
353+
"type": "number",
354+
"format": "float",
355+
"description": "A value that influences the probability of generated tokens appearing based on their cumulative\nfrequency in generated text.\nPositive values will make tokens less likely to appear as their frequency increases and\ndecrease the likelihood of the model repeating the same statements verbatim.",
356+
"x-ms-client-name": "frequencyPenalty"
357+
},
358+
"stream": {
359+
"type": "boolean",
360+
"description": "A value indicating whether chat completions should be streamed for this request."
361+
},
362+
"model": {
363+
"type": "string",
364+
"description": "The model name to provide as part of this completions request.\nNot applicable to Azure OpenAI, where deployment information should be included in the Azure\nresource URI that's connected to."
365+
}
366+
},
367+
"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.",
368+
"required": [
369+
"messages"
370+
]
371+
},
372+
"ChatMessage": {
373+
"type": "object",
374+
"properties": {
375+
"role": {
376+
"$ref": "#/definitions/ChatRole",
377+
"description": "The role associated with this message payload."
378+
},
379+
"content": {
380+
"type": "string",
381+
"description": "The text associated with this message payload."
382+
}
383+
},
384+
"description": "A single, role-attributed message within a chat completion interaction.",
385+
"required": [
386+
"role"
387+
]
388+
},
389+
"ChatRole": {
390+
"type": "string",
391+
"description": "A description of the intended purpose of a message within a chat completions interaction.",
392+
"enum": [
393+
"system",
394+
"assistant",
395+
"user"
396+
],
397+
"x-ms-enum": {
398+
"name": "ChatRole",
399+
"modelAsString": true,
400+
"values": [
401+
{
402+
"name": "system",
403+
"value": "system",
404+
"description": "The role that instructs or sets the behavior of the assistant."
405+
},
406+
{
407+
"name": "assistant",
408+
"value": "assistant",
409+
"description": "The role that provides responses to system-instructed, user-prompted input."
410+
},
411+
{
412+
"name": "user",
413+
"value": "user",
414+
"description": "The role that provides input for chat completions."
415+
}
416+
]
417+
}
418+
},
228419
"Choice": {
229420
"type": "object",
230421
"properties": {
@@ -296,6 +487,36 @@
296487
"usage"
297488
]
298489
},
490+
"CompletionsFinishReason": {
491+
"type": "string",
492+
"description": "Representation of the manner in which a completions response concluded.",
493+
"enum": [
494+
"stop",
495+
"length",
496+
"content_filter"
497+
],
498+
"x-ms-enum": {
499+
"name": "CompletionsFinishReason",
500+
"modelAsString": true,
501+
"values": [
502+
{
503+
"name": "stopped",
504+
"value": "stop",
505+
"description": "Completions ended normally and reached its end of token generation."
506+
},
507+
{
508+
"name": "tokenLimitReached",
509+
"value": "length",
510+
"description": "Completions exhausted available token limits before generation could complete."
511+
},
512+
{
513+
"name": "contentFiltered",
514+
"value": "content_filter",
515+
"description": "Completions generated a response that was identified as potentially sensitive per content\nmoderation policies."
516+
}
517+
]
518+
}
519+
},
299520
"CompletionsLogProbabilityModel": {
300521
"type": "object",
301522
"properties": {

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,36 @@
538538
"usage"
539539
]
540540
},
541+
"CompletionsFinishReason": {
542+
"type": "string",
543+
"description": "Representation of the manner in which a completions response concluded.",
544+
"enum": [
545+
"stop",
546+
"length",
547+
"content_filter"
548+
],
549+
"x-ms-enum": {
550+
"name": "CompletionsFinishReason",
551+
"modelAsString": true,
552+
"values": [
553+
{
554+
"name": "stopped",
555+
"value": "stop",
556+
"description": "Completions ended normally and reached its end of token generation."
557+
},
558+
{
559+
"name": "tokenLimitReached",
560+
"value": "length",
561+
"description": "Completions exhausted available token limits before generation could complete."
562+
},
563+
{
564+
"name": "contentFiltered",
565+
"value": "content_filter",
566+
"description": "Completions generated a response that was identified as potentially sensitive per content\nmoderation policies."
567+
}
568+
]
569+
}
570+
},
541571
"CompletionsLogProbabilityModel": {
542572
"type": "object",
543573
"properties": {

0 commit comments

Comments
 (0)