33 lines
937 B
Lua
33 lines
937 B
Lua
|
|
local bash_provider = {
|
||
|
|
request_completion = function(handlers, params, options)
|
||
|
|
local input = params.input
|
||
|
|
local command = "~/test '" .. input .. "'"
|
||
|
|
local handle = io.popen(command)
|
||
|
|
local result = handle:read("*a")
|
||
|
|
handle:close()
|
||
|
|
|
||
|
|
local response = vim.json.decode(result)
|
||
|
|
handlers.on_partial(response.message.content)
|
||
|
|
handlers.on_finish()
|
||
|
|
end
|
||
|
|
}
|
||
|
|
|
||
|
|
require('model').setup({
|
||
|
|
chats = {
|
||
|
|
mybash = {
|
||
|
|
provider = bash_provider,
|
||
|
|
create = function(input, context)
|
||
|
|
return {
|
||
|
|
messages = {
|
||
|
|
{ role = 'user', content = input }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
end,
|
||
|
|
run = function(messages, config)
|
||
|
|
local last_message = messages[#messages]
|
||
|
|
return { input = last_message.content }
|
||
|
|
end
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|