Skip to content

Commit

Permalink
Add default receive_timeout and app var
Browse files Browse the repository at this point in the history
Defaults to 10 minutes, because...well...OpenAI reliability...🤡
  • Loading branch information
jwilger committed Feb 18, 2024
1 parent ad3f960 commit c8eeec0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ config :open_ai_client,
System.get_env("OPENAI_API_KEY") || raise("OPENAI_API_KEY is not set")

config :open_ai_client, :openai_organization_id, System.get_env("OPENAI_ORGANIZATION_ID")

config :open_ai_client, :receive_timeout, System.get_env("OPENAI_RECEIVE_TIMEOUT") || 600_000
6 changes: 5 additions & 1 deletion lib/open_ai_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ defmodule OpenAiClient do
retry_log_level: nil,
into: nil,
retry: :transient,
receive_timeout: nil,
receive_timeout: default_receive_timeout(),
base_url: default_base_url(),
auth: {:bearer, default_api_key()}
])
Expand All @@ -95,6 +95,10 @@ defmodule OpenAiClient do
Enum.reject(options, fn {_key, value} -> value == nil end)
end

defp default_receive_timeout do
Application.get_env(:open_ai_client, :receive_timeout)
end

defp default_base_url do
Application.get_env(:open_ai_client, :base_url)
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule OpenAiClient.MixProject do
[
app: :open_ai_client,
description: "OpenAI API client for Elixir",
version: "2.0.1",
version: "2.1.0",
elixir: "~> 1.15",
start_permanent: Mix.env() == :prod,
aliases: aliases(),
Expand Down

0 comments on commit c8eeec0

Please sign in to comment.