Skip to content

Commit 4a9dffd

Browse files
fix(api): Fetch default model in config if the state is not set yet
1 parent b8427ae commit 4a9dffd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/opencode/api.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,13 @@ function M.commands_list()
545545
end
546546

547547
function M.current_model()
548-
return state.current_model or ''
548+
if state.current_model and state.current_model ~= "" then
549+
return state.current_model
550+
else
551+
local conf = require('opencode.config_file').get_opencode_config()
552+
local model = conf and conf.model
553+
return model or ''
554+
end
549555
end
550556

551557
--- Runs a user-defined command by name.

0 commit comments

Comments
 (0)