diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2023-03-21 18:36:38 +0100 |
|---|---|---|
| committer | Martin Bielik <mx.bielik@gmail.com> | 2023-03-21 18:36:38 +0100 |
| commit | 8125570fc4ca94b085857eadc563eafc2c0564a5 (patch) | |
| tree | c67323c90c13c3c06e1364cf662e4ed467b514b3 /py | |
| parent | e025530d25cedd1dcbd9d2102cd06296f3707da9 (diff) | |
| download | vim-ai-8125570fc4ca94b085857eadc563eafc2c0564a5.tar.gz | |
openai configuration
Diffstat (limited to 'py')
| -rw-r--r-- | py/chat.py | 7 | ||||
| -rw-r--r-- | py/complete.py | 11 | ||||
| -rw-r--r-- | py/utils.py | 2 |
3 files changed, 11 insertions, 9 deletions
@@ -6,6 +6,7 @@ vim.command(f"py3file {plugin_root}/py/utils.py") openai.api_key = load_api_key() +options = vim.eval("options") file_content = vim.eval('trim(join(getline(1, "$"), "\n"))') lines = file_content.splitlines() @@ -38,10 +39,12 @@ try: vim.command("redraw") response = openai.ChatCompletion.create( - model="gpt-3.5-turbo", messages=messages, stream=True, - request_timeout=request_timeout_seconds, + model=options['model'], + max_tokens=int(options['max_tokens']), + temperature=float(options['temperature']), + request_timeout=float(options['request_timeout']), ) generating_text = False diff --git a/py/complete.py b/py/complete.py index d47eb2a..f469592 100644 --- a/py/complete.py +++ b/py/complete.py @@ -5,6 +5,7 @@ plugin_root = vim.eval("s:plugin_root") vim.command(f"py3file {plugin_root}/py/utils.py") prompt = vim.eval("prompt") +options = vim.eval("options") openai.api_key = load_api_key() @@ -15,12 +16,12 @@ try: vim.command("redraw") response = openai.Completion.create( - model="text-davinci-003", - prompt=prompt, - max_tokens=1000, - temperature=0.1, stream=True, - request_timeout=request_timeout_seconds, + prompt=prompt, + model=options['model'], + max_tokens=int(options['max_tokens']), + temperature=float(options['temperature']), + request_timeout=float(options['request_timeout']), ) generating_text = False diff --git a/py/utils.py b/py/utils.py index 05da3b9..c9e88f2 100644 --- a/py/utils.py +++ b/py/utils.py @@ -1,8 +1,6 @@ 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") |