Skip to content

Commit

Permalink
Format and add anthropic test
Browse files Browse the repository at this point in the history
  • Loading branch information
frankroeder committed Jan 29, 2025
1 parent f25baf6 commit 15b96ee
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 33 deletions.
2 changes: 1 addition & 1 deletion lua/parrot/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ function M.setup(opts)

math.randomseed(os.time())
opts = opts or {}
opts.providers = opts.providers or {}
opts.providers = opts.providers or {}

local valid_provider_names = vim.tbl_keys(defaults.providers)
if not utils.has_valid_key(opts.providers, valid_provider_names) then
Expand Down
2 changes: 1 addition & 1 deletion lua/parrot/provider/perplexity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function Perplexity:get_available_models()
return {
"llama-3.1-sonar-small-128k-online", -- deprecated, will stop working after 2025-02-22
"llama-3.1-sonar-large-128k-online", -- deprecated, will stop working after 2025-02-22
"llama-3.1-sonar-huge-128k-online", -- deprecated, will stop working after 2025-02-22
"llama-3.1-sonar-huge-128k-online", -- deprecated, will stop working after 2025-02-22
"sonar",
"sonar-pro",
}
Expand Down
61 changes: 30 additions & 31 deletions tests/parrot/provider/anthropic_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,36 @@ describe("Anthropic", function()
assert.are.same(anthropic.name, "anthropic")
end)

-- TODO: preprocess_payload output is nil --
-- describe("preprocess_payload", function()
-- it("should handle payload with system message correctly", function()
-- local input = {
-- max_tokens = 4096,
-- messages = {
-- {
-- content = "You are a versatile AI assistant with capabilities\nextending to general knowledge and coding support. When engaging\nwith users, please adhere to the following guidelines to ensure\nthe highest quality of interaction:\n\n- Admit when unsure by saying 'I don't know.'\n- Ask for clarification when needed.\n- Use first principles thinking to analyze queries.\n- Start with the big picture, then focus on details.\n- Apply the Socratic method to enhance understanding.\n- Include all necessary code in your responses.\n- Stay calm and confident with each task.\n",
-- role = "system",
-- },
-- { content = "Who are you?", role = "user" },
-- },
-- model = "claude-3-haiku-20240307",
-- stream = true,
-- }
--
-- local expected = {
-- max_tokens = 4096,
-- messages = {
-- { content = "Who are you?", role = "user" },
-- },
-- model = "claude-3-haiku-20240307",
-- stream = true,
-- system = "You are a versatile AI assistant with capabilities\nextending to general knowledge and coding support. When engaging\nwith users, please adhere to the following guidelines to ensure\nthe highest quality of interaction:\n\n- Admit when unsure by saying 'I don't know.'\n- Ask for clarification when needed.\n- Use first principles thinking to analyze queries.\n- Start with the big picture, then focus on details.\n- Apply the Socratic method to enhance understanding.\n- Include all necessary code in your responses.\n- Stay calm and confident with each task.",
-- }
--
-- local result = anthropic:preprocess_payload(input)
--
-- assert.are.same(expected, result)
-- end)
-- end)
describe("preprocess_payload", function()
it("should handle payload with system message correctly", function()
local input = {
max_tokens = 4096,
messages = {
{
content = "You are a versatile AI assistant with capabilities\nextending to general knowledge and coding support. When engaging\nwith users, please adhere to the following guidelines to ensure\nthe highest quality of interaction:\n\n- Admit when unsure by saying 'I don't know.'\n- Ask for clarification when needed.\n- Use first principles thinking to analyze queries.\n- Start with the big picture, then focus on details.\n- Apply the Socratic method to enhance understanding.\n- Include all necessary code in your responses.\n- Stay calm and confident with each task.\n",
role = "system",
},
{ content = "Who are you?", role = "user" },
},
model = "claude-3-haiku-20240307",
stream = true,
}

local expected = {
max_tokens = 4096,
messages = {
{ content = "Who are you?", role = "user" },
},
model = "claude-3-haiku-20240307",
stream = true,
system = "You are a versatile AI assistant with capabilities\nextending to general knowledge and coding support. When engaging\nwith users, please adhere to the following guidelines to ensure\nthe highest quality of interaction:\n\n- Admit when unsure by saying 'I don't know.'\n- Ask for clarification when needed.\n- Use first principles thinking to analyze queries.\n- Start with the big picture, then focus on details.\n- Apply the Socratic method to enhance understanding.\n- Include all necessary code in your responses.\n- Stay calm and confident with each task.",
}

local result = anthropic:preprocess_payload(input)

assert.are.same(expected, result)
end)
end)

describe("verify", function()
it("should return true for a valid API key", function()
Expand Down

0 comments on commit 15b96ee

Please sign in to comment.