openai-python icon indicating copy to clipboard operation
openai-python copied to clipboard

Correctly set Accept header to text/event-stream for completion streaming

Open mathetake opened this issue 1 year ago • 0 comments

  • [x] I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Previously, the standard Accept header was set to application/json unconditionally. However, streaming response returns content-type: text/event-stream following the specification of server-sent-events.

This correctly sets the Accept header to it accordingly in order to comply with the standard. The exact same problem exists in other SDKS (e.g. https://github.com/openai/openai-go/pull/94)

Additional context & links

  • https://github.com/openai/openai-node/issues/375
  • https://github.com/openai/openai-node/pull/1145
  • https://github.com/openai/openai-go/pull/94

Context: I am an Envoy Proxy community member and from a network proxy perspective, the discrepancy from the web standard is not a good thing. Hope this brings an attention to the problem as the fix is clearly a single line!

mathetake avatar Oct 23 '24 17:10 mathetake