Move API Key to configuration
This commit is contained in:
@@ -28,6 +28,10 @@ if user = System.get_env("LAST_FM_USER") do
|
||||
config :music_library, LastFm, user: user
|
||||
end
|
||||
|
||||
if openai_key = System.get_env("OPENAI_KEY") do
|
||||
config :music_library, OpenAI, api_key: openai_key
|
||||
end
|
||||
|
||||
config :music_library, MusicLibrary.Repo,
|
||||
load_extensions: [
|
||||
MusicLibrary.Repo.extension_path("unicode")
|
||||
|
||||
+6
-1
@@ -53,7 +53,7 @@ defmodule OpenAI do
|
||||
stream: true,
|
||||
temperature: 0.2
|
||||
},
|
||||
auth: {:bearer, System.fetch_env!("OPENAI_KEY")},
|
||||
auth: {:bearer, api_key()},
|
||||
finch_request: fun
|
||||
)
|
||||
end
|
||||
@@ -61,4 +61,9 @@ defmodule OpenAI do
|
||||
defp decode_body("", _), do: :ok
|
||||
defp decode_body("[DONE]", _), do: :ok
|
||||
defp decode_body(json, cb), do: cb.(Jason.decode!(json))
|
||||
|
||||
defp api_key do
|
||||
Application.get_env(:music_library, OpenAI)
|
||||
|> Keyword.fetch!(:api_key)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user