diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2023-03-20 18:23:07 +0100 |
|---|---|---|
| committer | Martin Bielik <mx.bielik@gmail.com> | 2023-03-20 18:23:07 +0100 |
| commit | a8087e6f4ff418143eef31d363122242790c9556 (patch) | |
| tree | 576b89d4878b4fc91faf34432cd625f9c835d04c | |
| parent | a726c49281b0f232ea1b84ed1c0e2438eef1d4cb (diff) | |
| download | vim-ai-a8087e6f4ff418143eef31d363122242790c9556.tar.gz | |
request timeout
| -rw-r--r-- | py/chat.py | 7 | ||||
| -rw-r--r-- | py/complete.py | 1 | ||||
| -rw-r--r-- | py/utils.py | 2 |
3 files changed, 7 insertions, 3 deletions
@@ -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") |