Skip to content

Commit

Permalink
Updating the tesla adapter protocols to use http1
Browse files Browse the repository at this point in the history
There's a well documented error with Tesla where the http2 cannot send more than 65535 bytes. The issue is documented here: elixir-tesla/tesla#394

This is a workaround until Tesla gets their workaround implemented.
  • Loading branch information
OmegaNalphA committed Oct 13, 2023
1 parent b4ef4e5 commit 755d44b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/openai/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ defmodule OpenAI.Client do
def with_stream_opts(%{stream: true}, opts) do
# This looks weird, but is the format that Tesla requires in order to
# properly set the adapter options.
Keyword.put(opts, :opts, adapter: [body_as: :stream])
# The protocols is part of an open issue with Tesla where HTTP2 cannot upload more than 65535 bytes
Keyword.put(opts, :opts, adapter: [body_as: :stream, protocols: [:http1]])
end

def with_stream_opts(_params, opts), do: opts
def with_stream_opts(_params, opts), do
# The protocols is part of an open issue with Tesla where HTTP2 cannot upload more than 65535 bytes
Keyword.put(opts, :opts, adapter: [protocols: [:http1]])
end
end

0 comments on commit 755d44b

Please sign in to comment.