@@ -86,6 +86,23 @@ General Guidelines:
8686 },
8787}
8888
89+ --- Returns the adapter if it works with summarysation.
90+ --- @return CodeCompanion.HTTPAdapter | nil
91+ local function check_adapter_for_summarisation (adapter )
92+ local resolved_adapter = require (" codecompanion.adapters" ).resolve (adapter )
93+ if resolved_adapter .type == nil or resolved_adapter .type == " http" then
94+ return vim .deepcopy (resolved_adapter ) --[[ @as CodeCompanion.HTTPAdapter]]
95+ else
96+ vim .schedule_wrap (vim .notify )(
97+ [[ VectorCode query summarisation doesn't work with ACP adapters yet.
98+ Summarysation will be disabled.
99+ Please configure an HTTP adapter for it.]] ,
100+ vim .log .levels .WARN ,
101+ vc_config .notify_opts
102+ )
103+ end
104+ end
105+
89106--- @param opts VectorCode.CodeCompanion.QueryToolOpts |{}| nil
90107--- @return VectorCode.CodeCompanion.QueryToolOpts
91108local get_query_tool_opts = function (opts )
228245
229246--- @alias ChatMessage { role : string , content : string }
230247
231- --- @param adapter CodeCompanion.Adapter
248+ --- @param adapter CodeCompanion.HTTPAdapter
232249--- @param system_prompt string
233250--- @param user_messages string | string[]
234251--- @return { messages : ChatMessage[] , tools : table ?}
@@ -263,9 +280,12 @@ local function generate_summary(result, summarise_opts, cmd, callback)
263280 and type (callback ) == " function"
264281 and # result > 0
265282 then
266- --- @type CodeCompanion.Adapter
267- local adapter =
268- vim .deepcopy (require (" codecompanion.adapters" ).resolve (summarise_opts .adapter ))
283+ --- @type CodeCompanion.HTTPAdapter ?
284+ local adapter = check_adapter_for_summarisation (summarise_opts .adapter )
285+ if adapter == nil then
286+ summarise_opts .enabled = false
287+ return callback (result_xml )
288+ end
269289
270290 local system_prompt = summarise_opts .system_prompt
271291 if type (system_prompt ) == " function" then
@@ -293,10 +313,10 @@ When summarising the code, pay extra attention on information related to the que
293313 vim .deepcopy (adapter :map_schema_to_params (cc_schema .get_default (adapter )))
294314 settings .opts .stream = false
295315
296- --- @type CodeCompanion.Client
316+ --- @type CodeCompanion.HTTPClient
297317 local client = http_client .new ({ adapter = settings })
298318 client :request (payload , {
299- --- @param _adapter CodeCompanion.Adapter
319+ --- @param _adapter CodeCompanion.HTTPAdapter
300320 callback = function (_ , data , _adapter )
301321 if data then
302322 local res = _adapter .handlers .chat_output (_adapter , data )
0 commit comments