Skip to content

Commit

Permalink
Update default API version to 2024-10-21 (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcominerva authored Nov 5, 2024
2 parents cbcd4cb + c241d3e commit c330d28
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 11 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion samples/ChatGptApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion samples/ChatGptConsole/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion samples/ChatGptFunctionCallingConsole/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions samples/ChatGptStreamConsole/Application.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ChatGptNet;
using ChatGptNet.Extensions;

namespace ChatGptStreamConsole;

Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion samples/ChatGptStreamConsole/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/ChatGptNet/Models/ChatGptResponse.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using ChatGptNet.Extensions;
using ChatGptNet.Models.Common;
using ChatGptNet.Models.Converters;

Expand Down Expand Up @@ -59,4 +60,11 @@ public class ChatGptResponse : Response
/// <seealso cref="ChatGptChoice"/>
/// <seealso cref="ChatGptChoice.IsFiltered"/>
public bool IsContentFiltered => Choices.FirstOrDefault()?.IsFiltered ?? false;

/// <summary>
/// Gets the content of the response.
/// </summary>
/// <returns>The content of the response.</returns>
public override string? ToString()
=> this.GetContent();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ internal class AzureChatGptServiceConfiguration : ChatGptServiceConfiguration
/// <summary>
/// The default API version for Azure OpenAI service.
/// </summary>
public const string DefaultApiVersion = "2024-09-01-preview";
public const string DefaultApiVersion = "2024-10-21";

/// <summary>
/// Gets or sets the name of the Azure OpenAI Resource.
/// </summary>
public string? ResourceName { get; set; }

/// <summary>
/// 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).
/// </summary>
/// <remarks>
/// Currently supported versions are:
Expand Down Expand Up @@ -71,7 +71,15 @@ internal class AzureChatGptServiceConfiguration : ChatGptServiceConfiguration
/// <term>2024-09-01-preview</term>
/// <description><see href="https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2024-09-01-preview/inference.json">Swagger spec</see></description>
/// </item>
/// </list>
/// <item>
/// <term>2024-10-01-preview</term>
/// <description><see href="https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2024-10-01-preview/inference.json">Swagger spec</see></description>
/// </item>
/// <item>
/// <term>2024-10-21</term>
/// <description><see href="https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2024-10-21/inference.json">Swagger spec</see></description>
/// </item>
/// </list>
/// </remarks>
public string ApiVersion { get; set; } = DefaultApiVersion;

Expand Down

0 comments on commit c330d28

Please sign in to comment.