fix: claude parse response (#870)

This commit is contained in:
yetone 2024-11-19 06:03:03 +08:00 committed by GitHub
parent c551bbe5b6
commit e65be50a0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -78,6 +78,13 @@ M.parse_messages = function(opts)
end
M.parse_response = function(data_stream, event_state, opts)
if event_state == nil then
if data_stream:match('"content_block_delta"') then
event_state = "content_block_delta"
elseif data_stream:match('"message_stop"') then
event_state = "message_stop"
end
end
if event_state == "content_block_delta" then
local ok, json = pcall(vim.json.decode, data_stream)
if not ok then return end