diff --git a/.editorconfig b/.editorconfig index 887ee1e..def8856 100644 --- a/.editorconfig +++ b/.editorconfig @@ -140,8 +140,8 @@ csharp_style_pattern_local_over_anonymous_function = true:suggestion csharp_style_prefer_index_operator = true:suggestion csharp_style_prefer_range_operator = true:suggestion csharp_style_throw_expression = true:suggestion -csharp_style_unused_value_assignment_preference = discard_variable:suggestion -csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:none +csharp_style_unused_value_expression_statement_preference = discard_variable:none # 'using' directive preferences csharp_using_directive_placement = outside_namespace:suggestion diff --git a/README.md b/README.md index a18aa0f..b3b153a 100644 --- a/README.md +++ b/README.md @@ -53,13 +53,9 @@ builder.Services.AddChatGpt(options => - _ResourceName_: the name of your Azure OpenAI Resource (required). - _ApiKey_: Azure OpenAI provides two methods for authentication. You can use either API Keys or Azure Active Directory (required). - _ApiVersion_: the version of the API to use (optional). Allowed values: - - 2023-03-15-preview - 2023-05-15 - 2023-06-01-preview - - 2023-07-01-preview - - 2023-08-01-preview - - 2023-09-01-preview - - 2023-12-01-preview (default) + - 2024-02-15-preview (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 @@ -75,7 +71,7 @@ Currently available models are: - gpt-3.5-turbo-16k, - gpt-4, - gpt-4-32k -- gpt-4-1106-preview +- gpt-4-turbo-preview - gpt-4-vision-preview They have fixed names, available in the [OpenAIChatGptModels.cs file](https://github.com/marcominerva/ChatGptNet/blob/master/src/ChatGptNet/Models/OpenAIChatGptModels.cs). diff --git a/docs/ChatGptNet.Models/OpenAIChatGptModels.md b/docs/ChatGptNet.Models/OpenAIChatGptModels.md index eeafac4..7ac7eb0 100644 --- a/docs/ChatGptNet.Models/OpenAIChatGptModels.md +++ b/docs/ChatGptNet.Models/OpenAIChatGptModels.md @@ -10,12 +10,12 @@ public static class OpenAIChatGptModels | name | description | | --- | --- | -| const [Gpt35Turbo](OpenAIChatGptModels/Gpt35Turbo.md) | GPT-3.5 model can understand and generate natural language or code and it is optimized for chat. | -| const [Gpt35Turbo_16k](OpenAIChatGptModels/Gpt35Turbo_16k.md) | A model with the same capabilities as the standard [`Gpt35Turbo`](./OpenAIChatGptModels/Gpt35Turbo.md) model but with 4 times the token limit of [`Gpt35Turbo`](./OpenAIChatGptModels/Gpt35Turbo.md). | +| const [Gpt35_Turbo](OpenAIChatGptModels/Gpt35_Turbo.md) | GPT-3.5 model can understand and generate natural language or code and it is optimized for chat. | +| const [Gpt35_Turbo_16k](OpenAIChatGptModels/Gpt35_Turbo_16k.md) | A model with the same capabilities as the standard [`Gpt35_Turbo`](./OpenAIChatGptModels/Gpt35_Turbo.md) model but with 4 times the token limit of [`Gpt35_Turbo`](./OpenAIChatGptModels/Gpt35_Turbo.md). | | const [Gpt4](OpenAIChatGptModels/Gpt4.md) | GPT-4 is a large multimodal model that can solve difficult problems with greater accuracy than any of our previous models, thanks to its broader general knowledge and advanced reasoning capabilities. is optimized for chat but works well for traditional completions tasks. | -| const [Gpt4_1106_Preview](OpenAIChatGptModels/Gpt4_1106_Preview.md) | The latest GPT-4 model with improved instruction following, JSON mode, reproducible outputs, parallel function calling, and more. | +| const [Gpt4Vision_Preview](OpenAIChatGptModels/Gpt4Vision_Preview.md) | Ability to understand images, in addition to all other GPT-4 Turbo capabilties. | | const [Gpt4_32k](OpenAIChatGptModels/Gpt4_32k.md) | A model with the same capabilities as the base [`Gpt4`](./OpenAIChatGptModels/Gpt4.md) model but with 4 times the token limit of [`Gpt4`](./OpenAIChatGptModels/Gpt4.md). | -| const [Gpt4_Vision_Preview](OpenAIChatGptModels/Gpt4_Vision_Preview.md) | Ability to understand images, in addition to all other GPT-4 Turbo capabilties. | +| const [Gpt4_Turbo_Preview](OpenAIChatGptModels/Gpt4_Turbo_Preview.md) | The latest GPT-4 model with improved instruction following, JSON mode, reproducible outputs, parallel function calling, and more. | ## Remarks diff --git a/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt35Turbo.md b/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt35_Turbo.md similarity index 78% rename from docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt35Turbo.md rename to docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt35_Turbo.md index dc5cfd6..a743e5e 100644 --- a/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt35Turbo.md +++ b/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt35_Turbo.md @@ -1,9 +1,9 @@ -# OpenAIChatGptModels.Gpt35Turbo field +# OpenAIChatGptModels.Gpt35_Turbo field GPT-3.5 model can understand and generate natural language or code and it is optimized for chat. ```csharp -public const string Gpt35Turbo; +public const string Gpt35_Turbo; ``` ## Remarks @@ -12,7 +12,7 @@ This model supports 4.096 tokens. See [GPT-3.5](https://platform.openai.com/docs ## See Also -* field [Gpt35Turbo_16k](./Gpt35Turbo_16k.md) +* field [Gpt35_Turbo_16k](./Gpt35_Turbo_16k.md) * class [OpenAIChatGptModels](../OpenAIChatGptModels.md) * namespace [ChatGptNet.Models](../../ChatGptNet.md) diff --git a/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt35Turbo_16k.md b/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt35_Turbo_16k.md similarity index 54% rename from docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt35Turbo_16k.md rename to docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt35_Turbo_16k.md index e47286b..74cce41 100644 --- a/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt35Turbo_16k.md +++ b/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt35_Turbo_16k.md @@ -1,9 +1,9 @@ -# OpenAIChatGptModels.Gpt35Turbo_16k field +# OpenAIChatGptModels.Gpt35_Turbo_16k field -A model with the same capabilities as the standard [`Gpt35Turbo`](./Gpt35Turbo.md) model but with 4 times the token limit of [`Gpt35Turbo`](./Gpt35Turbo.md). +A model with the same capabilities as the standard [`Gpt35_Turbo`](./Gpt35_Turbo.md) model but with 4 times the token limit of [`Gpt35_Turbo`](./Gpt35_Turbo.md). ```csharp -public const string Gpt35Turbo_16k; +public const string Gpt35_Turbo_16k; ``` ## Remarks @@ -12,7 +12,7 @@ This model supports 16.384 tokens. See [GPT-3.5](https://platform.openai.com/doc ## See Also -* field [Gpt35Turbo](./Gpt35Turbo.md) +* field [Gpt35_Turbo](./Gpt35_Turbo.md) * class [OpenAIChatGptModels](../OpenAIChatGptModels.md) * namespace [ChatGptNet.Models](../../ChatGptNet.md) diff --git a/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt4_Vision_Preview.md b/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt4Vision_Preview.md similarity index 76% rename from docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt4_Vision_Preview.md rename to docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt4Vision_Preview.md index 453200c..3cf708f 100644 --- a/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt4_Vision_Preview.md +++ b/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt4Vision_Preview.md @@ -1,14 +1,14 @@ -# OpenAIChatGptModels.Gpt4_Vision_Preview field +# OpenAIChatGptModels.Gpt4Vision_Preview field Ability to understand images, in addition to all other GPT-4 Turbo capabilties. ```csharp -public const string Gpt4_Vision_Preview; +public const string Gpt4Vision_Preview; ``` ## Remarks -This model supports 128.000 tokens and returns a maximum if 4.096 outpout tokens. This preview model is not yet suited for production traffic. See [GPT-4](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) for more information. +This model supports 128.000 tokens and returns a maximum of 4.096 outpout tokens. This preview model is not yet suited for production traffic. See [GPT-4](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) for more information. ## See Also diff --git a/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt4_1106_Preview.md b/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt4_Turbo_Preview.md similarity index 78% rename from docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt4_1106_Preview.md rename to docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt4_Turbo_Preview.md index 3325d12..25b03a0 100644 --- a/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt4_1106_Preview.md +++ b/docs/ChatGptNet.Models/OpenAIChatGptModels/Gpt4_Turbo_Preview.md @@ -1,14 +1,14 @@ -# OpenAIChatGptModels.Gpt4_1106_Preview field +# OpenAIChatGptModels.Gpt4_Turbo_Preview field The latest GPT-4 model with improved instruction following, JSON mode, reproducible outputs, parallel function calling, and more. ```csharp -public const string Gpt4_1106_Preview; +public const string Gpt4_Turbo_Preview; ``` ## Remarks -This model supports 128.000 tokens and returns a maximum if 4.096 outpout tokens. This preview model is not yet suited for production traffic. See [GPT-4](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) for more information. +This model supports 128.000 tokens and returns a maximum of 4.096 outpout tokens. This preview model is not yet suited for production traffic. See [GPT-4](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) for more information. ## See Also diff --git a/docs/ChatGptNet/ChatGptFactoryServiceCollectionExtensions.md b/docs/ChatGptNet/ChatGptFactoryServiceCollectionExtensions.md new file mode 100644 index 0000000..8f4dd52 --- /dev/null +++ b/docs/ChatGptNet/ChatGptFactoryServiceCollectionExtensions.md @@ -0,0 +1,20 @@ +# ChatGptFactoryServiceCollectionExtensions class + +Provides extension methods for adding ChatGPT Client Factory support in NET applications. + +```csharp +public static class ChatGptFactoryServiceCollectionExtensions +``` + +## Public Members + +| name | description | +| --- | --- | +| static [AddChatGptClientFactory](ChatGptFactoryServiceCollectionExtensions/AddChatGptClientFactory.md)(…) | Registers a ChatGptClientFactory instance. | + +## See Also + +* namespace [ChatGptNet](../ChatGptNet.md) +* [ChatGptFactoryServiceCollectionExtensions.cs](https://github.com/marcominerva/ChatGptNet/tree/master/src/ChatGptNet/ChatGptFactoryServiceCollectionExtensions.cs) + + diff --git a/docs/ChatGptNet/ChatGptFactoryServiceCollectionExtensions/AddChatGptClientFactory.md b/docs/ChatGptNet/ChatGptFactoryServiceCollectionExtensions/AddChatGptClientFactory.md new file mode 100644 index 0000000..3c3f70a --- /dev/null +++ b/docs/ChatGptNet/ChatGptFactoryServiceCollectionExtensions/AddChatGptClientFactory.md @@ -0,0 +1,25 @@ +# ChatGptFactoryServiceCollectionExtensions.AddChatGptClientFactory method + +Registers a ChatGptClientFactory instance. + +```csharp +public static IServiceCollection AddChatGptClientFactory(this IServiceCollection services, + Action? builder = null) +``` + +| parameter | description | +| --- | --- | +| services | The IServiceCollection to add services to. | +| builder | The Action to configure the provided [`ChatGptOptions`](../ChatGptOptions.md). | + +## Return Value + +A reference to this instance after the operation has completed. + +## See Also + +* class [ChatGptOptionsBuilder](../ChatGptOptionsBuilder.md) +* class [ChatGptFactoryServiceCollectionExtensions](../ChatGptFactoryServiceCollectionExtensions.md) +* namespace [ChatGptNet](../../ChatGptNet.md) + + diff --git a/docs/ChatGptNet/ChatGptOptions.md b/docs/ChatGptNet/ChatGptOptions.md index eaa3a51..d645523 100644 --- a/docs/ChatGptNet/ChatGptOptions.md +++ b/docs/ChatGptNet/ChatGptOptions.md @@ -13,7 +13,7 @@ public class ChatGptOptions | [ChatGptOptions](ChatGptOptions/ChatGptOptions.md)() | The default constructor. | | [DefaultEmbeddingModel](ChatGptOptions/DefaultEmbeddingModel.md) { get; set; } | Gets or sets the default model for embedding. (default: [`TextEmbeddingAda002`](../ChatGptNet.Models.Embeddings/OpenAIEmbeddingModels/TextEmbeddingAda002.md) when the provider is OpenAI). | | [DefaultEmbeddingParameters](ChatGptOptions/DefaultEmbeddingParameters.md) { get; } | Gets or sets the default parameters for embeddings. | -| [DefaultModel](ChatGptOptions/DefaultModel.md) { get; set; } | Gets or sets the default model for chat completion. (default: [`Gpt35Turbo`](../ChatGptNet.Models/OpenAIChatGptModels/Gpt35Turbo.md) when the provider is OpenAI). | +| [DefaultModel](ChatGptOptions/DefaultModel.md) { get; set; } | Gets or sets the default model for chat completion. (default: [`Gpt35_Turbo`](../ChatGptNet.Models/OpenAIChatGptModels/Gpt35_Turbo.md) when the provider is OpenAI). | | [DefaultParameters](ChatGptOptions/DefaultParameters.md) { get; } | Gets or sets the default parameters for chat completion. | | [MessageExpiration](ChatGptOptions/MessageExpiration.md) { get; set; } | Gets or sets the expiration for cached conversation messages (default: 1 hour). | | [MessageLimit](ChatGptOptions/MessageLimit.md) { get; set; } | Gets or sets the maximum number of messages to use for chat completion (default: 10). | diff --git a/docs/ChatGptNet/ChatGptOptions/DefaultModel.md b/docs/ChatGptNet/ChatGptOptions/DefaultModel.md index a48b573..8539de2 100644 --- a/docs/ChatGptNet/ChatGptOptions/DefaultModel.md +++ b/docs/ChatGptNet/ChatGptOptions/DefaultModel.md @@ -1,6 +1,6 @@ # ChatGptOptions.DefaultModel property -Gets or sets the default model for chat completion. (default: [`Gpt35Turbo`](../../ChatGptNet.Models/OpenAIChatGptModels/Gpt35Turbo.md) when the provider is OpenAI). +Gets or sets the default model for chat completion. (default: [`Gpt35_Turbo`](../../ChatGptNet.Models/OpenAIChatGptModels/Gpt35_Turbo.md) when the provider is OpenAI). ```csharp public string? DefaultModel { get; set; } diff --git a/docs/ChatGptNet/ChatGptOptionsBuilder.md b/docs/ChatGptNet/ChatGptOptionsBuilder.md index 935b69b..16416a8 100644 --- a/docs/ChatGptNet/ChatGptOptionsBuilder.md +++ b/docs/ChatGptNet/ChatGptOptionsBuilder.md @@ -10,10 +10,10 @@ public class ChatGptOptionsBuilder | name | description | | --- | --- | -| [ChatGptOptionsBuilder](ChatGptOptionsBuilder/ChatGptOptionsBuilder.md)() | The default constructor. | +| [ChatGptOptionsBuilder](ChatGptOptionsBuilder/ChatGptOptionsBuilder.md)() | Initializes a new instance of the [`ChatGptOptionsBuilder`](./ChatGptOptionsBuilder.md) class. | | [DefaultEmbeddingModel](ChatGptOptionsBuilder/DefaultEmbeddingModel.md) { get; set; } | Gets or sets the default model for embeddings. (default: [`TextEmbeddingAda002`](../ChatGptNet.Models.Embeddings/OpenAIEmbeddingModels/TextEmbeddingAda002.md) when the provider is OpenAI). | -| [DefaultEmbeddingParameters](ChatGptOptionsBuilder/DefaultEmbeddingParameters.md) { get; } | Gets or sets the default parameters for embeddings. | -| [DefaultModel](ChatGptOptionsBuilder/DefaultModel.md) { get; set; } | Gets or sets the default model for chat completion. (default: [`Gpt35Turbo`](../ChatGptNet.Models/OpenAIChatGptModels/Gpt35Turbo.md) when the provider is OpenAI). | +| [DefaultEmbeddingParameters](ChatGptOptionsBuilder/DefaultEmbeddingParameters.md) { get; set; } | Gets or sets the default parameters for embeddings. | +| [DefaultModel](ChatGptOptionsBuilder/DefaultModel.md) { get; set; } | Gets or sets the default model for chat completion. (default: [`Gpt35_Turbo`](../ChatGptNet.Models/OpenAIChatGptModels/Gpt35_Turbo.md) when the provider is OpenAI). | | [DefaultParameters](ChatGptOptionsBuilder/DefaultParameters.md) { get; set; } | Gets or sets the default parameters for chat completion. | | [MessageExpiration](ChatGptOptionsBuilder/MessageExpiration.md) { get; set; } | Gets or sets the expiration for cached conversation messages (default: 1 hour). | | [MessageLimit](ChatGptOptionsBuilder/MessageLimit.md) { get; set; } | Gets or sets the maximum number of messages to use for chat completion (default: 10). | diff --git a/docs/ChatGptNet/ChatGptOptionsBuilder/ChatGptOptionsBuilder.md b/docs/ChatGptNet/ChatGptOptionsBuilder/ChatGptOptionsBuilder.md index 367bbcf..45b00de 100644 --- a/docs/ChatGptNet/ChatGptOptionsBuilder/ChatGptOptionsBuilder.md +++ b/docs/ChatGptNet/ChatGptOptionsBuilder/ChatGptOptionsBuilder.md @@ -1,6 +1,6 @@ # ChatGptOptionsBuilder constructor -The default constructor. +Initializes a new instance of the [`ChatGptOptionsBuilder`](../ChatGptOptionsBuilder.md) class. ```csharp public ChatGptOptionsBuilder() diff --git a/docs/ChatGptNet/ChatGptOptionsBuilder/DefaultEmbeddingParameters.md b/docs/ChatGptNet/ChatGptOptionsBuilder/DefaultEmbeddingParameters.md index ce497e1..e038018 100644 --- a/docs/ChatGptNet/ChatGptOptionsBuilder/DefaultEmbeddingParameters.md +++ b/docs/ChatGptNet/ChatGptOptionsBuilder/DefaultEmbeddingParameters.md @@ -3,7 +3,7 @@ Gets or sets the default parameters for embeddings. ```csharp -public EmbeddingParameters DefaultEmbeddingParameters { get; } +public EmbeddingParameters DefaultEmbeddingParameters { get; set; } ``` ## See Also diff --git a/docs/ChatGptNet/ChatGptOptionsBuilder/DefaultModel.md b/docs/ChatGptNet/ChatGptOptionsBuilder/DefaultModel.md index b8eb99e..0d96d0a 100644 --- a/docs/ChatGptNet/ChatGptOptionsBuilder/DefaultModel.md +++ b/docs/ChatGptNet/ChatGptOptionsBuilder/DefaultModel.md @@ -1,6 +1,6 @@ # ChatGptOptionsBuilder.DefaultModel property -Gets or sets the default model for chat completion. (default: [`Gpt35Turbo`](../../ChatGptNet.Models/OpenAIChatGptModels/Gpt35Turbo.md) when the provider is OpenAI). +Gets or sets the default model for chat completion. (default: [`Gpt35_Turbo`](../../ChatGptNet.Models/OpenAIChatGptModels/Gpt35_Turbo.md) when the provider is OpenAI). ```csharp public string? DefaultModel { get; set; } diff --git a/docs/ChatGptNet/ChatGptOptionsBuilderExtensions/UseAzure.md b/docs/ChatGptNet/ChatGptOptionsBuilderExtensions/UseAzure.md index 1e488d7..02c7a55 100644 --- a/docs/ChatGptNet/ChatGptOptionsBuilderExtensions/UseAzure.md +++ b/docs/ChatGptNet/ChatGptOptionsBuilderExtensions/UseAzure.md @@ -4,7 +4,7 @@ Configures Azure OpenAI Service settings. ```csharp public static ChatGptOptionsBuilder UseAzure(this ChatGptOptionsBuilder builder, - string resourceName, string apiKey, string apiVersion = "2023-12-01-preview", + string resourceName, string apiKey, string apiVersion = "2024-02-15-preview", AzureAuthenticationType authenticationType = AzureAuthenticationType.ApiKey) ``` diff --git a/docs/ChatGptNet/IChatGptClientFactory.md b/docs/ChatGptNet/IChatGptClientFactory.md new file mode 100644 index 0000000..1ff1df4 --- /dev/null +++ b/docs/ChatGptNet/IChatGptClientFactory.md @@ -0,0 +1,21 @@ +# IChatGptClientFactory interface + +Provides methods to create new instances of [`IChatGptClient`](./IChatGptClient.md) at runtime + +```csharp +public interface IChatGptClientFactory +``` + +## Members + +| name | description | +| --- | --- | +| [CreateClient](IChatGptClientFactory/CreateClient.md)() | Creates a new instance of a ChatGptClient. | +| [CreateClient](IChatGptClientFactory/CreateClient.md)(…) | Creates a new instance of a ChatGptClient configured with the supplied action. (2 methods) | + +## See Also + +* namespace [ChatGptNet](../ChatGptNet.md) +* [IChatGptClientFactory.cs](https://github.com/marcominerva/ChatGptNet/tree/master/src/ChatGptNet/IChatGptClientFactory.cs) + + diff --git a/docs/ChatGptNet/IChatGptClientFactory/CreateClient.md b/docs/ChatGptNet/IChatGptClientFactory/CreateClient.md new file mode 100644 index 0000000..e61516e --- /dev/null +++ b/docs/ChatGptNet/IChatGptClientFactory/CreateClient.md @@ -0,0 +1,69 @@ +# IChatGptClientFactory.CreateClient method (1 of 3) + +Creates a new instance of a ChatGptClient. + +```csharp +public IChatGptClient CreateClient() +``` + +## Return Value + +A new [`IChatGptClient`](../IChatGptClient.md) + +## See Also + +* interface [IChatGptClient](../IChatGptClient.md) +* interface [IChatGptClientFactory](../IChatGptClientFactory.md) +* namespace [ChatGptNet](../../ChatGptNet.md) + +--- + +# IChatGptClientFactory.CreateClient method (2 of 3) + +Creates a new instance of a ChatGptClient configured with the supplied action. + +```csharp +public IChatGptClient CreateClient(Action? setupAction) +``` + +| parameter | description | +| --- | --- | +| setupAction | The Action to configure the provided [`ChatGptOptions`](../ChatGptOptions.md). | + +## Return Value + +A new [`IChatGptClient`](../IChatGptClient.md) + +## See Also + +* interface [IChatGptClient](../IChatGptClient.md) +* class [ChatGptOptionsBuilder](../ChatGptOptionsBuilder.md) +* interface [IChatGptClientFactory](../IChatGptClientFactory.md) +* namespace [ChatGptNet](../../ChatGptNet.md) + +--- + +# IChatGptClientFactory.CreateClient method (3 of 3) + +Creates a new instance of a ChatGptClient configured with the supplied action. + +```csharp +public IChatGptClient CreateClient(Action? setupAction) +``` + +| parameter | description | +| --- | --- | +| setupAction | The Action to configure the provided [`ChatGptOptions`](../ChatGptOptions.md). | + +## Return Value + +A new [`IChatGptClient`](../IChatGptClient.md) + +## See Also + +* interface [IChatGptClient](../IChatGptClient.md) +* class [ChatGptOptionsBuilder](../ChatGptOptionsBuilder.md) +* interface [IChatGptClientFactory](../IChatGptClientFactory.md) +* namespace [ChatGptNet](../../ChatGptNet.md) + + diff --git a/docs/README.md b/docs/README.md index 6f45e14..06e28a5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,6 +5,7 @@ | public type | description | | --- | --- | | class [ChatGptBuilder](./ChatGptNet/ChatGptBuilder.md) | Represents the default builder for configuring ChatGPT. | +| static class [ChatGptFactoryServiceCollectionExtensions](./ChatGptNet/ChatGptFactoryServiceCollectionExtensions.md) | Provides extension methods for adding ChatGPT Client Factory support in NET applications. | | class [ChatGptOptions](./ChatGptNet/ChatGptOptions.md) | Options class that provides settings for configuring ChatGPT. | | class [ChatGptOptionsBuilder](./ChatGptNet/ChatGptOptionsBuilder.md) | Builder class to define settings for configuring ChatGPT. | | static class [ChatGptOptionsBuilderExtensions](./ChatGptNet/ChatGptOptionsBuilderExtensions.md) | Provides extensions to configure settings for accessing ChatGPT service. | @@ -13,6 +14,7 @@ | static class [IChatGptBuilderExtensions](./ChatGptNet/IChatGptBuilderExtensions.md) | Provides extension methods for configuring ChatGPT after service creation. | | interface [IChatGptCache](./ChatGptNet/IChatGptCache.md) | Represents the interface used to define the caching behavior for ChatGPT messages. | | interface [IChatGptClient](./ChatGptNet/IChatGptClient.md) | Provides methods to interact with ChatGPT. | +| interface [IChatGptClientFactory](./ChatGptNet/IChatGptClientFactory.md) | Provides methods to create new instances of [`IChatGptClient`](./ChatGptNet/IChatGptClient.md) at runtime | ## ChatGptNet.Exceptions namespace diff --git a/samples/ChatGptApi/ChatGptApi.csproj b/samples/ChatGptApi/ChatGptApi.csproj index 54659ec..82e8680 100644 --- a/samples/ChatGptApi/ChatGptApi.csproj +++ b/samples/ChatGptApi/ChatGptApi.csproj @@ -7,10 +7,11 @@ - - - + + + + diff --git a/samples/ChatGptApi/Program.cs b/samples/ChatGptApi/Program.cs index 6afc9cd..c41f23b 100644 --- a/samples/ChatGptApi/Program.cs +++ b/samples/ChatGptApi/Program.cs @@ -1,7 +1,7 @@ -using System.Diagnostics; using System.Text.Json.Serialization; using ChatGptNet; using ChatGptNet.Extensions; +using TinyHelpers.AspNetCore.Extensions; var builder = WebApplication.CreateBuilder(args); @@ -40,13 +40,8 @@ builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); -builder.Services.AddProblemDetails(options => -{ - options.CustomizeProblemDetails = context => - { - context.ProblemDetails.Extensions["traceId"] = Activity.Current?.Id ?? context.HttpContext.TraceIdentifier; - }; -}); +builder.Services.AddDefaultProblemDetails(); +builder.Services.AddDefaultExceptionHandler(); var app = builder.Build(); diff --git a/samples/ChatGptApi/appsettings.json b/samples/ChatGptApi/appsettings.json index b56eec0..7f23670 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": "2023-12-01-preview", // Optional, used only by Azure OpenAI Service (default: 2023-08-01-preview) + "ApiVersion": "2024-02-15-preview", // Optional, used only by Azure OpenAI Service (default: 2024-02-15-preview) "AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory "DefaultModel": "my-model", diff --git a/samples/ChatGptBlazor.Wasm/ChatGptBlazor.Wasm.csproj b/samples/ChatGptBlazor.Wasm/ChatGptBlazor.Wasm.csproj index 15e93d1..050e0b5 100644 --- a/samples/ChatGptBlazor.Wasm/ChatGptBlazor.Wasm.csproj +++ b/samples/ChatGptBlazor.Wasm/ChatGptBlazor.Wasm.csproj @@ -8,11 +8,11 @@ - - - - - + + + + + diff --git a/samples/ChatGptBlazor.Wasm/Components/ChatGptStream.razor b/samples/ChatGptBlazor.Wasm/Components/ChatGptStream.razor index 4d73032..962575e 100644 --- a/samples/ChatGptBlazor.Wasm/Components/ChatGptStream.razor +++ b/samples/ChatGptBlazor.Wasm/Components/ChatGptStream.razor @@ -1,14 +1,33 @@ @using ChatGptNet.Extensions; @using ChatGptNet.Models; @using ChatGptNet; +@using ChatGptNet.ServiceConfigurations @using Markdig; -@inject IChatGptClient chatGptClient +@inject IChatGptClientFactory chatGptClientFactory @inject IJSRuntime jsRuntime
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
@foreach (var message in messages) @@ -62,6 +81,12 @@ private string? message; private bool isAsking; + private string? azureResource; + private string? apiKey; + private string? model; + + private IChatGptClient? chatGptClient = null; + private bool CanSendMessage() => !string.IsNullOrWhiteSpace(message) && !isAsking; @@ -73,6 +98,17 @@ } } + private void Connect() + { + chatGptClient = chatGptClientFactory.CreateClient(options => + { + options.UseAzure(azureResource!, apiKey!, authenticationType: AzureAuthenticationType.ApiKey); + options.DefaultModel = model; + options.MessageLimit = 16; // Default: 10 + options.MessageExpiration = TimeSpan.FromMinutes(5); // Default: 1 hour + }); + } + private async Task AskAsync() { if (!isAsking) @@ -82,7 +118,7 @@ messages.Add(new ChatEntry { Sender = ChatGptRoles.User, Content = message! }); var responseMessage = new ChatEntry { Sender = ChatGptRoles.Assistant, Content = string.Empty }; - var responseStream = chatGptClient.AskStreamAsync(conversationId, message!); + var responseStream = chatGptClient!.AskStreamAsync(conversationId, message!); message = string.Empty; diff --git a/samples/ChatGptBlazor.Wasm/Program.cs b/samples/ChatGptBlazor.Wasm/Program.cs index 447738a..595caf9 100644 --- a/samples/ChatGptBlazor.Wasm/Program.cs +++ b/samples/ChatGptBlazor.Wasm/Program.cs @@ -1,5 +1,6 @@ using ChatGptBlazor.Wasm; using ChatGptNet; +using ChatGptNet.ServiceConfigurations; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; @@ -10,27 +11,6 @@ builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); // Adds ChatGPT service and configure options via code. -builder.Services.AddChatGpt(options => -{ - // OpenAI. - //options.UseOpenAI(apiKey: "", organization: ""); - - // Azure OpenAI Service. - //options.UseAzure(resourceName: "", apiKey: "", authenticationType: AzureAuthenticationType.ApiKey); - - options.DefaultModel = "my-model"; - options.MessageLimit = 16; // Default: 10 - options.MessageExpiration = TimeSpan.FromMinutes(5); // Default: 1 hour -}, -httpClient => -{ - // Configures retry policy on the inner HttpClient using Polly. - httpClient.AddStandardResilienceHandler(options => - { - options.AttemptTimeout.Timeout = TimeSpan.FromMinutes(1); - options.CircuitBreaker.SamplingDuration = TimeSpan.FromMinutes(3); - options.TotalRequestTimeout.Timeout = TimeSpan.FromMinutes(3); - }); -}); +builder.Services.AddChatGptClientFactory(); await builder.Build().RunAsync(); diff --git a/samples/ChatGptBlazor.Wasm/Properties/launchSettings.json b/samples/ChatGptBlazor.Wasm/Properties/launchSettings.json index f9af232..deec97b 100644 --- a/samples/ChatGptBlazor.Wasm/Properties/launchSettings.json +++ b/samples/ChatGptBlazor.Wasm/Properties/launchSettings.json @@ -1,40 +1,32 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:8206", - "sslPort": 44385 - } - }, "profiles": { "http": { "commandName": "Project", - "dotnetRunMessages": true, "launchBrowser": true, - "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", - "applicationUrl": "http://localhost:5297", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "http://localhost:5297" }, "https": { "commandName": "Project", - "dotnetRunMessages": true, "launchBrowser": true, - "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", - "applicationUrl": "https://localhost:7021;http://localhost:5297", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, + }, + "dotnetRunMessages": true, "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } + "applicationUrl": "https://localhost:7021;http://localhost:5297" + } + }, + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:8206", + "sslPort": 44385 } } -} +} \ No newline at end of file diff --git a/samples/ChatGptConsole/ChatGptConsole.csproj b/samples/ChatGptConsole/ChatGptConsole.csproj index 3d6f605..41fb183 100644 --- a/samples/ChatGptConsole/ChatGptConsole.csproj +++ b/samples/ChatGptConsole/ChatGptConsole.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/samples/ChatGptConsole/appsettings.json b/samples/ChatGptConsole/appsettings.json index 469407f..6c72132 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": "2023-12-01-preview", // Optional, used only by Azure OpenAI Service (default: 2023-12-01-preview) + "ApiVersion": "2024-02-15-preview", // Optional, used only by Azure OpenAI Service (default: 2024-02-15-preview) "AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory "DefaultModel": "my-model", diff --git a/samples/ChatGptFunctionCallingConsole/ChatGptFunctionCallingConsole.csproj b/samples/ChatGptFunctionCallingConsole/ChatGptFunctionCallingConsole.csproj index d74f6bc..61a24b8 100644 --- a/samples/ChatGptFunctionCallingConsole/ChatGptFunctionCallingConsole.csproj +++ b/samples/ChatGptFunctionCallingConsole/ChatGptFunctionCallingConsole.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/samples/ChatGptFunctionCallingConsole/appsettings.json b/samples/ChatGptFunctionCallingConsole/appsettings.json index fd15b9b..b075cd8 100644 --- a/samples/ChatGptFunctionCallingConsole/appsettings.json +++ b/samples/ChatGptFunctionCallingConsole/appsettings.json @@ -1,10 +1,10 @@ { "ChatGPT": { - "Provider": "Azure", // Optional. Allowed values: OpenAI (default) or Azure + "Provider": "OpenAI", // Optional. Allowed values: OpenAI (default) or Azure "ApiKey": "", // Required //"Organization": "", // Optional, used only by OpenAI "ResourceName": "", // Required when using Azure OpenAI Service - "ApiVersion": "2023-12-01-preview", // Optional, used only by Azure OpenAI Service (default: 2023-12-01-preview) + "ApiVersion": "2024-02-15-preview", // Optional, used only by Azure OpenAI Service (default: 2024-02-15-preview) "AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory "DefaultModel": "my-model", diff --git a/samples/ChatGptStreamConsole/ChatGptStreamConsole.csproj b/samples/ChatGptStreamConsole/ChatGptStreamConsole.csproj index 23d12aa..fe839ff 100644 --- a/samples/ChatGptStreamConsole/ChatGptStreamConsole.csproj +++ b/samples/ChatGptStreamConsole/ChatGptStreamConsole.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/samples/ChatGptStreamConsole/appsettings.json b/samples/ChatGptStreamConsole/appsettings.json index d11773f..8e0bff2 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": "2023-12-01-preview", // Optional, used only by Azure OpenAI Service (default: 2023-12-01-preview) + "ApiVersion": "2024-02-15-preview", // Optional, used only by Azure OpenAI Service (default: 2024-02-15-preview) "AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory "DefaultModel": "my-model", diff --git a/src/ChatGptNet/ChatGptClientFactory.cs b/src/ChatGptNet/ChatGptClientFactory.cs new file mode 100644 index 0000000..dc5e420 --- /dev/null +++ b/src/ChatGptNet/ChatGptClientFactory.cs @@ -0,0 +1,32 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace ChatGptNet; + +internal class ChatGptClientFactory(IServiceProvider serviceProvider, IChatGptCache chatGptCache, ChatGptOptionsBuilder defaultOptions) : IChatGptClientFactory +{ + public IChatGptClient CreateClient(Action? setupAction) + { + var options = new ChatGptOptionsBuilder(defaultOptions); + + if (setupAction is not null) + { + setupAction(serviceProvider, options); + } + + var httpClient = serviceProvider.GetRequiredService().CreateClient(); + return new ChatGptClient(httpClient, chatGptCache, options.Build()); + } + + public IChatGptClient CreateClient(Action? setupAction) + { + if (setupAction is null) + { + return CreateClient(); + } + + return CreateClient((_, options) => setupAction(options)); + } + + public IChatGptClient CreateClient() + => CreateClient((Action?)null); +} diff --git a/src/ChatGptNet/ChatGptFactoryServiceCollectionExtensions.cs b/src/ChatGptNet/ChatGptFactoryServiceCollectionExtensions.cs new file mode 100644 index 0000000..fa194db --- /dev/null +++ b/src/ChatGptNet/ChatGptFactoryServiceCollectionExtensions.cs @@ -0,0 +1,38 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace ChatGptNet; + +/// +/// Provides extension methods for adding ChatGPT Client Factory support in NET applications. +/// +public static class ChatGptFactoryServiceCollectionExtensions +{ + /// + /// Registers a instance. + /// + /// The to add services to. + /// The to configure the provided . + /// A reference to this instance after the operation has completed. + public static IServiceCollection AddChatGptClientFactory(this IServiceCollection services, Action? builder = null) + { + ArgumentNullException.ThrowIfNull(services); + + var options = new ChatGptOptionsBuilder(); + builder?.Invoke(options); + + return AddChatGptClientFactoryCore(services, options); + } + + private static IServiceCollection AddChatGptClientFactoryCore(this IServiceCollection services, ChatGptOptionsBuilder deafultOptions) + { + services.AddMemoryCache(); + services.AddSingleton(); + + services.AddHttpClient(); + services.AddSingleton( + serviceProvider => new ChatGptClientFactory(serviceProvider, serviceProvider.GetRequiredService(), deafultOptions) + ); + + return services; + } +} diff --git a/src/ChatGptNet/ChatGptOptions.cs b/src/ChatGptNet/ChatGptOptions.cs index 7d291c5..2c9c584 100644 --- a/src/ChatGptNet/ChatGptOptions.cs +++ b/src/ChatGptNet/ChatGptOptions.cs @@ -36,7 +36,7 @@ public class ChatGptOptions public bool ThrowExceptionOnError { get; set; } = true; /// - /// Gets or sets the default model for chat completion. (default: when the provider is OpenAI). + /// Gets or sets the default model for chat completion. (default: when the provider is OpenAI). /// /// /// diff --git a/src/ChatGptNet/ChatGptOptionsBuilder.cs b/src/ChatGptNet/ChatGptOptionsBuilder.cs index 721a801..327a5fd 100644 --- a/src/ChatGptNet/ChatGptOptionsBuilder.cs +++ b/src/ChatGptNet/ChatGptOptionsBuilder.cs @@ -36,7 +36,7 @@ public class ChatGptOptionsBuilder public bool ThrowExceptionOnError { get; set; } = true; /// - /// Gets or sets the default model for chat completion. (default: when the provider is OpenAI). + /// Gets or sets the default model for chat completion. (default: when the provider is OpenAI). /// /// /// @@ -69,6 +69,58 @@ public class ChatGptOptionsBuilder /// public string? User { get; set; } + /// + /// Initializes a new instance of the class. + /// + public ChatGptOptionsBuilder() + { + } + + internal ChatGptOptionsBuilder(ChatGptOptionsBuilder source) + { + MessageLimit = source.MessageLimit; + DefaultModel = source.DefaultModel; + DefaultEmbeddingModel = source.DefaultEmbeddingModel; + + DefaultParameters = new() + { + FrequencyPenalty = source.DefaultParameters?.FrequencyPenalty, + MaxTokens = source.DefaultParameters?.MaxTokens, + PresencePenalty = source.DefaultParameters?.PresencePenalty, + ResponseFormat = source.DefaultParameters?.ResponseFormat, + TopP = source.DefaultParameters?.TopP, + Temperature = source.DefaultParameters?.Temperature, + Seed = source.DefaultParameters?.Seed + }; + + DefaultEmbeddingParameters = new() + { + Dimensions = source.DefaultEmbeddingParameters.Dimensions + }; + + MessageExpiration = source.MessageExpiration; + ThrowExceptionOnError = source.ThrowExceptionOnError; + + ServiceConfiguration = source.ServiceConfiguration switch + { + OpenAIChatGptServiceConfiguration openAI => new OpenAIChatGptServiceConfiguration + { + ApiKey = openAI.ApiKey, + Organization = openAI.Organization + }, + AzureChatGptServiceConfiguration azure => new AzureChatGptServiceConfiguration + { + ResourceName = azure.ResourceName, + ApiKey = azure.ApiKey, + ApiVersion = azure.ApiVersion, + AuthenticationType = azure.AuthenticationType + }, + _ => null! + }; + + User = source.User; + } + internal ChatGptOptions Build() => new() { diff --git a/src/ChatGptNet/ChatGptServiceCollectionExtensions.cs b/src/ChatGptNet/ChatGptServiceCollectionExtensions.cs index a96f549..7c6af6a 100644 --- a/src/ChatGptNet/ChatGptServiceCollectionExtensions.cs +++ b/src/ChatGptNet/ChatGptServiceCollectionExtensions.cs @@ -165,7 +165,7 @@ private static void SetMissingDefaults(ChatGptOptionsBuilder options) // If the provider is OpenAI and some default models are not specified, use the default ones. if (string.IsNullOrWhiteSpace(options.DefaultModel)) { - options.DefaultModel = OpenAIChatGptModels.Gpt35Turbo; + options.DefaultModel = OpenAIChatGptModels.Gpt35_Turbo; } if (string.IsNullOrWhiteSpace(options.DefaultEmbeddingModel)) diff --git a/src/ChatGptNet/IChatGptClientFactory.cs b/src/ChatGptNet/IChatGptClientFactory.cs new file mode 100644 index 0000000..c4ab817 --- /dev/null +++ b/src/ChatGptNet/IChatGptClientFactory.cs @@ -0,0 +1,27 @@ +namespace ChatGptNet; + +/// +/// Provides methods to create new instances of at runtime +/// +public interface IChatGptClientFactory +{ + /// + /// Creates a new instance of a ChatGptClient configured with the supplied action. + /// + /// The to configure the provided . + /// A new + IChatGptClient CreateClient(Action? setupAction); + + /// + /// Creates a new instance of a ChatGptClient configured with the supplied action. + /// + /// The to configure the provided . + /// A new + IChatGptClient CreateClient(Action? setupAction); + + /// + /// Creates a new instance of a ChatGptClient. + /// + /// A new + IChatGptClient CreateClient(); +} diff --git a/src/ChatGptNet/Models/OpenAIChatGptModels.cs b/src/ChatGptNet/Models/OpenAIChatGptModels.cs index b9f2a6b..eaccce6 100644 --- a/src/ChatGptNet/Models/OpenAIChatGptModels.cs +++ b/src/ChatGptNet/Models/OpenAIChatGptModels.cs @@ -17,17 +17,17 @@ public static class OpenAIChatGptModels /// /// This model supports 4.096 tokens. See GPT-3.5 for more information. /// - /// - public const string Gpt35Turbo = "gpt-3.5-turbo"; + /// + public const string Gpt35_Turbo = "gpt-3.5-turbo"; /// - /// A model with the same capabilities as the standard model but with 4 times the token limit of . + /// A model with the same capabilities as the standard model but with 4 times the token limit of . /// /// /// This model supports 16.384 tokens. See GPT-3.5 for more information. /// - /// - public const string Gpt35Turbo_16k = "gpt-3.5-turbo-16k"; + /// + public const string Gpt35_Turbo_16k = "gpt-3.5-turbo-16k"; /// /// GPT-4 is a large multimodal model that can solve difficult problems with greater accuracy than any of our previous models, thanks to its broader general knowledge and advanced reasoning capabilities. is optimized for chat but works well for traditional completions tasks. @@ -51,19 +51,19 @@ public static class OpenAIChatGptModels /// The latest GPT-4 model with improved instruction following, JSON mode, reproducible outputs, parallel function calling, and more. /// /// - /// This model supports 128.000 tokens and returns a maximum if 4.096 outpout tokens. This preview model is not yet suited for production traffic. + /// This model supports 128.000 tokens and returns a maximum of 4.096 outpout tokens. This preview model is not yet suited for production traffic. /// See GPT-4 for more information. /// /// - public const string Gpt4_1106_Preview = "gpt-4-1106-preview"; + public const string Gpt4_Turbo_Preview = "gpt-4-turbo-preview"; /// /// Ability to understand images, in addition to all other GPT-4 Turbo capabilties. /// /// - /// This model supports 128.000 tokens and returns a maximum if 4.096 outpout tokens. This preview model is not yet suited for production traffic. + /// This model supports 128.000 tokens and returns a maximum of 4.096 outpout tokens. This preview model is not yet suited for production traffic. /// See GPT-4 for more information. /// /// - public const string Gpt4_Vision_Preview = "gpt-4-vision-preview"; + public const string Gpt4Vision_Preview = "gpt-4-vision-preview"; } \ No newline at end of file diff --git a/src/ChatGptNet/ServiceConfigurations/AzureChatGptServiceConfiguration.cs b/src/ChatGptNet/ServiceConfigurations/AzureChatGptServiceConfiguration.cs index 3bb7456..19ed925 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 = "2023-12-01-preview"; + public const string DefaultApiVersion = "2024-02-15-preview"; /// /// Gets or sets the name of the Azure OpenAI Resource. @@ -18,16 +18,12 @@ internal class AzureChatGptServiceConfiguration : ChatGptServiceConfiguration public string? ResourceName { get; set; } /// - /// Gets or sets the API version of the Azure OpenAI service (Default: 2023-12-01-preview). + /// Gets or sets the API version of the Azure OpenAI service (Default: 2024-02-15-preview). /// /// /// Currently supported versions are: /// /// - /// 2023-03-15-preview - /// Swagger spec - /// - /// /// 2023-05-15 /// Swagger spec /// @@ -36,20 +32,8 @@ internal class AzureChatGptServiceConfiguration : ChatGptServiceConfiguration /// Swagger spec /// /// - /// 2023-07-01-preview - /// Swagger spec - /// - /// - /// 2023-08-01-preview - /// Swagger spec - /// - /// - /// 2023-09-01-preview - /// Swagger spec - /// - /// - /// 2023-12-01-preview - /// Swagger spec + /// 2024-02-15-preview + /// Swagger spec /// /// ///