From 9a872803baf77b9a687b263d11cb2ac297b57a71 Mon Sep 17 00:00:00 2001 From: Martin Bielik Date: Thu, 13 Apr 2023 19:00:04 +0200 Subject: poc: removing openai dependency --- py/chat.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'py/chat.py') 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...") -- cgit v1.2.3