Enforce timeouts when using the OpenAI api
This commit is contained in:
@@ -32,6 +32,10 @@ defmodule OpenAI.API do
|
|||||||
end
|
end
|
||||||
|
|
||||||
Req.post!("https://api.openai.com/v1/chat/completions",
|
Req.post!("https://api.openai.com/v1/chat/completions",
|
||||||
|
receive_timeout: 1000,
|
||||||
|
connect_options: [
|
||||||
|
timeout: 2500
|
||||||
|
],
|
||||||
json: %{
|
json: %{
|
||||||
model: completion.model,
|
model: completion.model,
|
||||||
messages: [Map.take(completion, [:content, :role])],
|
messages: [Map.take(completion, [:content, :role])],
|
||||||
|
|||||||
Reference in New Issue
Block a user