You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
3.2 KiB
Lua
108 lines
3.2 KiB
Lua
local ok, neoai = pcall(require, "neoai")
|
|
if not ok then
|
|
vim.notify("missing module neoai", vim.log.levels.WARN)
|
|
return
|
|
end
|
|
|
|
|
|
local config = {
|
|
-- Below are the default options, feel free to override what you would like changed
|
|
ui = {
|
|
output_popup_text = "NeoAI",
|
|
input_popup_text = "Prompt",
|
|
width = 30, -- As percentage eg. 30%
|
|
output_popup_height = 80, -- As percentage eg. 80%
|
|
submit = "<Enter>", -- Key binding to submit the prompt
|
|
},
|
|
models = {
|
|
-- {
|
|
-- name = "openai",
|
|
-- model = "gpt-3.5-turbo",
|
|
-- params = nil,
|
|
-- },
|
|
{
|
|
name = "openai",
|
|
model = "dolphin-mixtral",
|
|
params = {
|
|
temperature = 0.2
|
|
},
|
|
}
|
|
},
|
|
register_output = {
|
|
["g"] = function(output)
|
|
return output
|
|
end,
|
|
["c"] = require("neoai.utils").extract_code_snippets,
|
|
},
|
|
inject = {
|
|
cutoff_width = 75,
|
|
},
|
|
prompts = {
|
|
context_prompt = function(context)
|
|
return "Hey, I'd like to provide some context for future "
|
|
.. "messages. Here is the code/text that I want to refer "
|
|
.. "to in our upcoming conversations:\n\n"
|
|
.. context
|
|
end,
|
|
},
|
|
mappings = {
|
|
["select_up"] = "<C-k>",
|
|
["select_down"] = "<C-j>",
|
|
},
|
|
open_ai = {
|
|
api_base = "http://localai.srvlan:8080/v1",
|
|
api_key = {
|
|
env = "OPENAI_API_KEY",
|
|
value = nil,
|
|
-- `get` is is a function that retrieves an API key, can be used to override the default method.
|
|
-- get = function() ... end
|
|
|
|
-- Here is some code for a function that retrieves an API key. You can use it with
|
|
-- the Linux 'pass' application.
|
|
-- get = function()
|
|
-- local key = vim.fn.system("pass show openai/mytestkey")
|
|
-- key = string.gsub(key, "\n", "")
|
|
-- return key
|
|
-- end,
|
|
},
|
|
},
|
|
shortcuts = {
|
|
{
|
|
name = "textify",
|
|
key = "<leader>as",
|
|
desc = "fix text with AI",
|
|
use_context = true,
|
|
prompt = [[
|
|
Please rewrite the text to make it more readable, clear,
|
|
concise, and fix any grammatical, punctuation, or spelling
|
|
errors
|
|
]],
|
|
modes = { "v" },
|
|
strip_function = nil,
|
|
},
|
|
{
|
|
name = "gitcommit",
|
|
key = "<leader>ag",
|
|
desc = "generate git commit message",
|
|
use_context = false,
|
|
prompt = function()
|
|
return [[
|
|
Using the following git diff generate a consise and
|
|
clear git commit message, with a short title summary
|
|
that is 75 characters or less:
|
|
]] .. vim.fn.system("git diff --cached")
|
|
end,
|
|
modes = { "n" },
|
|
strip_function = nil,
|
|
},
|
|
},
|
|
}
|
|
|
|
local M = {}
|
|
|
|
M.setup = function()
|
|
neoai.setup(config)
|
|
end
|
|
|
|
return M
|