mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
fix: http System.InvalidOperationException (#476)
This commit is contained in:
parent
82ae44ff8b
commit
4b182e6ecd
1 changed files with 2 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -105,11 +106,10 @@ namespace SourceGit.Models
|
||||||
chat.AddMessage("user", question);
|
chat.AddMessage("user", question);
|
||||||
|
|
||||||
var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(60) };
|
var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(60) };
|
||||||
client.DefaultRequestHeaders.Add("Content-Type", "application/json");
|
|
||||||
if (!string.IsNullOrEmpty(ApiKey))
|
if (!string.IsNullOrEmpty(ApiKey))
|
||||||
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}");
|
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}");
|
||||||
|
|
||||||
var req = new StringContent(JsonSerializer.Serialize(chat, JsonCodeGen.Default.OpenAIChatRequest));
|
var req = new StringContent(JsonSerializer.Serialize(chat, JsonCodeGen.Default.OpenAIChatRequest), Encoding.UTF8, "application/json");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var task = client.PostAsync(Server, req, cancellation);
|
var task = client.PostAsync(Server, req, cancellation);
|
||||||
|
|
Loading…
Reference in a new issue