Skip to content

Commit

Permalink
Add more settings
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes committed Mar 21, 2023
1 parent c323ba8 commit 7c051e6
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChatGPT.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ You are a helpful assistant named Clippy.
Settings = new ChatSettingsViewModel
{
Temperature = 0.7m,
TopP = 1m,
MaxTokens = 2000,
Model = "gpt-3.5-turbo",
Directions = directions
Expand Down
6 changes: 6 additions & 0 deletions ChatGPT.Core/Defaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ public static class Defaults

public const decimal DefaultTemperature = 0.7m;

public const decimal DefaultTopP = 1m;

public const decimal DefaultPresencePenalty = 0m;

public const decimal DefaultFrequencyPenalty = 0m;

public const int DefaultMaxTokens = 256;

public const string DefaultModel = "gpt-3.5-turbo";
Expand Down
27 changes: 27 additions & 0 deletions ChatGPT.Core/ViewModels/Chat/ChatSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ namespace ChatGPT.ViewModels.Chat;
public partial class ChatSettingsViewModel : ObservableObject
{
private decimal _temperature;
private decimal _topP;
private decimal _presencePenalty;
private decimal _frequencyPenalty;
private int _maxTokens;
private string? _apiKey;
private string? _model;
Expand All @@ -19,6 +22,27 @@ public decimal Temperature
set => SetProperty(ref _temperature, value);
}

[JsonPropertyName("top_p")]
public decimal TopP
{
get => _topP;
set => SetProperty(ref _topP, value);
}

[JsonPropertyName("presence_penalty")]
public decimal PresencePenalty
{
get => _presencePenalty;
set => SetProperty(ref _presencePenalty, value);
}

[JsonPropertyName("frequency_penalty")]
public decimal FrequencyPenalty
{
get => _frequencyPenalty;
set => SetProperty(ref _frequencyPenalty, value);
}

[JsonPropertyName("maxTokens")]
public int MaxTokens
{
Expand Down Expand Up @@ -59,6 +83,9 @@ public ChatSettingsViewModel Copy()
return new ChatSettingsViewModel
{
Temperature = _temperature,
TopP = _topP,
PresencePenalty = _presencePenalty,
FrequencyPenalty = _frequencyPenalty,
MaxTokens = _maxTokens,
ApiKey = _apiKey,
Model = _model,
Expand Down
3 changes: 3 additions & 0 deletions ChatGPT.Core/ViewModels/MainViewModel.Chats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ private ChatSettingsViewModel CreateDefaultChatSettings()
return new ChatSettingsViewModel
{
Temperature = Defaults.DefaultTemperature,
TopP = Defaults.DefaultTopP,
PresencePenalty = Defaults.DefaultPresencePenalty,
FrequencyPenalty = Defaults.DefaultFrequencyPenalty,
MaxTokens = Defaults.DefaultMaxTokens,
Model = Defaults.DefaultModel,
ApiKey = null,
Expand Down
3 changes: 3 additions & 0 deletions ChatGPT.UI/Views/Chat/ChatSettingsView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<Design.DataContext>
<vm:ChatSettingsViewModel>
<vm:ChatSettingsViewModel.Temperature>0.6</vm:ChatSettingsViewModel.Temperature>
<vm:ChatSettingsViewModel.TopP>1</vm:ChatSettingsViewModel.TopP>
<vm:ChatSettingsViewModel.FrequencyPenalty>0</vm:ChatSettingsViewModel.FrequencyPenalty>
<vm:ChatSettingsViewModel.PresencePenalty>0</vm:ChatSettingsViewModel.PresencePenalty>
<vm:ChatSettingsViewModel.MaxTokens>100</vm:ChatSettingsViewModel.MaxTokens>
<vm:ChatSettingsViewModel.ApiKey><x:Null/></vm:ChatSettingsViewModel.ApiKey>
</vm:ChatSettingsViewModel>
Expand Down
2 changes: 2 additions & 0 deletions ChatGPT/Model/Services/ChatServiceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ public class ChatServiceSettings
public decimal Temperature { get; set; }
public int MaxTokens { get; set; }
public decimal TopP { get; set; }
public decimal PresencePenalty { get; set; }
public decimal FrequencyPenalty { get; set; }
public string? Stop { get; set; }
}
4 changes: 2 additions & 2 deletions ChatGPT/Services/ChatService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ private static string GetRequestBodyJson(ChatServiceSettings settings)
N = 1,
Stream = false,
Stop = settings.Stop,
FrequencyPenalty = 0.0m,
PresencePenalty = 0.0m,
FrequencyPenalty = settings.FrequencyPenalty,
PresencePenalty = settings.PresencePenalty,
User = null
};

Expand Down

0 comments on commit 7c051e6

Please sign in to comment.