cyberchitta / openai_ex

Community maintained Elixir library for OpenAI API
https://hexdocs.pm/openai_ex
Apache License 2.0
132 stars 18 forks source link

Malformed payload in Run Stream #92

Closed restlessronin closed 4 months ago

restlessronin commented 4 months ago
          Hey @eddy147 thanks for the work on the stream. Unfortunately I'm still experiencing the same malformed payload on `v0.6.3`
    run_req =
      Runs.new(
        thread_id: thread_id,
        assistant_id: @assistant_id,
        model: @model_o
      )

    run_stream = openai() |> Runs.create(run_req, stream: true)

    run_stream.body_stream
    |> Stream.flat_map(& &1)
    |> Stream.each(&IO.inspect/1)
    |> Stream.run()
%{
  eventType: "thread.run.completed\ndata: {\"id\":\

_Originally posted by @xantrac in https://github.com/restlessronin/openai_ex/issues/89#issuecomment-2115343357_

restlessronin commented 4 months ago

@xantrac it looks like the run streaming format is not compliant with the SSE spec. I have asked about it on the OpenAI forums

In any case, I have applied a workaround that returns json with both 'event' and 'data' fields. Let me know if this fix works for you.

This has been published as v0.6.4.

Once again, thanks for bringing this to my attention.🙏🏾