Skip to content

Inability to Parse API Response Data Due to Missing Space After "data:" #781

Open
@fruitbars

Description

@fruitbars

Describe the bug
The bug occurs when the response data from the API does not include a space after the colon in the "data:" prefix. This causes the data to not be properly parsed or read by the client.

To Reproduce

  1. Make a request to the OpenAI API endpoint that returns streaming data.
  2. Ensure that the response includes a "data:" prefix without a space, like so: data:{"code":0,"message":"Success","sid":"xxx","id":"xxx","created":1719810561,"choices":[{"delta":{"role":"assistant","content":"He"},"index":0}]}.
  3. Attempt to read or parse the response data.

Expected behavior
The client should be able to correctly parse and read the response data regardless of whether there is a space after the "data:" prefix.

Screenshots/Logs
Unfortunately, no screenshots are available, but the logs would show that the data is not being processed as expected due to the missing space.

Environment

  • go-openai version: Not specified
  • Go version: Not specified
  • OpenAI API version: Not specified
  • OS: Not specified

Additional context
This issue might be related to how the client library handles the parsing of streaming data responses. It may require adjustments in the parsing logic to accommodate responses with and without a space after the "data:" prefix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions