mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-26 21:17:20 -08:00
enhance: supports Azure OpenAI REST API (#695)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
3c5a4741bf
commit
e3ffe3ef6c
1 changed files with 6 additions and 1 deletions
|
@ -155,7 +155,12 @@ namespace SourceGit.Models
|
||||||
|
|
||||||
var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(60) };
|
var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(60) };
|
||||||
if (!string.IsNullOrEmpty(ApiKey))
|
if (!string.IsNullOrEmpty(ApiKey))
|
||||||
|
{
|
||||||
|
if (Server.Contains("openai.azure.com/", StringComparison.Ordinal))
|
||||||
|
client.DefaultRequestHeaders.Add("api-key", ApiKey);
|
||||||
|
else
|
||||||
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}");
|
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}");
|
||||||
|
}
|
||||||
|
|
||||||
var req = new StringContent(JsonSerializer.Serialize(chat, JsonCodeGen.Default.OpenAIChatRequest), Encoding.UTF8, "application/json");
|
var req = new StringContent(JsonSerializer.Serialize(chat, JsonCodeGen.Default.OpenAIChatRequest), Encoding.UTF8, "application/json");
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in a new issue