summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Bielik <mx.bielik@gmail.com>2023-03-20 18:23:07 +0100
committerMartin Bielik <mx.bielik@gmail.com>2023-03-20 18:23:07 +0100
commita8087e6f4ff418143eef31d363122242790c9556 (patch)
tree576b89d4878b4fc91faf34432cd625f9c835d04c
parenta726c49281b0f232ea1b84ed1c0e2438eef1d4cb (diff)
downloadvim-ai-a8087e6f4ff418143eef31d363122242790c9556.tar.gz
request timeout
Diffstat (limited to '')
-rw-r--r--py/chat.py7
-rw-r--r--py/complete.py1
-rw-r--r--py/utils.py2
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")