summaryrefslogtreecommitdiff
path: root/py/chat.py
diff options
context:
space:
mode:
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")