mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 04:04:59 +00:00
enhance: API Key
is now optional
- Update README.md by adding tips for using OpenAI in this project
This commit is contained in:
parent
6fc972cc24
commit
ab54ecee42
3 changed files with 20 additions and 6 deletions
|
@ -95,7 +95,7 @@ namespace SourceGit.Models
|
|||
|
||||
public static bool IsValid
|
||||
{
|
||||
get => !string.IsNullOrEmpty(Server) && !string.IsNullOrEmpty(ApiKey) && !string.IsNullOrEmpty(Model);
|
||||
get => !string.IsNullOrEmpty(Server) && !string.IsNullOrEmpty(Model);
|
||||
}
|
||||
|
||||
public static OpenAIChatResponse Chat(string prompt, string question, CancellationToken cancellation)
|
||||
|
@ -105,7 +105,8 @@ namespace SourceGit.Models
|
|||
chat.AddMessage("user", question);
|
||||
|
||||
var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(60) };
|
||||
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}");
|
||||
if (!string.IsNullOrEmpty(ApiKey))
|
||||
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}");
|
||||
|
||||
var req = new StringContent(JsonSerializer.Serialize(chat, JsonCodeGen.Default.OpenAIChatRequest));
|
||||
try
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue