diff --git a/README.md b/README.md index d260fdb..f02f0f3 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,9 @@ builder.Services.AddChatGpt(options => - 2024-06-01 - 2024-07-01-preview - 2024-08-01-preview - - 2024-09-01-preview (default) + - 2024-09-01-preview + - 2024-10-01-preview + - 2024-10-21 (default) - _AuthenticationType_: it specifies if the key is an actual API Key or an [Azure Active Directory token](https://learn.microsoft.com/azure/cognitive-services/openai/how-to/managed-identity) (optional, default: "ApiKey"). ### DefaultModel and DefaultEmbeddingModel @@ -148,7 +150,7 @@ The configuration can be automatically read from [IConfiguration](https://learn. "ApiKey": "", // Required //"Organization": "", // Optional, used only by OpenAI "ResourceName": "", // Required when using Azure OpenAI Service - "ApiVersion": "2024-09-01-preview", // Optional, used only by Azure OpenAI Service (default: 2024-09-01-preview) + "ApiVersion": "2024-10-21", // Optional, used only by Azure OpenAI Service (default: 2024-10-21) "AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory "DefaultModel": "my-model", diff --git a/samples/ChatGptApi/appsettings.json b/samples/ChatGptApi/appsettings.json index 6c3b32b..855cd8e 100644 --- a/samples/ChatGptApi/appsettings.json +++ b/samples/ChatGptApi/appsettings.json @@ -4,7 +4,7 @@ "ApiKey": "", // Required //"Organization": "", // Optional, used only by OpenAI "ResourceName": "", // Required when using Azure OpenAI Service - "ApiVersion": "2024-09-01-preview", // Optional, used only by Azure OpenAI Service (default: 2024-09-01-preview) + "ApiVersion": "2024-10-21", // Optional, used only by Azure OpenAI Service (default: 2024-10-21) "AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory "DefaultModel": "my-model", diff --git a/samples/ChatGptConsole/appsettings.json b/samples/ChatGptConsole/appsettings.json index c821d06..e7a2f19 100644 --- a/samples/ChatGptConsole/appsettings.json +++ b/samples/ChatGptConsole/appsettings.json @@ -4,7 +4,7 @@ "ApiKey": "", // Required //"Organization": "", // Optional, used only by OpenAI "ResourceName": "", // Required when using Azure OpenAI Service - "ApiVersion": "2024-09-01-preview", // Optional, used only by Azure OpenAI Service (default: 2024-09-01-preview) + "ApiVersion": "2024-10-21", // Optional, used only by Azure OpenAI Service (default: 2024-10-21) "AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory "DefaultModel": "my-model", diff --git a/samples/ChatGptFunctionCallingConsole/appsettings.json b/samples/ChatGptFunctionCallingConsole/appsettings.json index c821d06..e7a2f19 100644 --- a/samples/ChatGptFunctionCallingConsole/appsettings.json +++ b/samples/ChatGptFunctionCallingConsole/appsettings.json @@ -4,7 +4,7 @@ "ApiKey": "", // Required //"Organization": "", // Optional, used only by OpenAI "ResourceName": "", // Required when using Azure OpenAI Service - "ApiVersion": "2024-09-01-preview", // Optional, used only by Azure OpenAI Service (default: 2024-09-01-preview) + "ApiVersion": "2024-10-21", // Optional, used only by Azure OpenAI Service (default: 2024-10-21) "AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory "DefaultModel": "my-model", diff --git a/samples/ChatGptStreamConsole/Application.cs b/samples/ChatGptStreamConsole/Application.cs index 413a6ce..f3cbad8 100644 --- a/samples/ChatGptStreamConsole/Application.cs +++ b/samples/ChatGptStreamConsole/Application.cs @@ -1,5 +1,4 @@ using ChatGptNet; -using ChatGptNet.Extensions; namespace ChatGptStreamConsole; @@ -44,7 +43,7 @@ public async Task ExecuteAsync() await foreach (var response in responseStream) { - Console.Write(response.GetContent()); + Console.Write(response); await Task.Delay(80); } diff --git a/samples/ChatGptStreamConsole/appsettings.json b/samples/ChatGptStreamConsole/appsettings.json index 720693d..c58b74d 100644 --- a/samples/ChatGptStreamConsole/appsettings.json +++ b/samples/ChatGptStreamConsole/appsettings.json @@ -4,7 +4,7 @@ "ApiKey": "", // Required //"Organization": "", // Optional, used only by OpenAI "ResourceName": "", // Required when using Azure OpenAI Service - "ApiVersion": "2024-09-01-preview", // Optional, used only by Azure OpenAI Service (default: 2024-09-01-preview) + "ApiVersion": "2024-10-21", // Optional, used only by Azure OpenAI Service (default: 2024-10-21) "AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory "DefaultModel": "my-model", diff --git a/src/ChatGptNet/Models/ChatGptResponse.cs b/src/ChatGptNet/Models/ChatGptResponse.cs index dc11a73..d11573f 100644 --- a/src/ChatGptNet/Models/ChatGptResponse.cs +++ b/src/ChatGptNet/Models/ChatGptResponse.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json.Serialization; +using ChatGptNet.Extensions; using ChatGptNet.Models.Common; using ChatGptNet.Models.Converters; @@ -59,4 +60,11 @@ public class ChatGptResponse : Response /// /// public bool IsContentFiltered => Choices.FirstOrDefault()?.IsFiltered ?? false; + + /// + /// Gets the content of the response. + /// + /// The content of the response. + public override string? ToString() + => this.GetContent(); } \ No newline at end of file diff --git a/src/ChatGptNet/ServiceConfigurations/AzureChatGptServiceConfiguration.cs b/src/ChatGptNet/ServiceConfigurations/AzureChatGptServiceConfiguration.cs index 8ffb898..2a773a4 100644 --- a/src/ChatGptNet/ServiceConfigurations/AzureChatGptServiceConfiguration.cs +++ b/src/ChatGptNet/ServiceConfigurations/AzureChatGptServiceConfiguration.cs @@ -10,7 +10,7 @@ internal class AzureChatGptServiceConfiguration : ChatGptServiceConfiguration /// /// The default API version for Azure OpenAI service. /// - public const string DefaultApiVersion = "2024-09-01-preview"; + public const string DefaultApiVersion = "2024-10-21"; /// /// Gets or sets the name of the Azure OpenAI Resource. @@ -18,7 +18,7 @@ internal class AzureChatGptServiceConfiguration : ChatGptServiceConfiguration public string? ResourceName { get; set; } /// - /// Gets or sets the API version of the Azure OpenAI service (Default: 2024-09-01-preview). + /// Gets or sets the API version of the Azure OpenAI service (Default: 2024-10-21). /// /// /// Currently supported versions are: @@ -71,7 +71,15 @@ internal class AzureChatGptServiceConfiguration : ChatGptServiceConfiguration /// 2024-09-01-preview /// Swagger spec /// - /// + /// + /// 2024-10-01-preview + /// Swagger spec + /// + /// + /// 2024-10-21 + /// Swagger spec + /// + /// /// public string ApiVersion { get; set; } = DefaultApiVersion;