Skip to content

Commit

Permalink
feat(config): extend preset with global config
Browse files Browse the repository at this point in the history
  • Loading branch information
S1M0N38 committed Jan 30, 2024
1 parent 5803169 commit 00c1a71
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions lua/dante/config.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
local M = {}

local defaults = {

presets = {
default = {
model = "gpt-3.5-turbo",
prompt = "You are an helpful assistant.",
temperature = 1,
stream = false,
-- if not specified, will use global config
-- model = "gpt-3.5-turbo",
-- prompt = "You are an helpful assistant.",
-- temperature = 1,
-- stream = false,
-- base_url = "https://api.openai.com/v1",
-- diffopt = { ... },
},
-- another_preset = {
-- -- you can define as many presets as you want
-- -- defining config here will override global config for this preset
-- },
},
openai_api_key = "OPENAI_API_KEY",

-- Globals config will be used as default for all presets
model = "gpt-3.5-turbo",
prompt = "You are an helpful assistant.",
temperature = 1,
stream = false,
env_var = "OPENAI_API_KEY",
base_url = "https://api.openai.com/v1",
diffopt = { "internal", "filler", "closeoff", "algorithm:patience", "followwrap", "linematch:120" },
}
Expand All @@ -18,6 +32,13 @@ M.options = {}

function M.setup(options)
M.options = vim.tbl_deep_extend("force", {}, defaults, options or {})
for _, preset in pairs(M.options.presets) do
for opt, value in pairs(M.options) do
if opt ~= "presets" then
preset[opt] = preset[opt] or value
end
end
end
end

return M

0 comments on commit 00c1a71

Please sign in to comment.