-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add MiniMax provider support #14
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -1,7 +1,21 @@ | ||
| import type { AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS } from '../../services/analytics/index.js' | ||
| import { isEnvTruthy } from '../envUtils.js' | ||
|
|
||
| export type APIProvider = 'firstParty' | 'bedrock' | 'vertex' | 'foundry' | ||
| export type APIProvider = 'firstParty' | 'bedrock' | 'vertex' | 'foundry' | 'minimax' | ||
|
|
||
| const MINI_MAX_ANTHROPIC_HOSTS = new Set(['api.minimax.io', 'api.minimaxi.com']) | ||
|
|
||
| function getAnthropicBaseUrlHost(): string | null { | ||
| const baseUrl = process.env.ANTHROPIC_BASE_URL | ||
| if (!baseUrl) { | ||
| return null | ||
| } | ||
| try { | ||
| return new URL(baseUrl).host | ||
| } catch { | ||
| return null | ||
| } | ||
|
Comment on lines
+8
to
+17
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. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Reject malformed configured URLs.
Treat only an unset value as the default API. Return Proposed fix export function isFirstPartyAnthropicBaseUrl(): boolean {
+ if (!process.env.ANTHROPIC_BASE_URL) {
+ return true
+ }
const host = getAnthropicBaseUrlHost()
if (!host) {
- return true
+ return false
}Also applies to: 44-47 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| export function getAPIProvider(): APIProvider { | ||
| return isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK) | ||
|
|
@@ -17,24 +31,24 @@ export function getAPIProviderForStatsig(): AnalyticsMetadata_I_VERIFIED_THIS_IS | |
| return getAPIProvider() as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS | ||
| } | ||
|
|
||
| export function isMiniMaxAnthropicBaseUrl(): boolean { | ||
| const host = getAnthropicBaseUrlHost() | ||
| return host !== null && MINI_MAX_ANTHROPIC_HOSTS.has(host) | ||
| } | ||
|
|
||
| /** | ||
| * Check if ANTHROPIC_BASE_URL is a first-party Anthropic API URL. | ||
| * Returns true if not set (default API) or points to api.anthropic.com | ||
| * (or api-staging.anthropic.com for ant users). | ||
| */ | ||
| export function isFirstPartyAnthropicBaseUrl(): boolean { | ||
| const baseUrl = process.env.ANTHROPIC_BASE_URL | ||
| if (!baseUrl) { | ||
| const host = getAnthropicBaseUrlHost() | ||
| if (!host) { | ||
| return true | ||
| } | ||
| try { | ||
| const host = new URL(baseUrl).host | ||
| const allowedHosts = ['api.anthropic.com'] | ||
| if (process.env.USER_TYPE === 'ant') { | ||
| allowedHosts.push('api-staging.anthropic.com') | ||
| } | ||
| return allowedHosts.includes(host) | ||
| } catch { | ||
| return false | ||
| const allowedHosts = ['api.anthropic.com', ...MINI_MAX_ANTHROPIC_HOSTS] | ||
| if (process.env.USER_TYPE === 'ant') { | ||
| allowedHosts.push('api-staging.anthropic.com') | ||
| } | ||
| return allowedHosts.includes(host) | ||
| } | ||
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Centralize effective-provider resolution.
This branch correctly maps a first-party MiniMax endpoint to the
minimaxmodel configuration. However, the conversion is local.getAPIProvider()still returnsfirstParty, sosrc/utils/model/deprecation.tsnever selects the newminimax: nullretirement entries, and theminimaxprovider label insrc/utils/status.tsxis unreachable.Extract a shared effective-provider helper and use it for model, deprecation, and provider metadata lookup. Keep the raw provider where the first-party transport and base-URL branch are required. Add tests covering both MiniMax hosts.
🤖 Prompt for AI Agents