feat(parrot): v2.5.1
This commit is contained in:
@@ -1,45 +1,50 @@
|
||||
return {
|
||||
'frankroeder/parrot.nvim',
|
||||
version = '2.3.0',
|
||||
version = '2.5.1',
|
||||
dependencies = { 'ibhagwan/fzf-lua', 'nvim-lua/plenary.nvim' },
|
||||
opts = {
|
||||
providers = {
|
||||
anthropic = {
|
||||
name = 'anthropic',
|
||||
endpoint = 'https://api.anthropic.com/v1/messages',
|
||||
model_endpoint = 'https://api.anthropic.com/v1/models',
|
||||
api_key = { '/usr/local/bin/sops', '--config', '/dev/null', '-d', vim.fn.expand('$HOME') .. '/.claude-api' },
|
||||
headers = function(self)
|
||||
return {
|
||||
['Content-Type'] = 'application/json',
|
||||
['x-api-key'] = self.api_key,
|
||||
['anthropic-version'] = '2023-06-01',
|
||||
}
|
||||
end,
|
||||
params = {
|
||||
chat = { max_tokens = 4096 },
|
||||
command = { max_tokens = 4096 },
|
||||
},
|
||||
models = {
|
||||
'claude-opus-4-6',
|
||||
'claude-sonet-4-5',
|
||||
'claude-haiku-4-5',
|
||||
},
|
||||
preprocess_payload = function(payload)
|
||||
for _, message in ipairs(payload.messages) do
|
||||
message.content = message.content:gsub('^%s*(.-)%s*$', "%1")
|
||||
end
|
||||
if payload.messages[1] and payload.messages[1].role == 'system' then
|
||||
-- remove the first message that serves as the system prompt as anthropic
|
||||
-- expects the system prompt to be part of the API call body and not the messages
|
||||
payload.system = payload.messages[1].content
|
||||
table.remove(payload.messages, 1)
|
||||
end
|
||||
return payload
|
||||
end,
|
||||
}
|
||||
},
|
||||
user_input_ui = 'buffer',
|
||||
}
|
||||
config = function()
|
||||
local parrot_opts = {
|
||||
providers = {
|
||||
anthropic = {
|
||||
name = 'anthropic',
|
||||
endpoint = 'https://api.anthropic.com/v1/messages',
|
||||
model_endpoint = 'https://api.anthropic.com/v1/models',
|
||||
api_key = { '/usr/local/bin/sops', '--config', '/dev/null', '-d', vim.fn.expand('$HOME') .. '/.claude-api' },
|
||||
headers = function(self)
|
||||
return {
|
||||
['Content-Type'] = 'application/json',
|
||||
['x-api-key'] = self.api_key,
|
||||
['anthropic-version'] = '2023-06-01',
|
||||
}
|
||||
end,
|
||||
params = {
|
||||
chat = { max_tokens = 4096 },
|
||||
command = { max_tokens = 4096 },
|
||||
},
|
||||
models = {
|
||||
'claude-opus-4-6',
|
||||
'claude-sonet-4-5',
|
||||
'claude-haiku-4-5',
|
||||
},
|
||||
preprocess_payload = function(payload)
|
||||
for _, message in ipairs(payload.messages) do
|
||||
message.content = message.content:gsub('^%s*(.-)%s*$', "%1")
|
||||
end
|
||||
if payload.messages[1] and payload.messages[1].role == 'system' then
|
||||
-- remove the first message that serves as the system prompt as anthropic
|
||||
-- expects the system prompt to be part of the API call body and not the messages
|
||||
payload.system = payload.messages[1].content
|
||||
table.remove(payload.messages, 1)
|
||||
end
|
||||
return payload
|
||||
end,
|
||||
}
|
||||
},
|
||||
user_input_ui = 'buffer',
|
||||
}
|
||||
|
||||
local parrot = require('parrot')
|
||||
parrot.setup(parrot_opts)
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user