Skip to content

Commit

Permalink
Update API version and model references (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcominerva authored Jul 23, 2024
2 parents 5f5bcdd + ab8d289 commit ffe9b12
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 29 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ builder.Services.AddChatGpt(options =>
- 2024-02-15-preview
- 2024-03-01-preview
- 2024-04-01-preview
- 2024-05-01-preview (default)
- 2024-05-01-preview
- 2024-02-01
- 2024-06-01 (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 All @@ -78,6 +79,7 @@ Currently available models are:
- gpt-4-32k
- gpt-4-turbo
- gpt-4o
- gpt-4o-mini

They have fixed names, available in the [OpenAIChatGptModels.cs file](https://github.com/marcominerva/ChatGptNet/blob/master/src/ChatGptNet/Models/OpenAIChatGptModels.cs).

Expand Down Expand Up @@ -143,7 +145,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": "2023-08-01-preview", // Optional, used only by Azure OpenAI Service (default: 2023-08-01-preview)
"ApiVersion": "2024-06-01", // Optional, used only by Azure OpenAI Service (default: 2024-06-01)
"AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory
"DefaultModel": "my-model",
Expand Down
5 changes: 2 additions & 3 deletions samples/ChatGptApi/ChatGptApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.6.0" />
<PackageReference Include="Polly.Extensions" Version="8.4.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.7.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="TinyHelpers.AspNetCore" Version="3.1.6" />
</ItemGroup>
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-05-01-preview", // Optional, used only by Azure OpenAI Service (default: 2024-05-01-preview)
"ApiVersion": "2024-06-01", // Optional, used only by Azure OpenAI Service (default: 2024-06-01)
"AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory

"DefaultModel": "my-model",
Expand Down
7 changes: 3 additions & 4 deletions samples/ChatGptBlazor.Wasm/ChatGptBlazor.Wasm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

<ItemGroup>
<PackageReference Include="Markdig" Version="0.37.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.6" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.6.0" />
<PackageReference Include="Polly.Extensions" Version="8.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.7" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.7.0" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions samples/ChatGptConsole/ChatGptConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.6.0" />
<PackageReference Include="Polly.Extensions" Version="8.4.0" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.7.0" />
</ItemGroup>

<ItemGroup>
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-05-01-preview", // Optional, used only by Azure OpenAI Service (default: 2024-05-01-preview)
"ApiVersion": "2024-06-01", // Optional, used only by Azure OpenAI Service (default: 2024-06-01)
"AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory

"DefaultModel": "my-model",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.6.0" />
<PackageReference Include="Polly.Extensions" Version="8.4.0" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.7.0" />
</ItemGroup>

<ItemGroup>
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-05-01-preview", // Optional, used only by Azure OpenAI Service (default: 2024-05-01-preview)
"ApiVersion": "2024-06-01", // Optional, used only by Azure OpenAI Service (default: 2024-06-01)
"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/ChatGptStreamConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.6.0" />
<PackageReference Include="Polly.Extensions" Version="8.4.0" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.7.0" />
</ItemGroup>

<ItemGroup>
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-05-01-preview", // Optional, used only by Azure OpenAI Service (default: 2024-05-01-preview)
"ApiVersion": "2024-06-01", // Optional, used only by Azure OpenAI Service (default: 2024-06-01)
"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 src/ChatGptNet/ChatGptNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
</ItemGroup>
Expand Down
17 changes: 10 additions & 7 deletions src/ChatGptNet/Models/OpenAIChatGptModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public static class OpenAIChatGptModels
/// <remarks>
/// This model supports 4.096 tokens. See <see href="https://platform.openai.com/docs/models/gpt-3-5">GPT-3.5</see> for more information.
/// </remarks>
/// <seealso cref="Gpt35_Turbo_16k"/>
public const string Gpt35_Turbo = "gpt-3.5-turbo";

/// <summary>
Expand All @@ -26,7 +25,6 @@ public static class OpenAIChatGptModels
/// <remarks>
/// This model supports 16.384 tokens. See <see href="https://platform.openai.com/docs/models/gpt-3-5">GPT-3.5</see> for more information.
/// </remarks>
/// <seealso cref="Gpt35_Turbo"/>
public const string Gpt35_Turbo_16k = "gpt-3.5-turbo-16k";

/// <summary>
Expand All @@ -35,7 +33,6 @@ public static class OpenAIChatGptModels
/// <remarks>
/// This model supports 8.192 tokens. See <see href="https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4">GPT-4</see> for more information.
/// </remarks>
/// <seealso cref="Gpt4_32k"/>
public const string Gpt4 = "gpt-4";

/// <summary>
Expand All @@ -44,7 +41,6 @@ public static class OpenAIChatGptModels
/// <remarks>
/// This model supports 32.768 tokens. See <see href="https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4">GPT-4</see> for more information.
/// </remarks>
/// <seealso cref="Gpt4"/>
public const string Gpt4_32k = "gpt-4-32k";

/// <summary>
Expand All @@ -54,16 +50,23 @@ public static class OpenAIChatGptModels
/// This model supports 128.000 tokens and returns a maximum of 4.096 outpout tokens.
/// See <see href="https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4">GPT-4</see> for more information.
/// </remarks>
/// <seealso cref="Gpt4"/>
public const string Gpt4_Turbo = "gpt-4-turbo";

/// <summary>
/// The most advanced, multimodal flagship model that’s cheaper and faster than <see cref="Gpt4_Turbo"/>.
/// The most advanced, multimodal flagship model that is cheaper and faster than <see cref="Gpt4_Turbo"/>.
/// </summary>
/// <remarks>
/// This model supports 128.000 tokens and returns a maximum of 4.096 outpout tokens.
/// See <see href="https://platform.openai.com/docs/models/gpt-4o">GPT-4</see> for more information.
/// </remarks>
/// <seealso cref="Gpt4_Turbo"/>
public const string Gpt4_o = "gpt-4o";

/// <summary>
/// An affordable and intelligent small model for fast, lightweight tasks. GPT-4o mini is cheaper and more capable than <see cref="Gpt35_Turbo"/>.
/// </summary>
/// <remarks>
/// This model supports 128.000 tokens and returns a maximum of 4.096 outpout tokens.
/// See <see href="https://platform.openai.com/docs/models/gpt-4o-mini">GPT-4</see> for more information.
/// </remarks>
public const string Gpt4_o_mini = "gpt-4o-mini";
}
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-05-01-preview";
public const string DefaultApiVersion = "2024-06-01";

/// <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-05-01-preview).
/// Gets or sets the API version of the Azure OpenAI service (Default: 2024-06-01).
/// </summary>
/// <remarks>
/// Currently supported versions are:
Expand Down Expand Up @@ -55,6 +55,10 @@ internal class AzureChatGptServiceConfiguration : ChatGptServiceConfiguration
/// <term>2023-02-01</term>
/// <description><see href="https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2024-02-01/inference.json">Swagger spec</see></description>
/// </item>
/// <item>
/// <term>2024-06-01</term>
/// <description><see href="https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2024-06-01/inference.json">Swagger spec</see></description>
/// </item>
/// </list>
/// </remarks>
public string ApiVersion { get; set; } = DefaultApiVersion;
Expand Down

0 comments on commit ffe9b12

Please sign in to comment.