diff options
Diffstat (limited to 'py/chat.py')
| -rw-r--r-- | py/chat.py | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -4,10 +4,18 @@ import openai plugin_root = vim.eval("s:plugin_root") vim.command(f"py3file {plugin_root}/py/utils.py") -options = make_options() +options = vim.eval("options") +request_options = make_request_options() openai.api_key = load_api_key() +file_content = vim.eval('trim(join(getline(1, "$"), "\n"))') +initial_prompt = '\n'.join(options['initial_prompt']) +prompt = f"{initial_prompt}\n{file_content}" + +lines = prompt.splitlines() +messages = [] + def parse_messages(): file_content = vim.eval('trim(join(getline(1, "$"), "\n"))') lines = file_content.splitlines() @@ -49,7 +57,7 @@ try: print('Answering...') vim.command("redraw") - response = openai.ChatCompletion.create(messages=messages, stream=True, **options) + response = openai.ChatCompletion.create(messages=messages, stream=True, **request_options) generating_text = False for resp in response: |