From 89a86f0fc197ec9ffb3663a499432f8df4e4b1e5 Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 2 Apr 2025 20:32:58 +0800 Subject: [PATCH] fix: search engine did not return correctly (#1801) --- lua/avante/config.lua | 2 +- lua/avante/llm_tools/init.lua | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/avante/config.lua b/lua/avante/config.lua index 3658423..2c04d8b 100644 --- a/lua/avante/config.lua +++ b/lua/avante/config.lua @@ -64,7 +64,7 @@ M._defaults = { }, ---@type WebSearchEngineProviderResponseBodyFormatter format_response_body = function(body) - if body.answer_box ~= nil then return body.answer_box.result, nil end + if body.answer_box ~= nil and body.answer_box.result ~= nil then return body.answer_box.result, nil end if body.organic_results ~= nil then local jsn = vim .iter(body.organic_results) diff --git a/lua/avante/llm_tools/init.lua b/lua/avante/llm_tools/init.lua index 3f809b2..2c8c946 100644 --- a/lua/avante/llm_tools/init.lua +++ b/lua/avante/llm_tools/init.lua @@ -326,6 +326,7 @@ function M.web_search(opts, on_log) local jsn = vim.json.decode(resp.body) return search_engine.format_response_body(jsn) end + return nil, "Error: No search engine found" end ---@type AvanteLLMToolFunc<{ url: string }>