File tree Expand file tree Collapse file tree 3 files changed +57
-1
lines changed
Expand file tree Collapse file tree 3 files changed +57
-1
lines changed Original file line number Diff line number Diff line change @@ -346,4 +346,34 @@ function M.setup()
346346 Logger .debug (" ECA commands registered" )
347347end
348348
349+ vim .api .nvim_create_user_command (" EcaChatSelectModel" , function ()
350+ local state = require (" eca.state" ):new ()
351+ local models = state .config .models .list
352+
353+ vim .ui .select (models , {
354+ prompt = " Select ECA Chat Model:" ,
355+ }, function (choice )
356+ if choice then
357+ state :update_selected_model (choice )
358+ end
359+ end )
360+ end , {
361+ desc = " Select Current ECA Chat model" ,
362+ })
363+
364+ vim .api .nvim_create_user_command (" EcaChatSelectBehavior" , function ()
365+ local state = require (" eca.state" ):new ()
366+ local behaviors = state .config .behaviors .list
367+
368+ vim .ui .select (behaviors , {
369+ prompt = " Select ECA Chat Behavior:" ,
370+ }, function (choice )
371+ if choice then
372+ state :update_selected_behavior (choice )
373+ end
374+ end )
375+ end , {
376+ desc = " Select Current ECA Chat behavior" ,
377+ })
378+
349379return M
Original file line number Diff line number Diff line change @@ -1279,6 +1279,8 @@ function M:_send_message(message)
12791279 requestId = tostring (os.time ()),
12801280 message = message ,
12811281 contexts = contexts or {},
1282+ model = self .mediator :selected_model (),
1283+ behavior = self .mediator :selected_behavior (),
12821284 }, function (err , result )
12831285 if err then
12841286 print (" err is " .. err )
Original file line number Diff line number Diff line change 168168function State :_update_usage (usage )
169169 self .usage = {
170170 tokens = {
171- limit = (usage .limit and usage .limit .output ) or self .usage .tokens .limit ,
171+ limit = (usage .limit and usage .limit .context ) or self .usage .tokens .limit ,
172172 session = usage .sessionTokens or self .usage .tokens .session ,
173173 },
174174 costs = {
@@ -198,4 +198,28 @@ function State:_update_tools(tool)
198198 end )
199199end
200200
201+ function State :update_selected_model (model )
202+ if not model or type (model ) ~= " string" then
203+ return
204+ end
205+
206+ self .config .models .selected = model
207+
208+ vim .schedule (function ()
209+ require (" eca.observer" ).notify ({ type = " state/updated" , content = { config = vim .deepcopy (self .config ) } })
210+ end )
211+ end
212+
213+ function State :update_selected_behavior (behavior )
214+ if not behavior or type (behavior ) ~= " string" then
215+ return
216+ end
217+
218+ self .config .behaviors .selected = behavior
219+
220+ vim .schedule (function ()
221+ require (" eca.observer" ).notify ({ type = " state/updated" , content = { config = vim .deepcopy (self .config ) } })
222+ end )
223+ end
224+
201225return State
You can’t perform that action at this time.
0 commit comments