From a8087e6f4ff418143eef31d363122242790c9556 Mon Sep 17 00:00:00 2001 From: Martin Bielik Date: Mon, 20 Mar 2023 18:23:07 +0100 Subject: request timeout --- py/chat.py | 7 ++++--- py/complete.py | 1 + py/utils.py | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/py/chat.py b/py/chat.py index 551bfb8..f01276d 100644 --- a/py/chat.py +++ b/py/chat.py @@ -38,9 +38,10 @@ try: vim.command("redraw") response = openai.ChatCompletion.create( - model="gpt-3.5-turbo", - messages=messages, - stream=True, + model="gpt-3.5-turbo", + messages=messages, + stream=True, + request_timeout=request_timeout_seconds, ) generating_text = False diff --git a/py/complete.py b/py/complete.py index 9e46d63..d47eb2a 100644 --- a/py/complete.py +++ b/py/complete.py @@ -20,6 +20,7 @@ try: max_tokens=1000, temperature=0.1, stream=True, + request_timeout=request_timeout_seconds, ) generating_text = False diff --git a/py/utils.py b/py/utils.py index c9e88f2..05da3b9 100644 --- a/py/utils.py +++ b/py/utils.py @@ -1,6 +1,8 @@ import sys import os +request_timeout_seconds = 15 + def load_api_key(): config_file_path = os.path.join(os.path.expanduser("~"), ".config/openai.token") api_key = os.getenv("OPENAI_API_KEY") -- cgit v1.2.3