Skip to content

Commit

Permalink
Introduce preliminary support for GPT-4 Turbo
Browse files Browse the repository at this point in the history
A new model Gpt4Turbo has been introduced in the ChatCompletionModels class with a tokens limit set to 4096. Corresponding updates have been made to the integration test cases replacing the previous model with this new one. Furthermore, the project version has been updated to 2.9.2 in the Directory.Build.props file
  • Loading branch information
rodion-m committed Nov 7, 2023
1 parent 477ef3a commit 802aa2b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.9.1</Version>
<Version>2.9.2</Version>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>12</LangVersion>
Expand Down
11 changes: 10 additions & 1 deletion src/OpenAI.ChatGpt/Models/ChatCompletion/ChatCompletionModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ public static class ChatCompletionModels
public const string Default = Gpt3_5_Turbo;

/// <summary>
/// IMPORTANT: This model is available only by request. Link for joining waitlist: https://openai.com/waitlist/gpt-4-api
/// Preview of the newest GPT-4 Turbo model.
/// </summary>
public const string Gpt4Turbo = "gpt-4-1106-preview";

/// <summary>
/// IMPORTANT: This model is available only by special coditions. https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4
/// More capable than any GPT-3.5 model, able to do more complex tasks, and optimized for chat.
/// Will be updated with OpenAI's latest model iteration 2 weeks after it is released.
/// This model has a maximum token limit of 8,192.
Expand Down Expand Up @@ -64,6 +69,8 @@ public static class ChatCompletionModels
/// The model was trained with data up to September 2021.
/// </summary>
public const string Gpt3_5_Turbo = "gpt-3.5-turbo";

public const string Gpt3_5_Turbo_1106 = "gpt-3.5-turbo-1106";

/// <summary>
/// Same capabilities as the standard gpt-3.5-turbo model but with 4 times the context.
Expand Down Expand Up @@ -119,11 +126,13 @@ public static class ChatCompletionModels
/// </summary>
private static readonly Dictionary<string, int> MaxTokensLimits = new()
{
{ Gpt4Turbo, 4096 },
{ Gpt4, 8192 },
{ Gpt4_0613, 8192 },
{ Gpt4_32k, 32_768 },
{ Gpt4_32k_0613, 32_768 },
{ Gpt3_5_Turbo, 4096 },
{ Gpt3_5_Turbo_1106, 16385 },
{ Gpt3_5_Turbo_16k, 16_384 },
{ Gpt3_5_Turbo_0613, 4096 },
{ Gpt3_5_Turbo_16k_0613, 16_384 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public async void Get_simple_structured_response_from_ChatGPT()
var message =
Dialog.StartAsSystem("What did user input?")
.ThenUser("My name is John, my age is 30, my email is [email protected]");
var response = await _client.GetStructuredResponse<UserInfo>(message);
var response = await _client.GetStructuredResponse<UserInfo>(message, model: ChatCompletionModels.Gpt4Turbo);
response.Should().NotBeNull();
response.Name.Should().Be("John");
response.Age.Should().Be(30);
Expand All @@ -26,7 +26,7 @@ public async void Get_structured_response_with_ARRAY_from_ChatGPT()
.StartAsSystem("What did user input?")
.ThenUser("My name is John, my age is 30, my email is [email protected]. " +
"I want to buy 2 apple and 3 orange.");
var response = await _client.GetStructuredResponse<Order>(message);
var response = await _client.GetStructuredResponse<Order>(message, model: ChatCompletionModels.Gpt4Turbo);
response.Should().NotBeNull();
response.UserInfo.Should().NotBeNull();
response.UserInfo!.Name.Should().Be("John");
Expand All @@ -46,7 +46,7 @@ public async void Get_structured_response_with_ENUM_from_ChatGPT()
var message = Dialog
.StartAsSystem("What did user input?")
.ThenUser("Мой любимый цвет - красный");
var response = await _client.GetStructuredResponse<Thing>(message);
var response = await _client.GetStructuredResponse<Thing>(message, model: ChatCompletionModels.Gpt4Turbo);
response.Should().NotBeNull();
response.Color.Should().Be(Thing.Colors.Red);
}
Expand All @@ -57,7 +57,7 @@ public async void Get_structured_response_with_extra_data_from_ChatGPT()
var message = Dialog
.StartAsSystem("Return requested data.")
.ThenUser("I need info about Almaty city");
var response = await _client.GetStructuredResponse<City>(message);
var response = await _client.GetStructuredResponse<City>(message, model: ChatCompletionModels.Gpt4Turbo);
response.Should().NotBeNull();
response.Name.Should().Be("Almaty");
response.Country.Should().Be("Kazakhstan");
Expand Down

0 comments on commit 802aa2b

Please sign in to comment.