@@ -36,23 +36,10 @@ return {
3636 Authorization = " Bearer ${api_key}" ,
3737 },
3838 handlers = {
39- --- @param self CodeCompanion.Adapter
40- --- @return boolean
39+ --- Use the OpenAI adapter for the bulk of the work
4140 setup = function (self )
42- local model = self .schema .model .default
43- local model_opts = self .schema .model .choices [model ]
44- if model_opts and model_opts .opts then
45- self .opts = vim .tbl_deep_extend (" force" , self .opts , model_opts .opts )
46- end
47-
48- if self .opts and self .opts .stream then
49- self .parameters .stream = true
50- self .parameters .stream_options = { include_usage = true }
51- end
52- return true
41+ return openai .handlers .setup (self )
5342 end ,
54-
55- --- Use the OpenAI adapter for the bulk of the work
5643 tokens = function (self , data )
5744 return openai .handlers .tokens (self , data )
5845 end ,
@@ -71,8 +58,8 @@ return {
7158 model = model ()
7259 end
7360
74- --- DeepSeek-R1 doesn't allow consecutive messages from the same role,
75- --- so we concatenate them into a single message
61+ -- DeepSeek-R1 doesn't allow consecutive messages from the same role,
62+ -- so we concatenate them into a single message
7663 for _ , msg in ipairs (messages ) do
7764 local last = processed [# processed ]
7865 if last and last .role == msg .role then
@@ -85,8 +72,8 @@ return {
8572 end
8673 end
8774
88- --- System role is only allowed as the first message, after this we must label
89- --- all system messages as assistant
75+ -- The system role is only allowed as the first message, after this we must label
76+ -- all system messages as assistant
9077 local has_system = false
9178 processed = vim
9279 .iter (processed )
@@ -109,6 +96,10 @@ return {
10996 return { messages = processed }
11097 end ,
11198
99+ --- Output the data from the API ready for insertion into the chat buffer
100+ --- @param self CodeCompanion.Adapter
101+ --- @param data table The streamed JSON data from the API , also formatted by the format_data handler
102+ --- @return { status : string , output : { role : string , content : string , reasoning : string ? } } | nil
112103 chat_output = function (self , data )
113104 local output = {}
114105
0 commit comments