-
Notifications
You must be signed in to change notification settings - Fork 0
fix: update default model to openai/gpt-5-mini and correct GitHub Mod… #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7eb6c89
b669a82
de28654
f91560e
7240bc8
cc07583
c18e686
160cf8f
b4f7405
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ inputs: | |
| provider: | ||
| description: "AI provider shorthand: copilot, github-models, openai, anthropic, openrouter, ollama, xai, zai, google, azure, aws, custom — sets api_url and api_type defaults automatically (azure/aws require api_url). Use github-models to authenticate with GITHUB_TOKEN without needing a personal PAT." | ||
| required: false | ||
| default: "github-models" | ||
| default: "github-azure-models" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Default provider in the action definition doesn't match what the documentation promises The action's default provider is set to Impact: Users following the Quick Start guide without specifying a provider will connect to the Azure-hosted endpoint instead of the documented GitHub-hosted endpoint, which may behave differently or require different permissions. Inconsistency between action.yml and READMEThe README at line 41 states: But default: "github-azure-models"The Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
| api_url: | ||
| description: "Full API endpoint URL (e.g. https://api.anthropic.com/v1/messages). Overrides provider + api_type defaults when set." | ||
| required: false | ||
|
|
||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ export type ApiType = "chat" | "responses" | "messages" | "text"; | |
| export type Provider = | ||
| | "copilot" | ||
| | "github-models" | ||
| | "github-azure-models" | ||
| | "openai" | ||
| | "anthropic" | ||
| | "openrouter" | ||
|
|
@@ -21,7 +22,8 @@ export const API_TYPE_PATHS: Record<ApiType, string> = { | |
| }; | ||
|
|
||
| export const PROVIDER_BASES: Partial<Record<Provider, string>> = { | ||
| "github-models": "https://models.inference.ai.azure.com", | ||
| "github-azure-models": "https://models.inference.ai.azure.com", | ||
| "github-models": "https://models.github.ai/inference", | ||
| copilot: "https://api.githubcopilot.com", | ||
| openai: "https://api.openai.com/v1", | ||
| anthropic: "https://api.anthropic.com/v1", | ||
|
|
@@ -67,6 +69,10 @@ export function isAzureProvider(provider: Provider | undefined, url: string): bo | |
| return provider === "azure" || url.includes(".openai.azure.com"); | ||
| } | ||
|
|
||
| export function isGithubModelsProvider(provider: Provider | undefined, url: string): boolean { | ||
| return provider === "github-models" || url.includes(".inference.ai.azure.com"); | ||
| } | ||
|
Comment on lines
+72
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 GitHub Models URL detection checks the old domain instead of the new one The URL-based detection for the GitHub Models provider checks for the old domain Impact: Users who set Mechanism: URL pattern mismatch after base URL migrationThe Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| export function requiresApiUrl(provider: Provider | undefined): boolean { | ||
| return REQUIRES_API_URL.includes(provider as Provider); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,10 @@ import { | |||||
| isCopilotUrl, | ||||||
| isAzureProvider, | ||||||
| requiresApiUrl, | ||||||
| isGithubModelsProvider, | ||||||
| } from "./config"; | ||||||
| import ModelClient, { isUnexpected } from "@azure-rest/ai-inference"; | ||||||
| import { AzureKeyCredential } from "@azure/core-auth"; | ||||||
|
|
||||||
| // ดึงค่าจาก Environment Variables (รองรับทั้ง GitHub Actions inputs และ env vars ตรง) | ||||||
| const GH_PAT = process.env.INPUT_GH_PAT ?? process.env.GH_PAT; | ||||||
|
|
@@ -130,6 +133,9 @@ async function askAI(diffText: string): Promise<string> { | |||||
| const systemPrompt = `You are an expert Code Reviewer. Review the code and respond in ${LANGUAGE}.`; | ||||||
| const userPrompt = `Please review the following code diff and suggest improvements. Also point out any security vulnerabilities if present. Respond in ${LANGUAGE}.\n\n${diffText}`; | ||||||
| console.log(`Using api_type: ${API_TYPE} (${API_URL})`); | ||||||
| if (isGithubModelsProvider(PROVIDER, API_URL) && API_TYPE === "chat") { | ||||||
| return askGitHubModels(systemPrompt, userPrompt); | ||||||
| } | ||||||
| if (API_TYPE === "chat" || API_TYPE === "text") { | ||||||
| return askOpenAICompat(systemPrompt, userPrompt); | ||||||
| } | ||||||
|
|
@@ -142,6 +148,33 @@ async function askAI(diffText: string): Promise<string> { | |||||
| return askOpenAICompat(systemPrompt, userPrompt); | ||||||
| } | ||||||
|
|
||||||
| // 2b. GitHub Models — ใช้ @azure-rest/ai-inference SDK อย่างเป็นทางการ | ||||||
| async function askGitHubModels(systemPrompt: string, userPrompt: string): Promise<string> { | ||||||
| const endpoint = API_URL.replace(/\/chat\/completions\/?$/, ""); | ||||||
| const token = GH_PAT ?? API_KEY; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 GitHub Models authentication ignores the explicit API key and always uses the general-purpose token The authentication token for GitHub Models is selected with wrong priority ( Impact: Users who provide a dedicated API key for GitHub Models will silently authenticate with the wrong credential, potentially causing authorization failures. Mechanism: GH_PAT takes precedence over the resolved API_KEY
Suggested change
Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||
| const client = ModelClient(endpoint, new AzureKeyCredential(token)); | ||||||
|
|
||||||
| const response = await client.path("/chat/completions").post({ | ||||||
| body: { | ||||||
| messages: [ | ||||||
| { role: "system", content: systemPrompt }, | ||||||
| { role: "user", content: userPrompt }, | ||||||
| ], | ||||||
| model: MODEL, | ||||||
| max_tokens: MAX_TOKENS, | ||||||
| }, | ||||||
| }); | ||||||
|
|
||||||
| if (isUnexpected(response)) { | ||||||
| const errText = JSON.stringify(response.body.error ?? response.body); | ||||||
| console.error(`GitHub Models API error: ${response.status}`); | ||||||
| console.error(`Response: ${errText.slice(0, 500)}`); | ||||||
| return `⚠️ GitHub Models API returned status ${response.status}. Response: ${errText.slice(0, 200)}`; | ||||||
| } | ||||||
|
|
||||||
| return response.body.choices?.[0]?.message?.content ?? ""; | ||||||
| } | ||||||
|
|
||||||
| async function askOpenAICompat(systemPrompt: string, userPrompt: string): Promise<string> { | ||||||
| const isChat = API_TYPE !== "text"; | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.