diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2023-04-11 17:30:16 +0200 |
|---|---|---|
| committer | Martin Bielik <mx.bielik@gmail.com> | 2023-04-11 17:30:16 +0200 |
| commit | 2d644e05545be6cd699eb5e834d6ba4468f12b41 (patch) | |
| tree | 0e74bccadde6e2e8555cfcccf90af3357083df94 /py/chat.py | |
| parent | 8c97b5cfde56540c8e6619c8d56dc7056d49866f (diff) | |
| download | vim-ai-2d644e05545be6cd699eb5e834d6ba4468f12b41.tar.gz | |
added debug logging
Diffstat (limited to 'py/chat.py')
| -rw-r--r-- | py/chat.py | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -74,8 +74,17 @@ try: print('Answering...') vim.command("redraw") - response = openai.ChatCompletion.create(messages=messages, stream=True, **request_options) - text_chunks = map(lambda resp: resp['choices'][0]['delta'].get('content', ''), response) + request = { + 'stream': True, + 'messages': messages, + **request_options + } + printDebug("[chat] request: {}", request) + response = openai.ChatCompletion.create(**request) + def map_chunk(resp): + printDebug("[chat] response: {}", resp) + return resp['choices'][0]['delta'].get('content', '') + text_chunks = map(map_chunk, response) render_text_chunks(text_chunks) vim.command("normal! a\n\n>>> user\n\n") |