Skip to content

Commit

Permalink
Solve New line header error
Browse files Browse the repository at this point in the history
  • Loading branch information
GeeksAmin committed Nov 5, 2024
1 parent 70ffdbf commit 4f34f9b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions Olive.Gpt/Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,28 +156,28 @@ public async IAsyncEnumerable<string> GetResponseStream(ChatMessage[] messages,
try
{
bool streamheaderadded = false;
bool stopheaderadded = false;
//bool stopheaderadded = false;
if (Client.DefaultRequestHeaders.Any(header => header.Key == "stream") == false)
{
streamheaderadded = true;
Client.DefaultRequestHeaders.Add("stream", "true");
}
if (Client.DefaultRequestHeaders.Any(header => header.Key == "stop") == false)
{
stopheaderadded = true;
Client.DefaultRequestHeaders.Add("stop", ["\n\n"]);
}
//if (Client.DefaultRequestHeaders.Any(header => header.Key == "stop") == false)
//{
// stopheaderadded = true;
// Client.DefaultRequestHeaders.Add("stop", ["\n\n"]);
//}
response = await Client.SendAsync(httpRequest, HttpCompletionOption.ResponseHeadersRead);

if (streamheaderadded)
{
Client.DefaultRequestHeaders.Remove("stream");
}

if (stopheaderadded)
{
Client.DefaultRequestHeaders.Remove("stop");
}
//if (stopheaderadded)
//{
// Client.DefaultRequestHeaders.Remove("stop");
//}
}
catch (Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion Olive.Gpt/Olive.Gpt.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>1.0.132</Version>
<Version>1.0.133</Version>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>

Expand Down

0 comments on commit 4f34f9b

Please sign in to comment.