summaryrefslogtreecommitdiff
path: root/py/chat.py
diff options
context:
space:
mode:
authorMartin Bielik <mx.bielik@gmail.com>2023-04-13 19:00:04 +0200
committerMartin Bielik <mx.bielik@gmail.com>2023-04-13 19:00:04 +0200
commit9a872803baf77b9a687b263d11cb2ac297b57a71 (patch)
tree1cb76aff662a1bc4bb59600274293a6db927d7ed /py/chat.py
parent0058b3f6509ac2632b09048c02d3ff4fa17bdfa9 (diff)
downloadvim-ai-9a872803baf77b9a687b263d11cb2ac297b57a71.tar.gz
poc: removing openai dependency
Diffstat (limited to '')
-rw-r--r--py/chat.py6
1 files changed, 1 insertions, 5 deletions
diff --git a/py/chat.py b/py/chat.py
index 9cb07c9..955832b 100644
--- a/py/chat.py
+++ b/py/chat.py
@@ -5,8 +5,6 @@ vim.command(f"py3file {plugin_root}/py/utils.py")
config_options = vim.eval("options")
config_ui = vim.eval("ui")
-openai.api_key = load_api_key()
-
def initialize_chat_window():
lines = vim.eval('getline(1, "$")')
contains_user_prompt = '>>> user' in lines
@@ -78,7 +76,7 @@ try:
**request_options
}
printDebug("[chat] request: {}", request)
- response = openai.ChatCompletion.create(**request)
+ response = openai_request('https://api.openai.com/v1/chat/completions', request)
def map_chunk(resp):
printDebug("[chat] response: {}", resp)
return resp['choices'][0]['delta'].get('content', '')
@@ -89,5 +87,3 @@ try:
vim.command("redraw")
except KeyboardInterrupt:
vim.command("normal! a Ctrl-C...")
-except openai.error.Timeout:
- vim.command("normal! aRequest timeout...")