summaryrefslogtreecommitdiff
path: root/py/chat.py
diff options
context:
space:
mode:
authorMartin Bielik <mx.bielik@gmail.com>2023-04-11 17:30:16 +0200
committerMartin Bielik <mx.bielik@gmail.com>2023-04-11 17:30:16 +0200
commit2d644e05545be6cd699eb5e834d6ba4468f12b41 (patch)
tree0e74bccadde6e2e8555cfcccf90af3357083df94 /py/chat.py
parent8c97b5cfde56540c8e6619c8d56dc7056d49866f (diff)
downloadvim-ai-2d644e05545be6cd699eb5e834d6ba4468f12b41.tar.gz
added debug logging
Diffstat (limited to 'py/chat.py')
-rw-r--r--py/chat.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/py/chat.py b/py/chat.py
index 0e3245f..6e94665 100644
--- a/py/chat.py
+++ b/py/chat.py
@@ -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")