opencommit
opencommit copied to clipboard
[Feature]: Support for Github Models (Github Marketplace)
trafficstars
Description
Currently opencommit doesn't support Github Models API calls. It would be nice to have the support for Github models, as they're free to use (if you get your access granted) and gives you free API key to request differents models, GPT 4o included
Suggested Solution
The user could provide a GITHUB_TOKEN (free) instead of the OpenAI (not free) API key for the LLM requests.
Usage :
import os
from openai import OpenAI
token = os.environ["GITHUB_TOKEN"]
endpoint = "https://models.inference.ai.azure.com"
model_name = "gpt-4o-mini"
client = OpenAI(
base_url=endpoint,
api_key=token,
)
response = client.chat.completions.create(
messages=[
{
"role": "system",
"content": "You are in charge to create a commit name for all those differences:",
},
{
"role": "user",
"content": "What is the capital of France?",
}
],
model=model_name,
temperature=1.,
max_tokens=1000,
top_p=1.
)
print(response.choices[0].message.content)
Alternatives
No response
Additional Context
No response