From fea9041ee1504abf93848b73245d0a6453f4dfec Mon Sep 17 00:00:00 2001 From: Roman Rizzi Date: Mon, 20 Mar 2023 16:43:51 -0300 Subject: [PATCH] DEV: Use 10s timeout when using the completions API (#19) --- lib/shared/inference/openai_completions.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/shared/inference/openai_completions.rb b/lib/shared/inference/openai_completions.rb index 4a6772e7..097b6340 100644 --- a/lib/shared/inference/openai_completions.rb +++ b/lib/shared/inference/openai_completions.rb @@ -9,8 +9,10 @@ module ::DiscourseAi "Content-Type" => "application/json", } + connection_opts = { request: { write_timeout: 10, read_timeout: 10, open_timeout: 10 } } + response = - Faraday.post( + Faraday.new(nil, connection_opts).post( "https://api.openai.com/v1/chat/completions", { model: model, messages: content }.to_json, headers,