chore(llm): expose parse_and_call handler (closes #105) (#114)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham 2024-08-20 07:54:58 -04:00 committed by GitHub
parent 94adc992a6
commit 7c7fd6e315
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -248,6 +248,7 @@ Remember: Accurate line numbers are CRITICAL. The range start_line to end_line m
---@field api_key_name string
---@field parse_response_data AvanteResponseParser
---@field parse_curl_args fun(opts: AvanteProvider, code_opts: AvantePromptOptions): AvanteCurlOutput
---@field parse_stream_data? fun(line: string): nil
---
---@alias AvanteChunkParser fun(chunk: string): any
---@alias AvanteCompleteParser fun(err: string|nil): nil
@ -574,7 +575,17 @@ M.stream = function(question, code_lang, code_content, selected_content_content,
return
end
vim.schedule(function()
parse_and_call(data)
if ProviderConfig ~= nil then
if ProviderConfig.parse_response_data ~= nil then
Utils.warn(
"parse_stream_data and parse_response_data are mutually exclusive, and thus parse_response_data will be ignored. Make sure that you handle the incoming data correctly.",
{ once = true }
)
ProviderConfig.parse_stream_data(data)
end
else
parse_and_call(data)
end
end)
end,
on_error = function(err)