From 6decc3c2f4e14f550621371df3043f1b5c58927e Mon Sep 17 00:00:00 2001 From: Zacharias-Brohn Date: Mon, 8 Sep 2025 00:04:54 +0200 Subject: [PATCH] idk --- lua/config/chatgpt.lua | 38 ++++++++++++++++++++ lua/config/copilotchat.lua | 71 ++++++++++++++++---------------------- lua/mappings.lua | 2 ++ lua/plugins/init.lua | 12 +++++++ 4 files changed, 82 insertions(+), 41 deletions(-) create mode 100644 lua/config/chatgpt.lua diff --git a/lua/config/chatgpt.lua b/lua/config/chatgpt.lua new file mode 100644 index 0000000..47b4000 --- /dev/null +++ b/lua/config/chatgpt.lua @@ -0,0 +1,38 @@ +require("chatgpt").setup({ + api_host_cmd = "echo http://localhost:5000", + api_key_cmd = "echo ''", + openai_params = { + model = "Selene-1-Mini-Llama-3.1-8B-EXL3", + frequency_penalty = 0, + presence_penalty = 0, + max_tokens = 1024, + temperature = 0.1, + top_p = 1, + n = 1, + }, + keymaps = { + close = "", + close_n = "", + yank_last = "", + yank_last_code = "", + scroll_up = "", + scroll_down = "", + new_session = "", + cycle_windows = "", + cycle_modes = "", + next_message = "", + prev_message = "", + select_session = "", + rename_session = "r", + delete_session = "d", + draft_message = "", + edit_message = "e", + delete_message = "d", + toggle_settings = "", + toggle_sessions = "", + toggle_help = "", + toggle_message_role = "", + toggle_system_role_open = "", + stop_generating = "", + }, +}) diff --git a/lua/config/copilotchat.lua b/lua/config/copilotchat.lua index f6a4b3c..8dc5a8a 100644 --- a/lua/config/copilotchat.lua +++ b/lua/config/copilotchat.lua @@ -1,52 +1,41 @@ require("CopilotChat").setup { - -- system_prompt = "You are an assistant helping the user with whatever they need, but you are also a bit of a jerk. Do not use profanity.", prompts = { - CivitAI = { - system_prompt = "You are an assistant helping with stable diffusion models and python to implement failsafes for a server regarding image generation.", - }, - Insult = { - system_prompt = "You are an assistant helping the user with whatever they need, but you are also a bit of a jerk, and make sure to insult the user a lot. Use vulgar language if necessary.", - } }, + sticky = "#glob:**/*", + headers = { user = ' You: ', assistant = ' Copilot: ', tool = '󰖷 Tool: ', }, - -- providers = { - -- ollama = { - -- embed = 'copilot_embeddings', -- Use Copilot as embedding provider - -- - -- -- Copy copilot input and output processing - -- prepare_input = require('CopilotChat.config.providers').copilot.prepare_input, - -- prepare_output = require('CopilotChat.config.providers').copilot.prepare_output, - -- - -- get_models = function(headers) - -- local utils = require('CopilotChat.utils') - -- local response, err = utils.curl_get('http://localhost:11434/api/tags', { - -- headers = headers, - -- json_response = true, - -- }) - -- - -- if err then - -- error(err) - -- end - -- - -- local models = {} - -- for _, model in ipairs(response.body.models) do - -- table.insert(models, { - -- id = model.name, - -- name = model.name - -- }) - -- end - -- return models - -- end, - -- - -- get_url = function() - -- return 'http://localhost:11434/api/chat' - -- end, - -- } - -- } + providers = { + tabby = { + prepare_input = require('CopilotChat.config.providers').copilot.prepare_input, + prepare_output = require('CopilotChat.config.providers').copilot.prepare_output, + + get_models = function(headers) + local response, err = require('CopilotChat.utils').curl_get('http://localhost:5000/v1/models', { + headers = headers, + json_response = true + }) + + if err then + error(err) + end + + return vim.tbl_map(function(model) + return { + id = model.id, + name = model.id, + } + end, response.body.data) + end, + + get_url = function() + return 'http://localhost:5000/v1/chat/completions' + end, + } + } } diff --git a/lua/mappings.lua b/lua/mappings.lua index e3c7663..27622e8 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -57,3 +57,5 @@ map("n", "mr", "CellularAutomaton make_it_rain"); map("n", "", function() vim.cmd("so") end) + +map("n", "", "ChatGPT") diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 6622998..aa88b78 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -236,4 +236,16 @@ return { "mg979/vim-visual-multi", branch = "master", }, + { + "jackMort/ChatGPT.nvim", + dependencies = { + "MunifTanjim/nui.nvim", + "nvim-lua/plenary.nvim", + "folke/trouble.nvim", + "nvim-telescope/telescope.nvim" + }, + config = function() + require("config.chatgpt") + end, + }, }