Skip to content

Commit 30aca80

Browse files
committed
Fixes #60 Whitespace optional in SSE event format
1 parent adca23f commit 30aca80

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

OpenAI_API/EndpointBase.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,17 @@ protected async IAsyncEnumerable<T> HttpStreamingRequest<T>(string url = null, H
369369
{
370370
resultAsString += line + Environment.NewLine;
371371

372-
if (line.StartsWith("data: "))
373-
line = line.Substring("data: ".Length);
372+
if (line.StartsWith("data:"))
373+
line = line.Substring("data:".Length);
374+
375+
line = line.TrimStart();
376+
374377
if (line == "[DONE]")
375378
{
376379
yield break;
377380
}
381+
else if (line.StartsWith(":"))
382+
{ }
378383
else if (!string.IsNullOrWhiteSpace(line))
379384
{
380385
var res = JsonConvert.DeserializeObject<T>(line);

0 commit comments

Comments
 (0)