-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from frankroeder/feat-gh-models
Add support for GitHub models beta API
- Loading branch information
Showing
4 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
local OpenAI = require("parrot.provider.openai") | ||
|
||
local GitHub = setmetatable({}, { __index = OpenAI }) | ||
GitHub.__index = GitHub | ||
|
||
-- Available API parameters for GitHub models | ||
local AVAILABLE_API_PARAMETERS = { | ||
-- required | ||
messages = true, | ||
model = true, | ||
-- optional | ||
max_tokens = true, | ||
temperature = true, | ||
top_p = true, | ||
stop = true, | ||
best_of = true, | ||
presence_penalty = true, | ||
stream = true, | ||
} | ||
|
||
function GitHub:new(endpoint, api_key) | ||
local instance = OpenAI.new(self, endpoint, api_key) | ||
instance.name = "github" | ||
return setmetatable(instance, self) | ||
end | ||
|
||
-- Preprocesses the payload before sending to the API | ||
---@param payload table | ||
---@return table | ||
function GitHub:preprocess_payload(payload) | ||
for _, message in ipairs(payload.messages) do | ||
message.content = message.content:gsub("^%s*(.-)%s*$", "%1") | ||
end | ||
return utils.filter_payload_parameters(AVAILABLE_API_PARAMETERS, payload) | ||
end | ||
|
||
-- Returns the list of available models | ||
---@param online boolean | ||
---@return string[] | ||
function GitHub:get_available_models(online) | ||
return { | ||
"AI21-Jamba-Instruct", | ||
"Cohere-command-r", | ||
"Cohere-command-r-plus", | ||
"Meta-Llama-3-70B-Instruct", | ||
"Meta-Llama-3-8B-Instruct", | ||
"Meta-Llama-3.1-405B-Instruct", | ||
"Meta-Llama-3.1-70B-Instruct", | ||
"Meta-Llama-3.1-8B-Instruct", | ||
"Mistral-small", | ||
"Mistral-Nemo", | ||
"Mistral-large-2407", | ||
"Mistral-large", | ||
"gpt-4o-mini", | ||
"gpt-4o", | ||
"Phi-3-medium-128k-instruct", | ||
"Phi-3-medium-4k-instruct", | ||
"Phi-3-mini-128k-instruct", | ||
"Phi-3-mini-4k-instruct", | ||
"Phi-3-small-128k-instruct", | ||
"Phi-3-small-8k-instruct", | ||
} | ||
end | ||
|
||
return GitHub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters