Replies: 2 comments 9 replies
-
Alright, I was testing the new meta models with groq and managed to solve the issue, though the solution is a bit hacky—it works for now. I added a handler to modify the ID. However, I believe the model name in your version might not be entirely correct. Could you take a look at it, please? groq = function()
return require("codecompanion.adapters").extend("openai", {
env = {
api_key = vim.env.GROQ_API_KEY,
},
name = "Groq",
url = "https://api.groq.com/openai/v1/chat/completions",
schema = {
model = {
default = "llama-3.2-11b-text-preview",
},
},
max_tokens = {
default = 8192,
},
temperature = {
default = 1,
},
handlers = {
form_messages = function(self, messages)
for i, msg in ipairs(messages) do
-- Remove 'id' and 'opts' properties from all messages
msg.id = nil
msg.opts = nil
-- Ensure 'name' is a string if present, otherwise remove it
if msg.name then
msg.name = tostring(msg.name)
else
msg.name = nil
end
-- Ensure only supported properties are present
local supported_props =
{ role = true, content = true, name = true }
for prop in pairs(msg) do
if not supported_props[prop] then
msg[prop] = nil
end
end
end
return { messages = messages }
end,
},
})
end,
edit: correct the code indentation |
Beta Was this translation helpful? Give feedback.
-
Made a PR to acheive support for any OpenAI compatible model, self hosted or otherwise. |
Beta Was this translation helpful? Give feedback.
-
OK, another noob question. Thanks to all of you I have deepseek running with codecompanion because it emulates the openai API. There is another provider groq which does the same thing, so I tried the same trick, just use the openai adapter and give it a different "utl".
The problem is that the groq emulation of openai does not accept the "id" tag. See https://console.groq.com/docs/api-reference#chat-create and suggests using a "name" tag instead. I'm looking at the Adapter code and can't for the life of me figure out how to suppress the "id" part of the JSON message.
Is there an easy way to do this, just as you can just extend the function with "URL" to get the right endpoint:
Beta Was this translation helpful? Give feedback.
All reactions