Skip to content

Commit

Permalink
fix(ollama): Fix parameters passthrough (#13)
Browse files Browse the repository at this point in the history
Also add keep_alive, prompt, system prompt and template parameters.
  • Loading branch information
mdietrich16 authored Mar 15, 2024
1 parent c198b45 commit 70ab6d9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lua/cmp_ai/backends/ollama.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ local requests = require('cmp_ai.requests')

Ollama = requests:new(nil)

function Ollama:new(o, params)
function Ollama:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self
self.params = vim.tbl_deep_extend('keep', params or {}, {
self.params = vim.tbl_deep_extend('keep', o or {}, {
base_url = 'http://127.0.0.1:11434/api/generate',
model = 'codellama:7b-code',
options = {
Expand All @@ -20,7 +20,10 @@ end
function Ollama:complete(lines_before, lines_after, cb)
local data = {
model = self.params.model,
prompt = '<PRE> ' .. lines_before .. ' <SUF>' .. lines_after .. ' <MID>',
prompt = self.params.prompt and self.params.prompt(lines_before, lines_after) or '<PRE> ' .. lines_before .. ' <SUF>' .. lines_after .. ' <MID>',
keep_alive = self.params.keep_alive,
template = self.params.template,
system = self.params.system,
stream = false,
options = self.params.options,
}
Expand Down

0 comments on commit 70ab6d9

Please sign in to comment.