diff --git a/src/Cli/src/Commands/Auth/OpenAiCommand.cs b/src/Cli/src/Commands/Auth/OpenAiCommand.cs index 44206633..f25cae8b 100644 --- a/src/Cli/src/Commands/Auth/OpenAiCommand.cs +++ b/src/Cli/src/Commands/Auth/OpenAiCommand.cs @@ -14,14 +14,19 @@ public OpenAiCommand() : base(name: Providers.OpenAi, description: "Authenticate aliases: ["--model", "-m"], getDefaultValue: () => ChatModels.Gpt35Turbo, description: "Model to use for commands"); + var temperatureOption = new Option( + aliases: ["--temperature", "-t"], + getDefaultValue: () => 0.7, + description: "Sampling temperature to use (between 0 and 2)"); AddArgument(apiKeyArgument); AddOption(modelOption); + AddOption(temperatureOption); - this.SetHandler(HandleAsync, apiKeyArgument, modelOption); + this.SetHandler(HandleAsync, apiKeyArgument, modelOption, temperatureOption); } - private static async Task HandleAsync(string apiKey, string model) + private static async Task HandleAsync(string apiKey, string model, double temperature) { - await Helpers.AuthenticateWithApiKeyAsync(apiKey, model, Providers.OpenAi).ConfigureAwait(false); + await Helpers.AuthenticateWithApiKeyAsync(apiKey, model, Providers.OpenAi, temperature).ConfigureAwait(false); } } \ No newline at end of file diff --git a/src/Cli/src/Helpers.cs b/src/Cli/src/Helpers.cs index 836b41a9..16741dce 100644 --- a/src/Cli/src/Helpers.cs +++ b/src/Cli/src/Helpers.cs @@ -51,12 +51,13 @@ public static async Task SetModelAsync(string model) Console.WriteLine($"Model set to {model}"); } - public static async Task AuthenticateWithApiKeyAsync(string apiKey, string model, string provider) + public static async Task AuthenticateWithApiKeyAsync(string apiKey, string model, string provider, double temperature) { var settingsFolder = GetSettingsFolder(); await File.WriteAllTextAsync(Path.Combine(settingsFolder, "provider.txt"), provider).ConfigureAwait(false); await File.WriteAllTextAsync(Path.Combine(settingsFolder, "api_key.txt"), apiKey).ConfigureAwait(false); + await File.WriteAllTextAsync(Path.Combine(settingsFolder, "temperature.txt"), temperature.ToString()).ConfigureAwait(false); await SetModelAsync(model).ConfigureAwait(false); }