Nvim : Integrate ollama.

This commit is contained in:
Dmitry Voronin 2024-02-29 08:49:14 +03:00
parent ddb61d4091
commit ab328fa858
6 changed files with 25 additions and 5 deletions

View file

@ -48,6 +48,10 @@
url = "git+https://git.voronind.com/mirror/lualine.nvim.git";
flake = false;
};
nvimOllama = {
url = "git+https://git.voronind.com/mirror/ollama.nvim.git";
flake = false;
};
nvimPlenary = {
url = "git+https://git.voronind.com/mirror/plenary.nvim.git";
flake = false;

View file

@ -17,8 +17,7 @@
after = [ "NetworkManager-wait-online.service" "ollama.service" ];
serviceConfig.Type = "simple";
script = ''
${lib.getExe pkgs.ollama} pull llama2-uncensored
${lib.getExe pkgs.ollama} pull codellama
${lib.getExe pkgs.ollama} pull mistral
'';
};
}

View file

@ -9,7 +9,7 @@ in {
vimAlias = true;
configure = {
customRC = ''
set runtimepath+=~/.cache/nvim,~/.cache/nvim/treesitter,${inputs.nvimTrouble},${inputs.nvimAlign},${inputs.nvimAutoclose},${inputs.nvimBufferline},${inputs.nvimCloseBuffers},${inputs.nvimDevicons},${inputs.nvimGitsigns},${inputs.nvimGruvbox},${inputs.nvimIndentoMatic},${inputs.nvimLspconfig},${inputs.nvimLualine},${inputs.nvimPlenary},${inputs.nvimSingleComment},${inputs.nvimTelescope},${inputs.nvimTodo},${inputs.nvimTokyonight},${inputs.nvimTree},${inputs.nvimTreesitter},${inputs.nvimWhichKey}
set runtimepath+=~/.cache/nvim,~/.cache/nvim/treesitter,${inputs.nvimTrouble},${inputs.nvimAlign},${inputs.nvimAutoclose},${inputs.nvimBufferline},${inputs.nvimCloseBuffers},${inputs.nvimDevicons},${inputs.nvimGitsigns},${inputs.nvimGruvbox},${inputs.nvimIndentoMatic},${inputs.nvimLspconfig},${inputs.nvimLualine},${inputs.nvimOllama},${inputs.nvimPlenary},${inputs.nvimSingleComment},${inputs.nvimTelescope},${inputs.nvimTodo},${inputs.nvimTokyonight},${inputs.nvimTree},${inputs.nvimTreesitter},${inputs.nvimWhichKey}
lua dofile("${nvimSrc}/key/Rekey.lua")
lua dofile("${nvimSrc}/key/Leader.lua")
@ -34,6 +34,7 @@ in {
lua dofile("${nvimSrc}/plugin/Align.lua")
lua dofile("${nvimSrc}/plugin/Treesitter.lua")
lua dofile("${nvimSrc}/plugin/Fold.lua")
lua dofile("${nvimSrc}/plugin/Ollama.lua")
lua dofile("${nvimSrc}/key/Autocomplete.lua")
lua dofile("${nvimSrc}/key/Buffer.lua")
lua dofile("${nvimSrc}/key/Comment.lua")
@ -43,6 +44,7 @@ in {
lua dofile("${nvimSrc}/key/Gitsigns.lua")
lua dofile("${nvimSrc}/key/Lsp.lua")
lua dofile("${nvimSrc}/key/Navigation.lua")
lua dofile("${nvimSrc}/key/Ollama.lua")
lua dofile("${nvimSrc}/key/Sort.lua")
lua dofile("${nvimSrc}/key/Telescope.lua")
lua dofile("${nvimSrc}/key/Terminal.lua")

View file

@ -2,7 +2,7 @@
# Usage: ask <QUERY>
function ask() {
curl http://localhost:11434/api/generate -d "{
\"model\": \"llama2-uncensored\",
\"model\": \"mistral\",
\"prompt\":\"${*}\"
}" 2> /dev/null | parallel -j1 -- "echo {} | jq -r .response | tr -d '\n'"
echo
@ -12,7 +12,7 @@ function ask() {
# Usage: ask_code <QUERY>
function ask_code() {
curl http://localhost:11434/api/generate -d "{
\"model\": \"codellama\",
\"model\": \"mistral\",
\"prompt\":\"${*}\"
}" 2> /dev/null | parallel -j1 -- "echo {} | jq -r .response | tr -d '\n'"
echo

View file

@ -0,0 +1,2 @@
rekey_normal("<Leader>p", ":<c-u>lua require('ollama').prompt()<cr>")
rekey_visual("<Leader>p", ":<c-u>lua require('ollama').prompt()<cr>")

View file

@ -0,0 +1,13 @@
require("ollama").setup {
model = "mistral",
url = "http://127.0.0.1:11434",
-- View the actual default prompts in ./lua/ollama/prompts.lua
prompts = {
Sample_Prompt = {
prompt = "This is a sample prompt that receives $input and $sel(ection), among others.",
input_label = "> ",
model = "mistral",
action = "display",
}
}
}