parrot: reformat

This commit is contained in:
2025-10-15 10:13:22 +03:00
parent 89a49ccc5d
commit 42ca780fac

View File

@@ -1,19 +1,19 @@
return { return {
'frankroeder/parrot.nvim', 'frankroeder/parrot.nvim',
version = "2.3.0", version = '2.3.0',
dependencies = { 'ibhagwan/fzf-lua', 'nvim-lua/plenary.nvim' }, dependencies = { 'ibhagwan/fzf-lua', 'nvim-lua/plenary.nvim' },
opts = { opts = {
providers = { providers = {
anthropic = { anthropic = {
name = "anthropic", name = 'anthropic',
endpoint = "https://api.anthropic.com/v1/messages", endpoint = 'https://api.anthropic.com/v1/messages',
model_endpoint = "https://api.anthropic.com/v1/models", model_endpoint = 'https://api.anthropic.com/v1/models',
api_key = { "/usr/local/bin/sops", "--config", "/dev/null", "-d", vim.fn.expand("$HOME") .. "/.claude-api" }, api_key = { '/usr/local/bin/sops', "--config", "/dev/null", "-d", vim.fn.expand("$HOME") .. "/.claude-api" },
headers = function(self) headers = function(self)
return { return {
["Content-Type"] = "application/json", ['Content-Type'] = "application/json",
["x-api-key"] = self.api_key, ['x-api-key'] = self.api_key,
["anthropic-version"] = "2023-06-01", ['anthropic-version'] = "2023-06-01",
} }
end, end,
params = { params = {
@@ -21,14 +21,14 @@ return {
command = { max_tokens = 4096 }, command = { max_tokens = 4096 },
}, },
models = { models = {
"claude-opus-4-1-20250805", 'claude-opus-4-1-20250805',
"claude-sonnet-4-20250514", 'claude-sonnet-4-5-20250929',
}, },
preprocess_payload = function(payload) preprocess_payload = function(payload)
for _, message in ipairs(payload.messages) do for _, message in ipairs(payload.messages) do
message.content = message.content:gsub("^%s*(.-)%s*$", "%1") message.content = message.content:gsub('^%s*(.-)%s*$', "%1")
end end
if payload.messages[1] and payload.messages[1].role == "system" then if payload.messages[1] and payload.messages[1].role == 'system' then
-- remove the first message that serves as the system prompt as anthropic -- 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 -- expects the system prompt to be part of the API call body and not the messages
payload.system = payload.messages[1].content payload.system = payload.messages[1].content