Skip to content

Commit

Permalink
chore: add selene and fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gsuuon committed Jan 20, 2024
1 parent 810e45d commit 00c02e2
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 36 deletions.
2 changes: 0 additions & 2 deletions lua/model/core/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ function M.to_string(contents, name)
end
end

local last = contents.messages[#contents.messages]

if #contents.messages % 2 == 0 then
result = result .. '\n======\n'
end
Expand Down
28 changes: 14 additions & 14 deletions lua/model/core/scopes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,19 @@ function M.complete_arglead_prompt_names(arglead)
end

-- TODO actual tests
local function test()
-- M.set_global_user_prompts(util.module.autoload('model.prompts.starter'))
M.set_buffer_user_prompts({ codego = 'code go' })
M.set_buffer_user_prompts({ boop = 'boop prompt' })
M.add_buffer_plugin_prompts('baps', { bap = 'bap' })
M.add_buffer_plugin_prompts('boops', { boop = 'boopsbooplocal' })
-- M.add_global_plugin_prompts('baps', { bapppp = 'bapppp'})
-- M.add_global_plugin_prompts('boops', { boop = 'boopsboopglobal'})
-- what do I do about shadowing?

-- show(get_prompt_names())
-- show(M.get_prompt('bap@baps'))
-- show(M.complete_arglead_prompt_names('code'))
end
-- local function test()
-- -- M.set_global_user_prompts(util.module.autoload('model.prompts.starter'))
-- M.set_buffer_user_prompts({ codego = 'code go' })
-- M.set_buffer_user_prompts({ boop = 'boop prompt' })
-- M.add_buffer_plugin_prompts('baps', { bap = 'bap' })
-- M.add_buffer_plugin_prompts('boops', { boop = 'boopsbooplocal' })
-- -- M.add_global_plugin_prompts('baps', { bapppp = 'bapppp'})
-- -- M.add_global_plugin_prompts('boops', { boop = 'boopsboopglobal'})
-- -- what do I do about shadowing?

-- -- show(get_prompt_names())
-- -- show(M.get_prompt('bap@baps'))
-- -- show(M.complete_arglead_prompt_names('code'))
-- end

return M
1 change: 1 addition & 0 deletions lua/model/format/zephyr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ return {
),
}
end,
contents_to_strings = contents_to_strings
}
9 changes: 7 additions & 2 deletions lua/model/format/zephyr_tokenizing.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local llamacpp = require('model.providers.llamacpp')
local zephyr = require('model.format.zephyr')

-- NOTE: llamacpp may be handling text that matches stop tokens itself now? it seems to be stopping correctly with just '</s>' text between turns instead of spitting out </s>.

Expand Down Expand Up @@ -26,7 +27,7 @@ local function tokenize_messages(messages, system, url_base, cb)
local BOS = 1
local EOS = 2

local formatted_messages = contents_to_strings(messages, system)
local formatted_messages = zephyr.contents_to_strings(messages, system)

async(function(wait, resolve)
local tokens_list = {
Expand All @@ -52,7 +53,7 @@ end
---Tokenizes each message individually and adds a 2 (EOS) token between messages.
---@param messages ChatMessage[]
---@param config table
function M.chatprompt_tokenize_run(messages, config)
local function chatprompt_tokenize_run(messages, config)
local options = config.options or {}

return function(set_params)
Expand All @@ -78,3 +79,7 @@ function M.chatprompt_tokenize_run(messages, config)
end)
end
end

return {
run = chatprompt_tokenize_run
}
16 changes: 5 additions & 11 deletions lua/model/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,10 @@ local input = require('model.core.input')
local M = {}

local function yank_with_line_numbers_and_filename(register, whole_file)
local function string_or(a, b)
if not a or a == '' then
return b
else
return a
end
end

register = register or '"'

-- Capture the selected lines
local lines, filename
local lines, filename, buf_name
do
buf_name = vim.fn.expand('%')
if buf_name ~= '' then
Expand Down Expand Up @@ -86,7 +78,8 @@ local function command_request_completion(cmd_params)
return provider.request_completion(prompt, args, want_visual_selection)
end

local function command_request_multi_completion_streams(cmd_params)
---@diagnostic disable-next-line: unused-function, unused-local
local function _command_request_multi_completion_streams(cmd_params)
local prompt_names = cmd_params.fargs

local found_prompts = vim.tbl_map(function(name)
Expand All @@ -103,7 +96,8 @@ local function command_request_multi_completion_streams(cmd_params)
)
end

local function create_deprecated_command(
---@diagnostic disable-next-line: unused-function, unused-local
local function _create_deprecated_command(
deprecated_name,
new_name,
cmd_fn,
Expand Down
2 changes: 1 addition & 1 deletion lua/model/providers/codellama.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ local PRE = 32007
local MID = 32009
local SUF = 32008
local BOS = 1
local EOS = 2
-- local EOS = 2

---@param handlers StreamHandlers
---@param params { context: { before: string, after: string } } -- before and after context along with generation options: https://github.com/ggerganov/llama.cpp/tree/master/examples/server#api-endpoints
Expand Down
1 change: 0 additions & 1 deletion lua/model/providers/llamacpp.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local curl = require('model.util.curl')
local util = require('model.util')
local async = require('model.util.async')
local system = require('model.util.system')
Expand Down
6 changes: 3 additions & 3 deletions lua/model/store/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ function M.add_lua_functions(glob)
)
end

---@param glob string glob pattern to search for files, starting from current directory
---@param glob_ string glob pattern to search for files, starting from current directory
---@param to_items function converts each filepath to a list of items
local function glob_to_items(glob, to_items)
local filepaths = vim.fn.glob(glob, nil, true)
local function glob_to_items(glob_, to_items)
local filepaths = vim.fn.glob(glob_, nil, true)

local results = {}

Expand Down
4 changes: 2 additions & 2 deletions lua/tests/sse_spec.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
describe('server-sent events client', function()
local sse = require('model.util.sse')
local sse_ = require('model.util.sse')

local sse_client = function()
local results = {}

local client = sse.client({
local client = sse_.client({
on_message = function(msg)
results.messages = results.messages or {}
table.insert(results.messages, msg)
Expand Down
1 change: 1 addition & 0 deletions selene.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
std="vim"
15 changes: 15 additions & 0 deletions vim.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[selene]
base = "lua51"
name = "vim"

[vim]
any = true

[describe]
any = true

[it]
any = true

[assert]
any = true

0 comments on commit 00c02e2

Please sign in to comment.