Skip to content

Commit

Permalink
allow for arbitrary headers to be added to requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Kofron committed Oct 13, 2024
1 parent e45b158 commit 7f20ed7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/openai_ex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ defmodule OpenaiEx do
openai |> Map.put(:base_url, base_url)
end

def with_additional_headers(openai = %OpenaiEx{}, additional_headers) do
openai |> Map.get_and_update(
:_http_headers,
fn headers ->
{headers, headers ++ additional_headers}
end
) |> elem(1)
end

def with_receive_timeout(openai = %OpenaiEx{}, timeout)
when is_integer(timeout) and timeout > 0 do
openai |> Map.put(:receive_timeout, timeout)
Expand Down

0 comments on commit 7f20ed7

Please sign in to comment.