fix: construct handler opts in the parse function (#78)

This commit is contained in:
yetone 2024-08-19 11:22:10 +08:00 committed by GitHub
parent b71e43d69e
commit 5c57daea2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -488,7 +488,6 @@ M.stream = function(question, code_lang, code_content, selected_content_content,
code_content = code_content, code_content = code_content,
selected_code_content = selected_content_content, selected_code_content = selected_content_content,
} }
local handler_opts = { on_chunk = on_chunk, on_complete = on_complete, event_state = nil }
---@type AvanteCurlOutput ---@type AvanteCurlOutput
local spec = nil local spec = nil
@ -510,6 +509,7 @@ M.stream = function(question, code_lang, code_content, selected_content_content,
---@param line string ---@param line string
local function parse_and_call(line) local function parse_and_call(line)
local handler_opts = { on_chunk = on_chunk, on_complete = on_complete, event_state = nil }
local event = line:match("^event: (.+)$") local event = line:match("^event: (.+)$")
if event then if event then
handler_opts.event_state = event handler_opts.event_state = event