Skip to content

Commit

Permalink
ref: sunset ollero.ollama
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-souza committed Sep 26, 2024
1 parent 4f1c612 commit 4cdd65c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 74 deletions.
5 changes: 1 addition & 4 deletions lua/ollero/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@ local M = {
opts = vim.tbl_deep_extend("force", default_options, opts or {})

local registration_list = {
logger = require("shared.logger").create_logger(opts),
term = function()
return require("term.term"):new({ title = "👁️🦙 Ask Ollero " })
end,
logger = require("shared.logger").create_logger(opts),
ollama = function()
return require("ollama.ollama")
end,
ollama_old = function()
return require("ollero.ollama")
end,
}

for name, value in pairs(registration_list) do
Expand Down
31 changes: 0 additions & 31 deletions lua/ollero/ollama.lua

This file was deleted.

51 changes: 12 additions & 39 deletions lua/ollero/ollero.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
local utils = require("shared.utils")
local di = require("di")
local commands = require("ollero.commands")
local strings = require("shared.strings")
local commands = require("shared.commands")

local term = di.resolve("term")
local logger = di.resolve("logger")
local ollama_v2 = di.resolve("ollama")
local ollama = di.resolve("ollama_old")
local ollama = di.resolve("ollama")

---Manage Window and Ollama interaction
local Ollero = {}
Expand All @@ -20,7 +18,7 @@ function Ollero.init(opts)

-- setup
term.win:show()
ollama_v2.run(model)
ollama.run(model)
term.win:hide()

commands.apply_commands({
Expand Down Expand Up @@ -65,14 +63,12 @@ function Ollero.ask(opts)

term:send(question)
term.win:toggle()
-- term:send(term:termcode("<C-d>"))
-- di.resolve("ollama").ask(model, question)
end

---List Models
function Ollero.list_models()
local options = ollama_v2.list()
local online_options = ollama_v2.fetch_models()
local options = ollama.list()
local online_options = ollama.fetch_models()

options[#options] = "-----------------"

Expand All @@ -88,36 +84,36 @@ function Ollero.list_models()

term.win:show()
term:send(term:termcode("<C-d>")) -- stop
ollama_v2.run(choice) -- kickoff new model
ollama.run(choice) -- kickoff new model
end

vim.ui.select(options, { prompt = "List of Ollama Models" }, on_select)
end

---List Models
function Ollero.install_model()
local options = ollama_v2.fetch_models()
local options = ollama.fetch_models()

vim.ui.select(
options,
{ prompt = "📦 Select an Ollama Model to install" },
function(choice)
vim.notify("Installing model: " .. choice)
ollama_v2.install(choice)
ollama.install(choice)
end
)
end

---Remove Model
function Ollero.remove_model()
local options = ollama_v2.list()
local options = ollama.list()

vim.ui.select(
options,
{ prompt = "🗑️ Select an Ollama Model to remove" },
function(choice)
vim.notify("Removing model: " .. choice)
ollama_v2.remove(choice)
ollama.remove(choice)
vim.notify("Model " .. choice .. " removed")
end
)
Expand All @@ -129,7 +125,7 @@ function Ollero.build_model(opts)

vim.ui.input({ prompt = "Enter model name: " }, function(name)
vim.schedule(function()
ollama_v2.build_model(name, filename)
ollama.build_model(name, filename)
end)
end)
end
Expand All @@ -140,32 +136,9 @@ function Ollero.create_model(opts)
prompt = "Enter a prompt to generate your file (enter to skip): ",
}, function(prompt)
vim.schedule(function()
ollama_v2.create_modelfile(prompt, opts.args)
ollama.create_modelfile(prompt, opts.args)
end)
end)
end

---Run Model
function Ollero.run_model()
ollama.list(function(output)
local options = utils.split(output)

vim.ui.select(
options,
{ prompt = "Select a model to run" },
function(choice)
if choice == nil then
return
end

ollama.run(choice, function(cmd)
term:send(term:termcode("<C-d>"))
term:send(cmd)
term:send(term:termcode("<C-l>"))
end)
end
)
end)
end

return Ollero
File renamed without changes.

0 comments on commit 4cdd65c

Please sign in to comment.