nvim ai: 更換相容模型
This commit is contained in:
parent
37a9abb546
commit
a76e5071f5
@ -1,6 +1,7 @@
|
|||||||
-- if true then return {} end -- 暫時停用
|
-- if true then return {} end -- 暫時停用
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
|
-- 呼叫AI聊天視窗用
|
||||||
"yetone/avante.nvim",
|
"yetone/avante.nvim",
|
||||||
|
|
||||||
-- Key Bindings
|
-- Key Bindings
|
||||||
@ -29,22 +30,13 @@ return {
|
|||||||
{ "<C-A-i>", "<cmd>AvanteToggle<cr>", desc = "Avante Chat Toggle" },
|
{ "<C-A-i>", "<cmd>AvanteToggle<cr>", desc = "Avante Chat Toggle" },
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
provider = "openai",
|
provider = "ollama",
|
||||||
openai = {
|
|
||||||
endpoint = {{ print .ollamaUrl "/v1" | quote }},
|
|
||||||
model = "qwen2.5-coder:7b", -- your desired model (or use gpt-4o, etc.)
|
|
||||||
timeout = 30000, -- Timeout in milliseconds, increase this for reasoning models
|
|
||||||
-- temperature = 0,
|
|
||||||
-- max_completion_tokens = 8192, -- Increase this to include reasoning tokens (for reasoning models)
|
|
||||||
-- reasoning_effort = "medium", -- low|medium|high, only used for reasoning models
|
|
||||||
disable_tools = true, -- Open-source models often do not support tools.
|
|
||||||
},
|
|
||||||
|
|
||||||
auto_suggestions_provider = "ollama",
|
|
||||||
ollama = {
|
ollama = {
|
||||||
|
{{ if .ollamaKey -}}
|
||||||
api_key_name = "OLLAMA_API_KEY",
|
api_key_name = "OLLAMA_API_KEY",
|
||||||
|
{{ end -}}
|
||||||
endpoint = {{ .ollamaUrl | quote }},
|
endpoint = {{ .ollamaUrl | quote }},
|
||||||
model = "qwen2.5-coder:1.5b",
|
model = "qwen2.5-coder:7b",
|
||||||
disable_tools = true, -- Open-source models often do not support tools.
|
disable_tools = true, -- Open-source models often do not support tools.
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -57,6 +49,15 @@ return {
|
|||||||
minimize_diff = true, -- Whether to remove unchanged lines when applying a code block
|
minimize_diff = true, -- Whether to remove unchanged lines when applying a code block
|
||||||
enable_token_counting = true, -- Whether to enable token counting. Default to true.
|
enable_token_counting = true, -- Whether to enable token counting. Default to true.
|
||||||
},
|
},
|
||||||
|
mappings = {
|
||||||
|
--- @class AvanteConflictMappings
|
||||||
|
suggestion = {
|
||||||
|
accept = "<C-l>",
|
||||||
|
next = "<C-]>",
|
||||||
|
prev = "<C-[>",
|
||||||
|
dismiss = "<C-'>",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
|
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
|
||||||
build = "make",
|
build = "make",
|
||||||
@ -101,8 +102,7 @@ return {
|
|||||||
},
|
},
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
-- 這裡動態設定 Neovim 的環境變數(不會傳給 shell)
|
-- 這裡動態設定 Neovim 的環境變數(不會傳給 shell)
|
||||||
vim.env.OPENAI_API_KEY = {{ .ollamaKey | quote }}
|
{{ if .ollamaKey }}vim.env.OLLAMA_API_KEY = {{ .ollamaKey | quote }}{{ end }}
|
||||||
vim.env.OLLAMA_API_KEY = {{ .ollamaKey | quote }}
|
|
||||||
require("avante").setup(opts)
|
require("avante").setup(opts)
|
||||||
|
|
||||||
-- -- 配置 Copilot
|
-- -- 配置 Copilot
|
||||||
@ -111,22 +111,30 @@ return {
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
-- 自動補全用
|
||||||
'huggingface/llm.nvim',
|
'huggingface/llm.nvim',
|
||||||
dependencies = { 'kevinhwang91/nvim-ufo' }, -- 確保 ufo 先載入
|
dependencies = { 'kevinhwang91/nvim-ufo' }, -- 確保 ufo 先載入
|
||||||
event = 'VeryLazy', -- 啟動後自動載入
|
event = 'VeryLazy', -- 啟動後自動載入
|
||||||
opts = {
|
opts = {
|
||||||
model = "qwen2.5-coder:1.5b",
|
|
||||||
backend = "openai",
|
backend = "openai",
|
||||||
|
-- chat_mode = true,
|
||||||
|
-- model = "qwen2.5-coder:1.5b", -- 實測發現不相容,先關掉
|
||||||
|
-- model = "codellama:7b",
|
||||||
|
-- model = "starcoder2:3b",
|
||||||
|
model = "starcoder:1b",
|
||||||
url = {{ .ollamaUrl | quote }}, -- llm-ls uses "/api/generate"
|
url = {{ .ollamaUrl | quote }}, -- llm-ls uses "/api/generate"
|
||||||
api_token = {{ .ollamaKey | quote }},
|
{{ if .ollamaKey }}api_token = {{ .ollamaKey | quote }},{{ end }}
|
||||||
-- -- cf https://github.com/ollama/ollama/blob/main/docs/api.md#parameters
|
-- -- cf https://github.com/ollama/ollama/blob/main/docs/api.md#parametersu can set any field:value pair here it will be passed as is to the backend
|
||||||
request_body = {
|
request_body = {
|
||||||
-- Modelfile options for the model you use
|
-- Modelfile options for the model you use
|
||||||
options = {
|
options = {
|
||||||
temperature = 0.2,
|
temperature = 0.2,
|
||||||
top_p = 0.95,
|
top_p = 0.95,
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
-- on_response = function(output)
|
||||||
|
-- return output:gsub("^```[%w]*\n?", ""):gsub("```$", "")
|
||||||
|
-- end,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user