From 51fb73b3715884e4a27583570ff8aff4b936ef20 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 31 May 2024 15:08:31 -0700 Subject: [PATCH 01/48] Update ImageEmbeddingsClient to change embed to embedImage Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index 79e770265da7..d7f7b3be540f 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -80,6 +80,6 @@ interface Client2 { service: ModelClient, }) interface Client3 { - embed is ModelClient.getImageEmbeddings; + embedImage is ModelClient.getImageEmbeddings; getModelInfo is ModelClient.getModelInfo; } From fd54bf93fdc2af23719eafa25bdf6b244840587c Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 31 May 2024 16:25:07 -0700 Subject: [PATCH 02/48] Add typespec-csharp to the tspconfig Signed-off-by: Travis Angevine --- specification/ai/ModelClient/tspconfig.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/specification/ai/ModelClient/tspconfig.yaml b/specification/ai/ModelClient/tspconfig.yaml index 8c7c4d75c64e..e7527a1df9b3 100644 --- a/specification/ai/ModelClient/tspconfig.yaml +++ b/specification/ai/ModelClient/tspconfig.yaml @@ -22,3 +22,10 @@ options: package-dir: "azure-ai-inference" package-name: "{package-dir}" flavor: azure + "@azure-tools/typespec-csharp": + package-dir: "Azure.AI.Inference" + namespace: "Azure.AI.Inference" + clear-output-folder: true + model-namespace: false + generate-protocol-methods: false + flavor: azure \ No newline at end of file From 08c7c64963eff669a1e29456ba8ab5a7c90e504c Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Wed, 5 Jun 2024 14:37:38 -0700 Subject: [PATCH 03/48] Move csharp client property renames Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index b6996c54f3d5..30e0fb2196d9 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -85,3 +85,10 @@ interface Client3 { embedImage is ModelClient.getImageEmbeddings; getModelInfo is ModelClient.getModelInfo; } + +// The following is to update names as necessary for specific programming languages. +// Done in this file to provide a single point of reference for any renames. +@@clientName(Azure.OpenAI.ChatCompletionOptions.top_p, "NucleusSamplingFactor", "csharp") +@@clientName(Azure.OpenAI.ChatCompletionOptions.stop, "StopSequences", "csharp") +@@clientName(Azure.OpenAI.ChatCompletionOptions.stream, "InternalShouldStreamResponse", "csharp") +@@clientName(Azure.OpenAI.ChatChoice.delta, "InternalStreamingDeltaMessage", "csharp") From ab6c309feac93178fbabdf70347304190094b4cb Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Wed, 5 Jun 2024 15:14:23 -0700 Subject: [PATCH 04/48] Missing semicolons Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index 30e0fb2196d9..d9d78e451138 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -88,7 +88,7 @@ interface Client3 { // The following is to update names as necessary for specific programming languages. // Done in this file to provide a single point of reference for any renames. -@@clientName(Azure.OpenAI.ChatCompletionOptions.top_p, "NucleusSamplingFactor", "csharp") -@@clientName(Azure.OpenAI.ChatCompletionOptions.stop, "StopSequences", "csharp") -@@clientName(Azure.OpenAI.ChatCompletionOptions.stream, "InternalShouldStreamResponse", "csharp") -@@clientName(Azure.OpenAI.ChatChoice.delta, "InternalStreamingDeltaMessage", "csharp") +@@clientName(Azure.OpenAI.ChatCompletionOptions.top_p, "NucleusSamplingFactor", "csharp"); +@@clientName(Azure.OpenAI.ChatCompletionOptions.stop, "StopSequences", "csharp"); +@@clientName(Azure.OpenAI.ChatCompletionOptions.stream, "InternalShouldStreamResponse", "csharp"); +@@clientName(Azure.OpenAI.ChatChoice.delta, "InternalStreamingDeltaMessage", "csharp"); From 4f8a7ea1399ad330113333ed5eb56a45e4483b0e Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Wed, 5 Jun 2024 15:17:01 -0700 Subject: [PATCH 05/48] Wrong namespace Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index d9d78e451138..9a48661191ed 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -88,7 +88,7 @@ interface Client3 { // The following is to update names as necessary for specific programming languages. // Done in this file to provide a single point of reference for any renames. -@@clientName(Azure.OpenAI.ChatCompletionOptions.top_p, "NucleusSamplingFactor", "csharp"); -@@clientName(Azure.OpenAI.ChatCompletionOptions.stop, "StopSequences", "csharp"); -@@clientName(Azure.OpenAI.ChatCompletionOptions.stream, "InternalShouldStreamResponse", "csharp"); -@@clientName(Azure.OpenAI.ChatChoice.delta, "InternalStreamingDeltaMessage", "csharp"); +@@clientName(ModelClient.ChatCompletionOptions.top_p, "NucleusSamplingFactor", "csharp"); +@@clientName(ModelClient.ChatCompletionOptions.stop, "StopSequences", "csharp"); +@@clientName(ModelClient.ChatCompletionOptions.stream, "InternalShouldStreamResponse", "csharp"); +@@clientName(ModelClient.ChatChoice.delta, "InternalStreamingDeltaMessage", "csharp"); From be84fda2eff85988f3b3e9448847b8956f9ac42e Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Wed, 5 Jun 2024 15:24:42 -0700 Subject: [PATCH 06/48] Incorrect namespaces Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index 9a48661191ed..3b9319a2a4bf 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -88,7 +88,7 @@ interface Client3 { // The following is to update names as necessary for specific programming languages. // Done in this file to provide a single point of reference for any renames. -@@clientName(ModelClient.ChatCompletionOptions.top_p, "NucleusSamplingFactor", "csharp"); -@@clientName(ModelClient.ChatCompletionOptions.stop, "StopSequences", "csharp"); -@@clientName(ModelClient.ChatCompletionOptions.stream, "InternalShouldStreamResponse", "csharp"); -@@clientName(ModelClient.ChatChoice.delta, "InternalStreamingDeltaMessage", "csharp"); +@@clientName(ModelClient.ChatCompletionsOptions.top_p, "NucleusSamplingFactor", "csharp"); +@@clientName(ModelClient.ChatCompletionsOptions.stop, "StopSequences", "csharp"); +@@clientName(ModelClient.ChatCompletionsOptions.stream, "InternalShouldStreamResponse", "csharp"); +@@clientName(ModelClient.StreamingChatChoiceUpdate.delta, "InternalStreamingDeltaMessage", "csharp"); From 4f56fb385fca59c6ddbd379c307dffdab8c0f4f2 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Wed, 5 Jun 2024 15:29:20 -0700 Subject: [PATCH 07/48] Aliases need to have things referenced differently, apparently Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index 3b9319a2a4bf..a6e7d2106218 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -88,7 +88,7 @@ interface Client3 { // The following is to update names as necessary for specific programming languages. // Done in this file to provide a single point of reference for any renames. -@@clientName(ModelClient.ChatCompletionsOptions.top_p, "NucleusSamplingFactor", "csharp"); -@@clientName(ModelClient.ChatCompletionsOptions.stop, "StopSequences", "csharp"); -@@clientName(ModelClient.ChatCompletionsOptions.stream, "InternalShouldStreamResponse", "csharp"); +@@clientName(ModelClient.ChatCompletionsOptions::top_p, "NucleusSamplingFactor", "csharp"); +@@clientName(ModelClient.ChatCompletionsOptions::stop, "StopSequences", "csharp"); +@@clientName(ModelClient.ChatCompletionsOptions::stream, "InternalShouldStreamResponse", "csharp"); @@clientName(ModelClient.StreamingChatChoiceUpdate.delta, "InternalStreamingDeltaMessage", "csharp"); From db6580b6d8386863ac05acf59da99478f685f1f2 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Wed, 5 Jun 2024 15:41:11 -0700 Subject: [PATCH 08/48] Need to specify parameters? Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index a6e7d2106218..70f9e1abbfe7 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -88,7 +88,7 @@ interface Client3 { // The following is to update names as necessary for specific programming languages. // Done in this file to provide a single point of reference for any renames. -@@clientName(ModelClient.ChatCompletionsOptions::top_p, "NucleusSamplingFactor", "csharp"); -@@clientName(ModelClient.ChatCompletionsOptions::stop, "StopSequences", "csharp"); -@@clientName(ModelClient.ChatCompletionsOptions::stream, "InternalShouldStreamResponse", "csharp"); +@@clientName(ModelClient.ChatCompletionsOptions::parameters.top_p, "NucleusSamplingFactor", "csharp"); +@@clientName(ModelClient.ChatCompletionsOptions::parameters.stop, "StopSequences", "csharp"); +@@clientName(ModelClient.ChatCompletionsOptions::parameters.stream, "InternalShouldStreamResponse", "csharp"); @@clientName(ModelClient.StreamingChatChoiceUpdate.delta, "InternalStreamingDeltaMessage", "csharp"); From a5b3fbc98296382bfe5a3d32797062a9d3c88a09 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Wed, 5 Jun 2024 16:00:47 -0700 Subject: [PATCH 09/48] Move alias renames to the individual file for now Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 3 --- specification/ai/ModelClient/models/chat_completions.tsp | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index 70f9e1abbfe7..87148cd45467 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -88,7 +88,4 @@ interface Client3 { // The following is to update names as necessary for specific programming languages. // Done in this file to provide a single point of reference for any renames. -@@clientName(ModelClient.ChatCompletionsOptions::parameters.top_p, "NucleusSamplingFactor", "csharp"); -@@clientName(ModelClient.ChatCompletionsOptions::parameters.stop, "StopSequences", "csharp"); -@@clientName(ModelClient.ChatCompletionsOptions::parameters.stream, "InternalShouldStreamResponse", "csharp"); @@clientName(ModelClient.StreamingChatChoiceUpdate.delta, "InternalStreamingDeltaMessage", "csharp"); diff --git a/specification/ai/ModelClient/models/chat_completions.tsp b/specification/ai/ModelClient/models/chat_completions.tsp index 95e6db57ac07..3f0818d43be8 100644 --- a/specification/ai/ModelClient/models/chat_completions.tsp +++ b/specification/ai/ModelClient/models/chat_completions.tsp @@ -33,6 +33,7 @@ alias ChatCompletionsOptions = { @doc(""" A value indicating whether chat completions should be streamed for this request. """) + @clientName("InternalShouldStreamResponse", "csharp") stream?: boolean; @doc(""" @@ -69,6 +70,7 @@ alias ChatCompletionsOptions = { """) @maxValue(1.0) @minValue(0.0) + @clientName("NucleusSamplingFactor", "csharp") top_p?: float32 = 1.0; @doc("The maximum number of tokens to generate.") @@ -82,6 +84,7 @@ alias ChatCompletionsOptions = { A collection of textual sequences that will end completions generation. """) @minItems(1) + @clientName("StopSequences", "csharp") stop?: string[]; @doc("The available tool definitions that the chat completions request can use, including caller-defined functions.") From 1c552f36abed39d0e2a4b744fb59f668a7706129 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Thu, 20 Jun 2024 13:49:47 -0700 Subject: [PATCH 10/48] Change ChatCompletionsOptions to a model Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/chat_completions.tsp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/models/chat_completions.tsp b/specification/ai/ModelClient/models/chat_completions.tsp index fb35be83aa62..20e6bd6b71a2 100644 --- a/specification/ai/ModelClient/models/chat_completions.tsp +++ b/specification/ai/ModelClient/models/chat_completions.tsp @@ -9,7 +9,12 @@ using Azure.ClientGenerator.Core; namespace ModelClient; -alias ChatCompletionsOptions = { +@doc(""" +The configuration information for a chat completions request. +Completions support a wide variety of tasks and generate text that continues from or "completes" +provided prompt data. +""") +model ChatCompletionsOptions = { @doc(""" The collection of context messages associated with this chat completions request. Typical usage begins with a chat message for the System role that provides instructions for From 8e420b994d3f16a0a2bfc4fc6d7945c9f57dc30b Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Thu, 20 Jun 2024 13:52:44 -0700 Subject: [PATCH 11/48] syntax Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/chat_completions.tsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/ai/ModelClient/models/chat_completions.tsp b/specification/ai/ModelClient/models/chat_completions.tsp index 20e6bd6b71a2..bfe138c18662 100644 --- a/specification/ai/ModelClient/models/chat_completions.tsp +++ b/specification/ai/ModelClient/models/chat_completions.tsp @@ -14,7 +14,7 @@ The configuration information for a chat completions request. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data. """) -model ChatCompletionsOptions = { +model ChatCompletionsOptions { @doc(""" The collection of context messages associated with this chat completions request. Typical usage begins with a chat message for the System role that provides instructions for @@ -107,7 +107,7 @@ model ChatCompletionsOptions = { same seed and parameters should return the same result. Determinism is not guaranteed." """) seed?: int64; -}; +} alias ChatCompletionsCommon = { @doc("A unique identifier associated with this chat completions response.") From 8c122c58036255691dd7e8cb4c8ffcf7bdf56edb Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 21 Jun 2024 16:27:18 -0700 Subject: [PATCH 12/48] Leave the model property Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/chat_completions.tsp | 1 - 1 file changed, 1 deletion(-) diff --git a/specification/ai/ModelClient/models/chat_completions.tsp b/specification/ai/ModelClient/models/chat_completions.tsp index 2863942b014e..6a21fc17aa51 100644 --- a/specification/ai/ModelClient/models/chat_completions.tsp +++ b/specification/ai/ModelClient/models/chat_completions.tsp @@ -111,7 +111,6 @@ model ChatCompletionsOptions { @doc(""" ID of the specific AI model to use, if more than one model is available on the endpoint. """) - @clientName("DeploymentName", "csharp") `model`?: string; } From e6e24a1739919ebbb1a0b1c72994958f56a82f5d Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Thu, 27 Jun 2024 10:35:43 -0700 Subject: [PATCH 13/48] Add additional properties for ChatCompletionsOptions Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/chat_completions.tsp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/specification/ai/ModelClient/models/chat_completions.tsp b/specification/ai/ModelClient/models/chat_completions.tsp index 6a21fc17aa51..bf3d811627a3 100644 --- a/specification/ai/ModelClient/models/chat_completions.tsp +++ b/specification/ai/ModelClient/models/chat_completions.tsp @@ -112,6 +112,14 @@ model ChatCompletionsOptions { ID of the specific AI model to use, if more than one model is available on the endpoint. """) `model`?: string; + + @doc(""" + Additional, model-specific parameters that are not in the + standard request payload. They will be added as-is to the root of the JSON in the request body. + How the service handles these extra parameters depends on the value of the + ``unknown-parameters`` request header. Default value is None. + """) + ..Record; } alias ChatCompletionsCommon = { From c33085fe51cbc4a73f60899b0ce2229eed77bbea Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Thu, 27 Jun 2024 10:38:57 -0700 Subject: [PATCH 14/48] 3 dots, not 2 Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/chat_completions.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/models/chat_completions.tsp b/specification/ai/ModelClient/models/chat_completions.tsp index bf3d811627a3..c3a5fccbb2a5 100644 --- a/specification/ai/ModelClient/models/chat_completions.tsp +++ b/specification/ai/ModelClient/models/chat_completions.tsp @@ -119,7 +119,7 @@ model ChatCompletionsOptions { How the service handles these extra parameters depends on the value of the ``unknown-parameters`` request header. Default value is None. """) - ..Record; + ...Record; } alias ChatCompletionsCommon = { From bc2ead48f5d3e6bf6860694833a31a4dea5dd791 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Thu, 27 Jun 2024 11:07:15 -0700 Subject: [PATCH 15/48] Can't add docstring to generic spread property Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/chat_completions.tsp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/specification/ai/ModelClient/models/chat_completions.tsp b/specification/ai/ModelClient/models/chat_completions.tsp index c3a5fccbb2a5..e4b7a2b902f4 100644 --- a/specification/ai/ModelClient/models/chat_completions.tsp +++ b/specification/ai/ModelClient/models/chat_completions.tsp @@ -113,12 +113,6 @@ model ChatCompletionsOptions { """) `model`?: string; - @doc(""" - Additional, model-specific parameters that are not in the - standard request payload. They will be added as-is to the root of the JSON in the request body. - How the service handles these extra parameters depends on the value of the - ``unknown-parameters`` request header. Default value is None. - """) ...Record; } From cea8c463144bbcfddd843df17498d3ec4b0c0791 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Tue, 2 Jul 2024 09:17:50 -0700 Subject: [PATCH 16/48] Change unknown parameters to extra parameters Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/common.tsp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/specification/ai/ModelClient/models/common.tsp b/specification/ai/ModelClient/models/common.tsp index b38347a08845..8548ced51301 100644 --- a/specification/ai/ModelClient/models/common.tsp +++ b/specification/ai/ModelClient/models/common.tsp @@ -132,23 +132,23 @@ union ModelType { alias AdditionalRequestHeaders = { @doc(""" - Controls what happens if unknown parameters are passed in the JSON request payload. - This sets the HTTP request header `unknown-parameters`. + Controls what happens if extra parameters are passed in the JSON request payload. + This sets the HTTP request header `extra-parameters`. """) - @header("unknown-parameters") - unknown_params?: UnknownParams; + @header("extra-parameters") + extra_params?: ExtraParams; }; -@doc("Controls what happens if unknown parameters are passed in the JSON request payload.") -union UnknownParams { +@doc("Controls what happens if extra parameters are passed in the JSON request payload.") +union ExtraParams { string, - @doc("The service will error if it detected unknown parameters in the request payload. This is the service default.") + @doc("The service will error if it detected extra parameters in the request payload. This is the service default.") error: "error", - @doc("The service will ignore (drop) unknown parameters in the request payload. It will only pass the known parameters to the back-end AI model.") + @doc("The service will ignore (drop) extra parameters in the request payload. It will only pass the known parameters to the back-end AI model.") drop: "drop", - @doc("The service will pass unknown parameters to the back-end AI model.") + @doc("The service will pass extra parameters to the back-end AI model.") pass_through: "pass_through", } From 69c429fb901e091182aa5ee0c1a1f1b074c4f06b Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Tue, 9 Jul 2024 13:12:02 -0700 Subject: [PATCH 17/48] Remove unnecessary rename Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index 7b24aeed6fe8..7254da42efb3 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -118,7 +118,3 @@ interface Client3 { embed is AI.Model.getImageEmbeddings; getModelInfo is AI.Model.getModelInfo; } - -// The following is to update names as necessary for specific programming languages. -// Done in this file to provide a single point of reference for any renames. -@@clientName(ModelClient.StreamingChatChoiceUpdate.delta, "InternalStreamingDeltaMessage", "csharp"); From 9353cd8bfa0a6666995fe08ffbab007f91422f40 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Thu, 11 Jul 2024 10:32:23 -0700 Subject: [PATCH 18/48] Removing api-key change for python, for now Signed-off-by: Travis Angevine --- specification/ai/ModelClient/main.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/main.tsp b/specification/ai/ModelClient/main.tsp index d3958a8697c1..396f471b7171 100644 --- a/specification/ai/ModelClient/main.tsp +++ b/specification/ai/ModelClient/main.tsp @@ -10,7 +10,7 @@ using Azure.Core; #suppress "@azure-tools/typespec-autorest/unsupported-http-auth-scheme" @useAuth( - BearerAuth | ApiKeyAuth | OAuth2Auth<[ + BearerAuth | OAuth2Auth<[ { type: OAuth2FlowType.implicit, authorizationUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize", From acd2c9ae2b6fe3518b3cb37798d2feb514a990eb Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Tue, 23 Jul 2024 15:08:18 -0700 Subject: [PATCH 19/48] Make operator method internal Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index b67978d9ecbe..9125c05d514e 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -58,7 +58,7 @@ namespace Customizations; // The actual name here doesn't matter and is here for // 1. Add chat completions streaming (to getChatCompletions operator) // 2. Add hyper-params (to getChatCompletions/Embeddings/ImageEmbeddings, all clients) // 3. Cache model info (to getModelInfo, all clients, Python only) -@@access(AI.Model.getChatCompletions, Access.internal, "python"); +@@access(AI.Model.getChatCompletions, Access.internal); @@access(AI.Model.getEmbeddings, Access.internal); @@access(AI.Model.getImageEmbeddings, Access.internal); @@access(AI.Model.getModelInfo, Access.internal, "python"); From 7e90c46e0e94ecc7852cf1c8cc941f9906c59d0b Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Thu, 25 Jul 2024 16:38:25 -0700 Subject: [PATCH 20/48] Fix pass-through header Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/common.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/models/common.tsp b/specification/ai/ModelClient/models/common.tsp index 97d76628688d..c6e6a0b24f23 100644 --- a/specification/ai/ModelClient/models/common.tsp +++ b/specification/ai/ModelClient/models/common.tsp @@ -151,5 +151,5 @@ union ExtraParameters { drop: "drop", @doc("The service will pass extra parameters to the back-end AI model.") - pass_through: "pass_through", + pass_through: "pass-through", } From 6525a08a59edd52d0b9a670deff5fdb3e09dc105 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 26 Jul 2024 10:08:06 -0700 Subject: [PATCH 21/48] Re-enable protocol methods for csharp Signed-off-by: Travis Angevine --- specification/ai/ModelClient/tspconfig.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/specification/ai/ModelClient/tspconfig.yaml b/specification/ai/ModelClient/tspconfig.yaml index ce37a126573f..d8545016b4ed 100644 --- a/specification/ai/ModelClient/tspconfig.yaml +++ b/specification/ai/ModelClient/tspconfig.yaml @@ -28,5 +28,4 @@ options: namespace: "Azure.AI.Inference" clear-output-folder: true model-namespace: false - generate-protocol-methods: false flavor: azure \ No newline at end of file From c625ccb513a53bca685fe3e9522a9c78b78fcf7e Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 26 Jul 2024 13:45:16 -0700 Subject: [PATCH 22/48] Remove "spread" for ChatCompletionsOptions Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index 7b79bbfad9f8..099c85796f8c 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -25,7 +25,7 @@ namespace AI.Model; @route("chat/completions") op getChatCompletions is Azure.Core.RpcOperation< { - ...ChatCompletionsOptions; + ChatCompletionsOptions; ...AdditionalRequestHeaders; }, ChatCompletions From b3ff7cfc31c6b0a3d873e150af4e0b4c2c289b54 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 26 Jul 2024 13:47:06 -0700 Subject: [PATCH 23/48] Remove spread for additionalRequestHeaders Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index 099c85796f8c..4ca23fc8ffae 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -26,7 +26,7 @@ namespace AI.Model; op getChatCompletions is Azure.Core.RpcOperation< { ChatCompletionsOptions; - ...AdditionalRequestHeaders; + AdditionalRequestHeaders; }, ChatCompletions >; From 3cad35ae84bf87371383a55e5a0d46dc3e27db20 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 26 Jul 2024 13:54:43 -0700 Subject: [PATCH 24/48] needed commas Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index 4ca23fc8ffae..e074d258be24 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -25,8 +25,8 @@ namespace AI.Model; @route("chat/completions") op getChatCompletions is Azure.Core.RpcOperation< { - ChatCompletionsOptions; - AdditionalRequestHeaders; + ChatCompletionsOptions, + AdditionalRequestHeaders }, ChatCompletions >; From 4d8fe2cbb55d7ff3fd2c0942a727c870ea01487b Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 26 Jul 2024 14:07:34 -0700 Subject: [PATCH 25/48] another formatting attempt Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index e074d258be24..ed4a98970c09 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -25,8 +25,8 @@ namespace AI.Model; @route("chat/completions") op getChatCompletions is Azure.Core.RpcOperation< { - ChatCompletionsOptions, - AdditionalRequestHeaders + body: ChatCompletionsOptions, + ...AdditionalRequestHeaders }, ChatCompletions >; From 442e62ec6da735d3fd71402b941ea612f77b54d5 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 26 Jul 2024 14:25:34 -0700 Subject: [PATCH 26/48] okay, figured out how the formatting works Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index ed4a98970c09..2c1d0ae65e26 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -25,8 +25,8 @@ namespace AI.Model; @route("chat/completions") op getChatCompletions is Azure.Core.RpcOperation< { - body: ChatCompletionsOptions, - ...AdditionalRequestHeaders + chatCompletionsOptions: ChatCompletionsOptions, + extraParams: AdditionalRequestHeaders }, ChatCompletions >; From eba14dabb3bb775b80c7f87f88b72803eaf82562 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 26 Jul 2024 14:31:27 -0700 Subject: [PATCH 27/48] Alias breaks the generator Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/common.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/models/common.tsp b/specification/ai/ModelClient/models/common.tsp index c6e6a0b24f23..48dee68041bb 100644 --- a/specification/ai/ModelClient/models/common.tsp +++ b/specification/ai/ModelClient/models/common.tsp @@ -130,7 +130,7 @@ union ModelType { chat: "chat", } -alias AdditionalRequestHeaders = { +model AdditionalRequestHeaders = { @doc(""" Controls what happens if extra parameters, undefined by the REST API, are passed in the JSON request payload. From 4a3dfd2ac0ca91599e9bc74030e635b631d9520e Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 26 Jul 2024 14:38:59 -0700 Subject: [PATCH 28/48] A model won't give us the interaction pattern that we want. Trying this. Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/common.tsp | 4 ++-- specification/ai/ModelClient/routes.tsp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/specification/ai/ModelClient/models/common.tsp b/specification/ai/ModelClient/models/common.tsp index 48dee68041bb..3947f08b01e2 100644 --- a/specification/ai/ModelClient/models/common.tsp +++ b/specification/ai/ModelClient/models/common.tsp @@ -130,7 +130,7 @@ union ModelType { chat: "chat", } -model AdditionalRequestHeaders = { +alias AdditionalRequestHeaders = { @doc(""" Controls what happens if extra parameters, undefined by the REST API, are passed in the JSON request payload. @@ -138,7 +138,7 @@ model AdditionalRequestHeaders = { """) @header("extra-parameters") extra_params?: ExtraParameters; -}; +} @doc("Controls what happens if extra parameters, undefined by the REST ApI are passed in the JSON request payload.") union ExtraParameters { diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index 2c1d0ae65e26..1ebdf5f6e5e1 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -26,7 +26,8 @@ namespace AI.Model; op getChatCompletions is Azure.Core.RpcOperation< { chatCompletionsOptions: ChatCompletionsOptions, - extraParams: AdditionalRequestHeaders + @header("extra-parameters") + extraParams: ExtraParameters }, ChatCompletions >; From 392243f3532a97a0f88520e99997af0cb1214b7d Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 26 Jul 2024 14:40:36 -0700 Subject: [PATCH 29/48] Forgot semicolon Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/common.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/models/common.tsp b/specification/ai/ModelClient/models/common.tsp index 3947f08b01e2..c6e6a0b24f23 100644 --- a/specification/ai/ModelClient/models/common.tsp +++ b/specification/ai/ModelClient/models/common.tsp @@ -138,7 +138,7 @@ alias AdditionalRequestHeaders = { """) @header("extra-parameters") extra_params?: ExtraParameters; -} +}; @doc("Controls what happens if extra parameters, undefined by the REST ApI are passed in the JSON request payload.") union ExtraParameters { From 72ff5d0c95232077cb14077aa19418ac3be4c51c Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Mon, 29 Jul 2024 10:21:39 -0700 Subject: [PATCH 30/48] Does swapping the order of parameters matter? Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index 1ebdf5f6e5e1..43f7e6623496 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -25,9 +25,9 @@ namespace AI.Model; @route("chat/completions") op getChatCompletions is Azure.Core.RpcOperation< { - chatCompletionsOptions: ChatCompletionsOptions, @header("extra-parameters") - extraParams: ExtraParameters + extraParams: ExtraParameters, + chatCompletionsOptions: ChatCompletionsOptions }, ChatCompletions >; From 063b0518fe07a2bc9c86c1fc32080693682891f0 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Mon, 29 Jul 2024 10:31:39 -0700 Subject: [PATCH 31/48] Make extraParams optional? Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index 43f7e6623496..2b3589e8eb7d 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -25,9 +25,9 @@ namespace AI.Model; @route("chat/completions") op getChatCompletions is Azure.Core.RpcOperation< { + chatCompletionsOptions: ChatCompletionsOptions, @header("extra-parameters") - extraParams: ExtraParameters, - chatCompletionsOptions: ChatCompletionsOptions + extraParams?: ExtraParameters }, ChatCompletions >; From dd47e68edf1ff4fa61842a54815a88b29ef084ea Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Mon, 29 Jul 2024 13:15:21 -0700 Subject: [PATCH 32/48] Try and get rid of anonymous model Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index 2b3589e8eb7d..df5d35330b65 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -24,11 +24,7 @@ namespace AI.Model; @actionSeparator("/") @route("chat/completions") op getChatCompletions is Azure.Core.RpcOperation< - { - chatCompletionsOptions: ChatCompletionsOptions, - @header("extra-parameters") - extraParams?: ExtraParameters - }, + ChatCompletionsOptions & AdditionalRequestHeaders, ChatCompletions >; From 1f6224294f94d356afa456576f85aef37a4b165c Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Mon, 29 Jul 2024 13:49:57 -0700 Subject: [PATCH 33/48] Try adding RequestHeadersTrait Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index df5d35330b65..83114aca3158 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -24,8 +24,9 @@ namespace AI.Model; @actionSeparator("/") @route("chat/completions") op getChatCompletions is Azure.Core.RpcOperation< - ChatCompletionsOptions & AdditionalRequestHeaders, - ChatCompletions + ChatCompletionsOptions, + ChatCompletions, + RequestHeadersTrait >; @doc(""" From 7254471d0389b26504ced9de61025c3e8524b0cd Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Mon, 29 Jul 2024 14:09:23 -0700 Subject: [PATCH 34/48] Maybe needs to be an object? Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index 83114aca3158..a59a8475bd5d 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -26,7 +26,7 @@ namespace AI.Model; op getChatCompletions is Azure.Core.RpcOperation< ChatCompletionsOptions, ChatCompletions, - RequestHeadersTrait + {RequestHeadersTrait} >; @doc(""" From d752df67297da65db27bf12502914a2eb85666c4 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Mon, 29 Jul 2024 14:16:21 -0700 Subject: [PATCH 35/48] Add using Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index a59a8475bd5d..604830894dfc 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -12,6 +12,7 @@ using TypeSpec.Rest; using TypeSpec.Http; using TypeSpec.Versioning; using Azure.Core; +using Azure.Core.Traits; namespace AI.Model; @@ -26,7 +27,7 @@ namespace AI.Model; op getChatCompletions is Azure.Core.RpcOperation< ChatCompletionsOptions, ChatCompletions, - {RequestHeadersTrait} + RequestHeadersTrait >; @doc(""" From 4039eb161a839f14dd1daa1ef01bc7a475fea5ff Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Tue, 30 Jul 2024 09:24:21 -0700 Subject: [PATCH 36/48] Revert to "good" state Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index 604830894dfc..258eb23a0b6a 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -16,6 +16,9 @@ using Azure.Core.Traits; namespace AI.Model; +/* +Leaving this comment out for now as the "Goal" for how this should be formatted + @doc(""" Gets chat completions for the provided chat messages. Completions support a wide variety of tasks and generate text that continues from or "completes" @@ -29,6 +32,24 @@ op getChatCompletions is Azure.Core.RpcOperation< ChatCompletions, RequestHeadersTrait >; +*/ + +@doc(""" + Gets chat completions for the provided chat messages. + Completions support a wide variety of tasks and generate text that continues from or "completes" + provided prompt data. The method makes a REST API call to the `/chat/completions` route + on the given endpoint. + """) +@actionSeparator("/") +@route("chat/completions") +op getChatCompletions is Azure.Core.RpcOperation< + { + chatCompletionsOptions: ChatCompletionsOptions, + @header("extra-parameters") + extraParams?: ExtraParameters, + }, + ChatCompletions +>; @doc(""" Return the embedding vectors for given text prompts. From 7b1e6e1bd99fbeffe59220698279e78672f31c3a Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Tue, 13 Aug 2024 13:45:49 -0700 Subject: [PATCH 37/48] Try moving extra parameters. Change Parameters back to unknown Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/chat_completions.tsp | 4 +++- specification/ai/ModelClient/routes.tsp | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/specification/ai/ModelClient/models/chat_completions.tsp b/specification/ai/ModelClient/models/chat_completions.tsp index f1e2b60b6861..6b8acf2deb25 100644 --- a/specification/ai/ModelClient/models/chat_completions.tsp +++ b/specification/ai/ModelClient/models/chat_completions.tsp @@ -120,6 +120,8 @@ model ChatCompletionsOptions { """) `model`?: string; + ...AdditionalRequestHeaders; + ...Record; } @@ -462,7 +464,7 @@ model FunctionDefinition { #suppress "@azure-tools/typespec-azure-core/bad-record-type" @doc("The parameters the function accepts, described as a JSON Schema object.") - parameters?: Record; + parameters?: unknown; } @doc(""" diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index 258eb23a0b6a..db293a43659e 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -45,8 +45,6 @@ op getChatCompletions is Azure.Core.RpcOperation< op getChatCompletions is Azure.Core.RpcOperation< { chatCompletionsOptions: ChatCompletionsOptions, - @header("extra-parameters") - extraParams?: ExtraParameters, }, ChatCompletions >; From 65239b3df534592b7870cdc70a2d68fa771b5e04 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Tue, 13 Aug 2024 14:18:38 -0700 Subject: [PATCH 38/48] Skip the alias Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/chat_completions.tsp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/models/chat_completions.tsp b/specification/ai/ModelClient/models/chat_completions.tsp index 6b8acf2deb25..e3eaade0db2f 100644 --- a/specification/ai/ModelClient/models/chat_completions.tsp +++ b/specification/ai/ModelClient/models/chat_completions.tsp @@ -120,7 +120,13 @@ model ChatCompletionsOptions { """) `model`?: string; - ...AdditionalRequestHeaders; + @doc(""" + Controls what happens if extra parameters, undefined by the REST API, + are passed in the JSON request payload. + This sets the HTTP request header `extra-parameters`. + """) + @header("extra-parameters") + extra_params?: ExtraParameters; ...Record; } From 323366cf1c619b27bf222f6dc11d4684b4f08db5 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Tue, 13 Aug 2024 14:28:19 -0700 Subject: [PATCH 39/48] Is it the header which is causing issues? Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/chat_completions.tsp | 1 - 1 file changed, 1 deletion(-) diff --git a/specification/ai/ModelClient/models/chat_completions.tsp b/specification/ai/ModelClient/models/chat_completions.tsp index e3eaade0db2f..febe977e024d 100644 --- a/specification/ai/ModelClient/models/chat_completions.tsp +++ b/specification/ai/ModelClient/models/chat_completions.tsp @@ -125,7 +125,6 @@ model ChatCompletionsOptions { are passed in the JSON request payload. This sets the HTTP request header `extra-parameters`. """) - @header("extra-parameters") extra_params?: ExtraParameters; ...Record; From 1562993ffba6c65da6fef8d4e65474431aa48639 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Tue, 13 Aug 2024 14:36:31 -0700 Subject: [PATCH 40/48] Headers in the options object seems to not work Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/chat_completions.tsp | 7 ------- specification/ai/ModelClient/routes.tsp | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/specification/ai/ModelClient/models/chat_completions.tsp b/specification/ai/ModelClient/models/chat_completions.tsp index febe977e024d..738aabd2ed4a 100644 --- a/specification/ai/ModelClient/models/chat_completions.tsp +++ b/specification/ai/ModelClient/models/chat_completions.tsp @@ -120,13 +120,6 @@ model ChatCompletionsOptions { """) `model`?: string; - @doc(""" - Controls what happens if extra parameters, undefined by the REST API, - are passed in the JSON request payload. - This sets the HTTP request header `extra-parameters`. - """) - extra_params?: ExtraParameters; - ...Record; } diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index db293a43659e..258eb23a0b6a 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -45,6 +45,8 @@ op getChatCompletions is Azure.Core.RpcOperation< op getChatCompletions is Azure.Core.RpcOperation< { chatCompletionsOptions: ChatCompletionsOptions, + @header("extra-parameters") + extraParams?: ExtraParameters, }, ChatCompletions >; From bd9d3085e55f8a5187aa996e973dbfee60880b49 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Tue, 13 Aug 2024 14:40:32 -0700 Subject: [PATCH 41/48] Remove commented operation Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index 258eb23a0b6a..f44d84755d19 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -16,24 +16,6 @@ using Azure.Core.Traits; namespace AI.Model; -/* -Leaving this comment out for now as the "Goal" for how this should be formatted - -@doc(""" - Gets chat completions for the provided chat messages. - Completions support a wide variety of tasks and generate text that continues from or "completes" - provided prompt data. The method makes a REST API call to the `/chat/completions` route - on the given endpoint. - """) -@actionSeparator("/") -@route("chat/completions") -op getChatCompletions is Azure.Core.RpcOperation< - ChatCompletionsOptions, - ChatCompletions, - RequestHeadersTrait ->; -*/ - @doc(""" Gets chat completions for the provided chat messages. Completions support a wide variety of tasks and generate text that continues from or "completes" From 7e3d4fd604280e7fc2f82a8e89ed3d0a9b72ff46 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Tue, 13 Aug 2024 14:42:51 -0700 Subject: [PATCH 42/48] Unnecessary using Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 1 - 1 file changed, 1 deletion(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index f44d84755d19..499f67030a48 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -12,7 +12,6 @@ using TypeSpec.Rest; using TypeSpec.Http; using TypeSpec.Versioning; using Azure.Core; -using Azure.Core.Traits; namespace AI.Model; From 376a38832dc8103573519772b91d7c275d5ff912 Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 23 Aug 2024 16:22:27 -0700 Subject: [PATCH 43/48] Add embeddings for csharp Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index 7f3695046871..da4540aa379c 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -39,12 +39,12 @@ namespace Customizations; // The actual name here doesn't matter and is here for @@access(AI.Model.ChatRole, Access.public); @@access(AI.Model.CompletionsFinishReason, Access.public); @@access(AI.Model.CompletionsUsage, Access.public); -@@access(AI.Model.EmbeddingEncodingFormat, Access.public, "python"); -@@access(AI.Model.EmbeddingInput, Access.public, "python"); -@@access(AI.Model.EmbeddingInputType, Access.public, "python"); -@@access(AI.Model.EmbeddingItem, Access.public, "python"); -@@access(AI.Model.EmbeddingsResult, Access.public, "python"); -@@access(AI.Model.EmbeddingsUsage, Access.public, "python"); +@@access(AI.Model.EmbeddingEncodingFormat, Access.public, "python,csharp"); +@@access(AI.Model.EmbeddingInput, Access.public, "python,csharp"); +@@access(AI.Model.EmbeddingInputType, Access.public, "python,csharp"); +@@access(AI.Model.EmbeddingItem, Access.public, "python,csharp"); +@@access(AI.Model.EmbeddingsResult, Access.public, "python,csharp"); +@@access(AI.Model.EmbeddingsUsage, Access.public, "python,csharp"); @@access(AI.Model.FunctionCall, Access.public); @@access(AI.Model.FunctionDefinition, Access.public); @@access(AI.Model.ModelInfo, Access.public); @@ -102,7 +102,7 @@ interface Client1 { name: "EmbeddingsClient", service: AI.Model, }, - "python" + "python,csharp" ) interface Client2 { embed is AI.Model.getEmbeddings; @@ -114,7 +114,7 @@ interface Client2 { name: "ImageEmbeddingsClient", service: AI.Model, }, - "python" + "python,csharp" ) interface Client3 { embed is AI.Model.getImageEmbeddings; From 56e81a8fc9aed575b8e8ac2d26f3813f38b052bd Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Mon, 26 Aug 2024 14:58:58 -0700 Subject: [PATCH 44/48] Client changes for C# Signed-off-by: Travis Angevine --- specification/ai/ModelClient/routes.tsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/ai/ModelClient/routes.tsp b/specification/ai/ModelClient/routes.tsp index 0b1039902ae2..8081b156eeb1 100644 --- a/specification/ai/ModelClient/routes.tsp +++ b/specification/ai/ModelClient/routes.tsp @@ -40,7 +40,7 @@ op getChatCompletions is Azure.Core.RpcOperation< @route("embeddings") op getEmbeddings is Azure.Core.RpcOperation< { - ...EmbeddingsOptions; + embeddingsOptions: EmbeddingsOptions; ...AdditionalRequestHeaders; }, EmbeddingsResult @@ -54,7 +54,7 @@ op getEmbeddings is Azure.Core.RpcOperation< @route("images/embeddings") op getImageEmbeddings is Azure.Core.RpcOperation< { - ...ImageEmbeddingsOptions; + imageEmbeddingsOptions: ImageEmbeddingsOptions; ...AdditionalRequestHeaders; }, EmbeddingsResult From b1d22e9a271866b876eac94f4338dee45da98b4f Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Mon, 26 Aug 2024 15:05:25 -0700 Subject: [PATCH 45/48] Need the options objects to be models Signed-off-by: Travis Angevine --- specification/ai/ModelClient/models/embeddings.tsp | 5 ++++- specification/ai/ModelClient/models/image_embeddings.tsp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/specification/ai/ModelClient/models/embeddings.tsp b/specification/ai/ModelClient/models/embeddings.tsp index 8e2aa8e1751f..72a706ca3877 100644 --- a/specification/ai/ModelClient/models/embeddings.tsp +++ b/specification/ai/ModelClient/models/embeddings.tsp @@ -6,7 +6,10 @@ using TypeSpec.Http; namespace AI.Model; -alias EmbeddingsOptions = { +@doc(""" +The configuration information for an embeddings request. +""") +model EmbeddingsOptions { @doc(""" Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array diff --git a/specification/ai/ModelClient/models/image_embeddings.tsp b/specification/ai/ModelClient/models/image_embeddings.tsp index 6e2f407d5dbc..34640347ef7b 100644 --- a/specification/ai/ModelClient/models/image_embeddings.tsp +++ b/specification/ai/ModelClient/models/image_embeddings.tsp @@ -6,7 +6,10 @@ using TypeSpec.Http; namespace AI.Model; -alias ImageEmbeddingsOptions = { +@doc(""" +The configuration information for an image embeddings request. +""") +model ImageEmbeddingsOptions { @doc(""" Input image to embed. To embed multiple inputs in a single request, pass an array. The input must not exceed the max input tokens for the model. From fb263d75b270fa2fc25b20ddd1836ccac98de47a Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Wed, 28 Aug 2024 10:37:25 -0700 Subject: [PATCH 46/48] Make the embedding methods public for now, for intial testing Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index da4540aa379c..37eb935bc6cf 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -64,8 +64,8 @@ namespace Customizations; // The actual name here doesn't matter and is here for // 2. Add hyper-params (to getChatCompletions/Embeddings/ImageEmbeddings, all clients) // 3. Cache model info (to getModelInfo, all clients, Python only) @@access(AI.Model.getChatCompletions, Access.internal); -@@access(AI.Model.getEmbeddings, Access.internal); -@@access(AI.Model.getImageEmbeddings, Access.internal); +@@access(AI.Model.getEmbeddings, Access.internal, "python"); +@@access(AI.Model.getImageEmbeddings, Access.internal, "python"); @@access(AI.Model.getModelInfo, Access.internal, "python"); // We use shorter names in the Python client library From 2ef054672d2b58426a7ff77dbbbd789fac3b50dd Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Thu, 29 Aug 2024 15:16:53 -0700 Subject: [PATCH 47/48] Remove image embedding for now until it can be tested Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index 37eb935bc6cf..82daa259cece 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -114,7 +114,7 @@ interface Client2 { name: "ImageEmbeddingsClient", service: AI.Model, }, - "python,csharp" + "python" ) interface Client3 { embed is AI.Model.getImageEmbeddings; From aa97e50e44d2c620c92e5a4c791bb387a741d64c Mon Sep 17 00:00:00 2001 From: Travis Angevine Date: Fri, 27 Sep 2024 12:40:28 -0700 Subject: [PATCH 48/48] Add new streaming classes for C# Signed-off-by: Travis Angevine --- specification/ai/ModelClient/client.tsp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/specification/ai/ModelClient/client.tsp b/specification/ai/ModelClient/client.tsp index 82daa259cece..7a98741d8b5c 100644 --- a/specification/ai/ModelClient/client.tsp +++ b/specification/ai/ModelClient/client.tsp @@ -54,10 +54,10 @@ namespace Customizations; // The actual name here doesn't matter and is here for @@access(AI.Model.ChatMessageImageContentItem, Access.public); @@access(AI.Model.ChatMessageImageUrl, Access.public); @@access(AI.Model.ChatMessageImageDetailLevel, Access.public); -@@access(AI.Model.StreamingChatCompletionsUpdate, Access.public, "python"); -@@access(AI.Model.StreamingChatChoiceUpdate, Access.public, "python"); -@@access(AI.Model.StreamingChatResponseMessageUpdate, Access.public, "python"); -@@access(AI.Model.StreamingChatResponseToolCallUpdate, Access.public, "python"); +@@access(AI.Model.StreamingChatCompletionsUpdate, Access.public, "python,csharp"); +@@access(AI.Model.StreamingChatChoiceUpdate, Access.public, "python,csharp"); +@@access(AI.Model.StreamingChatResponseMessageUpdate, Access.public, "python,csharp"); +@@access(AI.Model.StreamingChatResponseToolCallUpdate, Access.public, "python,csharp"); // The operators need to be hidden, since we hand-write the public versions of those to // 1. Add chat completions streaming (to getChatCompletions operator)