diff --git a/.vscode/cspell.json b/.vscode/cspell.json index d4dbf858e8fb..f5ab450da763 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -183,6 +183,12 @@ "warnaserror" ] }, + { + "filename": "**/sdk/ai/**/*.cs", + "words": [ + "Ubinary" + ] + }, { "filename": "**/sdk/analysisservices/**/*.cs", "words": [ diff --git a/sdk/ai/Azure.AI.Inference/CHANGELOG.md b/sdk/ai/Azure.AI.Inference/CHANGELOG.md index 9e7a664d7747..5e3a0ad0a239 100644 --- a/sdk/ai/Azure.AI.Inference/CHANGELOG.md +++ b/sdk/ai/Azure.AI.Inference/CHANGELOG.md @@ -1,14 +1,27 @@ # Release History -## 1.0.0-beta.2 (Unreleased) +## 1.0.0-beta.2 (2024-10-24) ### Features Added +- Added new `EmbeddingsClient`, to provide support for generating text embeddings using supported models. +- Add support for passing a string file path on disk in order to provide an image for chat completions. ### Breaking Changes +- `ChatCompletionsClientOptions` has been renamed to `AzureAIInferenceClientOptions`. +- `ChatCompletions` response object has been flattened. `ChatCompletions.Choices` has been removed, and the underlying properties have been bubbled up to be on the `ChatCompletions` object instead. +- `ChatCompletionsFunctionToolCall` has been replaced with `ChatCompletionsToolCall`. +- `ChatCompletionsFunctionToolDefinition` has been replaced with `ChatCompletionsToolDefinition`. +- `ChatCompletionsToolSelectionPreset` has been replaced with `ChatCompletionsToolChoicePreset`. +- `ChatCompletionsNamedFunctionToolSelection` has been replaced with `ChatCompletionsNamedToolChoice`. +- `ChatCompletionsFunctionToolSelection` has been replaced with `ChatCompletionsNamedToolChoiceFunction`. +- `StreamingChatCompletionsUpdate.AuthorName` has been removed +- Removed `extraParams` from the `complete` and `completeAsync` methods. It is now set implicitly if `additionalProperties` is provided in the options object. ### Bugs Fixed +- Fixed support for chat completions streaming while using tools. ### Other Changes +- Removed the need to manually provide an `api-key` header when talking to Azure OpenAI. ## 1.0.0-beta.1 (2024-08-06) ### Features Added diff --git a/sdk/ai/Azure.AI.Inference/README.md b/sdk/ai/Azure.AI.Inference/README.md index 7849ea1c1d19..06fa6cae04ab 100644 --- a/sdk/ai/Azure.AI.Inference/README.md +++ b/sdk/ai/Azure.AI.Inference/README.md @@ -53,7 +53,7 @@ The package includes `ChatCompletionsClient` +* [Text Embeddings](#text-embeddings-example) The examples create a client as mentioned in [Create and authenticate a client directly, using key](#create-and-authenticate-a-client-directly-using-key). Only mandatory input settings are shown for simplicity. @@ -165,7 +165,7 @@ This example demonstrates how to generate a single chat completions, with key au var endpoint = new Uri(System.Environment.GetEnvironmentVariable("AZURE_AI_CHAT_ENDPOINT")); var credential = new AzureKeyCredential(System.Environment.GetEnvironmentVariable("AZURE_AI_CHAT_KEY")); -var client = new ChatCompletionsClient(endpoint, credential, new ChatCompletionsClientOptions()); +var client = new ChatCompletionsClient(endpoint, credential, new AzureAIInferenceClientOptions()); var requestOptions = new ChatCompletionsOptions() { @@ -177,12 +177,12 @@ var requestOptions = new ChatCompletionsOptions() }; Response response = client.Complete(requestOptions); -System.Console.WriteLine(response.Value.Choices[0].Message.Content); +System.Console.WriteLine(response.Value.Content); ``` The following types or messages are supported: `SystemMessage`,`UserMessage`, `AssistantMessage`, `ToolMessage`. See also samples: -* [Sample5_ChatCompletionsWithImageUrl.md](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/ai/Azure.AI.Inference/samples/Sample5_ChatCompletionsWithImageUrl.md) for usage of `UserMessage` that includes sending an image URL. +* [Sample5_ChatCompletionsWithImages.md](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/ai/Azure.AI.Inference/samples/Sample5_ChatCompletionsWithImages.md) for usage of `UserMessage` that includes sending an image URL or image data from a local file. * [Sample7_ChatCompletionsWithTools.md](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/ai/Azure.AI.Inference/samples/Sample7_ChatCompletionsWithTools.md) for usage of `ToolMessage`. Alternatively, you can read a `BinaryData` object based on a JSON string instead of using the strongly typed classes like `ChatRequestSystemMessage` and `ChatRequestUserMessage`: @@ -191,7 +191,7 @@ Alternatively, you can read a `BinaryData` object based on a JSON string instead var endpoint = new Uri(System.Environment.GetEnvironmentVariable("AZURE_AI_CHAT_ENDPOINT")); var credential = new AzureKeyCredential(System.Environment.GetEnvironmentVariable("AZURE_AI_CHAT_KEY")); -var client = new ChatCompletionsClient(endpoint, credential, new ChatCompletionsClientOptions()); +var client = new ChatCompletionsClient(endpoint, credential, new AzureAIInferenceClientOptions()); var requestOptions = new ChatCompletionsOptions() { @@ -207,7 +207,7 @@ BinaryData messages = BinaryData.FromString(jsonMessages); requestOptions = ModelReaderWriter.Read(messages); Response response = client.Complete(requestOptions); -System.Console.WriteLine(response.Value.Choices[0].Message.Content); +System.Console.WriteLine(response.Value.Content); ``` To generate completions for additional messages, simply call `client.Complete` multiple times using the same `client`. @@ -220,7 +220,7 @@ This example demonstrates how to generate a single chat completions with streami var endpoint = new Uri(System.Environment.GetEnvironmentVariable("AZURE_AI_CHAT_ENDPOINT")); var credential = new AzureKeyCredential(System.Environment.GetEnvironmentVariable("AZURE_AI_CHAT_KEY")); -var client = new ChatCompletionsClient(endpoint, credential, new ChatCompletionsClientOptions()); +var client = new ChatCompletionsClient(endpoint, credential, new AzureAIInferenceClientOptions()); var requestOptions = new ChatCompletionsOptions() { @@ -255,15 +255,13 @@ In this example, extra JSON elements are inserted at the root of the request bod Note that by default, the service will reject any request payload that includes unknown parameters (ones that are not defined in the REST API [Request Body table](https://learn.microsoft.com/azure/ai-studio/reference/reference-model-inference-chat-completions#request-body)). In order to change the default service behaviour, when the `Complete` method includes `AdditonalProperties`, the client library will automatically add the HTTP request header `"unknown_params": "pass-through"`. - - Azure_AI_Inference_ChatCompletionsWithAdditionalPropertiesScenario ```C# Snippet:Azure_AI_Inference_ChatCompletionsWithAdditionalPropertiesScenario var endpoint = new Uri(System.Environment.GetEnvironmentVariable("AZURE_AI_CHAT_ENDPOINT")); var credential = new AzureKeyCredential(System.Environment.GetEnvironmentVariable("AZURE_AI_CHAT_KEY")); -var client = new ChatCompletionsClient(endpoint, credential, new ChatCompletionsClientOptions()); +var client = new ChatCompletionsClient(endpoint, credential, new AzureAIInferenceClientOptions()); var requestOptions = new ChatCompletionsOptions() { @@ -278,13 +276,25 @@ Response response = client.Complete(requestOptions); System.Console.WriteLine(response.Value.Choices[0].Message.Content); ``` -