-
Notifications
You must be signed in to change notification settings - Fork 43
Allows Mistral byok to be used for Codestral #4000
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 |
|---|---|---|
|
|
@@ -15,22 +15,22 @@ import type { BYOKResult } from '@/lib/ai-gateway/providers/types'; | |
| import { getVercelModelsMetadata } from '@/lib/ai-gateway/providers/gateway-models-cache'; | ||
|
|
||
| export async function getModelUserByokProviders(modelId: string): Promise<UserByokProviderId[]> { | ||
| if (isCodestralModel(modelId)) { | ||
| return ['codestral']; | ||
| } | ||
| const vercelModelMetadata = await getVercelModelsMetadata(); | ||
| if (Object.keys(vercelModelMetadata).length === 0) { | ||
| console.error('[getModelUserByokProviders] no Vercel model metadata in the database'); | ||
| return []; | ||
| } | ||
| const providers = | ||
| const providers: UserByokProviderId[] = | ||
| vercelModelMetadata[mapModelIdToVercel(modelId, false)]?.endpoints | ||
| .map(ep => VercelUserByokInferenceProviderIdSchema.safeParse(ep.provider_name ?? ep.tag).data) | ||
| .filter(providerId => providerId !== undefined) ?? []; | ||
| if (providers.length === 0) { | ||
| console.debug(`[getModelUserByokProviders] no user byok providers for ${modelId}`); | ||
| return []; | ||
| } | ||
| if (isCodestralModel(modelId)) { | ||
| providers.splice(0, 0, 'codestral'); | ||
|
Contributor
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. SUGGESTION:
Reply with |
||
| } | ||
| console.debug('[getModelUserByokProviders] found user byok providers for %s', modelId, providers); | ||
| return providers; | ||
| } | ||
|
|
||
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.
WARNING: BYOK key priority not honoured — DB
orderBy(created_at)overrides the['codestral', 'mistral']intentgetBYOKforUser/getBYOKforOrganizationquery withinArray(byok_api_keys.provider_id, providerIds)andorderBy(byok_api_keys.created_at). SQL'sIN (…)clause does not preserve the input array order, so when a user has both acodestralkey and amistralkey the DB returns them oldest-first.userByok?.at(0)(line 237) then picks the oldest key regardless of which provider it is. If themistralkey was created before thecodestralkey, thecodestralkey is silently ignored and the user's Mistral La Plateforme key is used withapi.mistral.ai— the correct endpoint for that key type, but thecodestralkey preference is lost.To honour the priority ordering, consider re-sorting the returned entries client-side by their position in
byokProviderKeysbefore calling.at(0):Reply with
@kilocode-bot fix itto have Kilo Code address this issue.