Skip to content

Commit

Permalink
Fix golangci-lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
csmarchbanks committed Sep 5, 2023
1 parent 024b0ea commit 9ba5cc1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/plugin/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ func (a *App) runOpenAIChatCompletionsStream(ctx context.Context, req *backend.R
}
path := strings.TrimPrefix(req.Path, "openai")
httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, settings.OpenAIURL+path, bytes.NewReader(outgoingBody))
if err != nil {
return fmt.Errorf("proxy: stream: error creating request: %w", err)
}
httpReq.Header.Set("Authorization", fmt.Sprintf("Bearer %s", settings.openAIKey))
httpReq.Header.Set("OpenAI-Organization", settings.OpenAIOrganizationID)
httpReq.Header.Set("Content-Type", "application/json")
Expand All @@ -80,6 +83,11 @@ func (a *App) runOpenAIChatCompletionsStream(ctx context.Context, req *backend.R
// If the event data is "[DONE]", then we're done.
if eventData == "[DONE]" {
err = sender.SendJSON([]byte(`{"choices": [{"delta": {"done": true}}]}`))
if err != nil {
err = fmt.Errorf("proxy: stream: error sending done: %w", err)
log.DefaultLogger.Error(err.Error())
return err
}
log.DefaultLogger.Debug(fmt.Sprintf("proxy: stream: done==true, ending (in happy branch): %s", req.Path))
return nil
}
Expand Down

0 comments on commit 9ba5cc1

Please sign in to comment.