Buckets:
| import type { ProviderId, ProviderType } from '@/lib/types/provider'; | |
| import type { ProviderSettings } from '@/lib/types/settings'; | |
| interface NewCustomProviderConfig { | |
| name: string; | |
| type: ProviderType; | |
| baseUrl: string; | |
| icon: string; | |
| requiresApiKey: boolean; | |
| } | |
| export function formatContextWindow(size?: number): string { | |
| if (!size) return '-'; | |
| // For M: prefer decimal (use decimal for exact thousands) | |
| if (size >= 1000000) { | |
| if (size % 1000000 === 0) { | |
| return `${size / 1000000}M`; | |
| } | |
| return `${(size / 1000000).toFixed(1)}M`; | |
| } | |
| // For K: prefer decimal if divisible by 1000, otherwise use binary | |
| if (size >= 1000) { | |
| if (size % 1000 === 0) { | |
| return `${size / 1000}K`; | |
| } | |
| return `${Math.floor(size / 1024)}K`; | |
| } | |
| return size.toString(); | |
| } | |
| export function getProviderTypeLabel(type: string, t: (key: string) => string): string { | |
| const translationKey = `settings.providerTypes.${type}`; | |
| const translated = t(translationKey); | |
| // If translation exists (not equal to key), use it; otherwise fallback to type | |
| return translated !== translationKey ? translated : type; | |
| } | |
| export function createCustomProviderSettings( | |
| providerData: NewCustomProviderConfig, | |
| ): ProviderSettings { | |
| return { | |
| apiKey: '', | |
| baseUrl: providerData.baseUrl || '', | |
| models: [], | |
| name: providerData.name, | |
| type: providerData.type, | |
| defaultBaseUrl: providerData.baseUrl || undefined, | |
| icon: providerData.icon || undefined, | |
| requiresApiKey: providerData.requiresApiKey, | |
| isBuiltIn: false, | |
| }; | |
| } | |
| interface VerifyModelRequestConfig { | |
| providerId: ProviderId; | |
| modelId: string; | |
| apiKey?: string; | |
| baseUrl?: string; | |
| providerType?: ProviderType | string; | |
| requiresApiKey?: boolean; | |
| } | |
| export function createVerifyModelRequest(config: VerifyModelRequestConfig) { | |
| return { | |
| apiKey: config.apiKey || '', | |
| baseUrl: config.baseUrl || '', | |
| model: `${config.providerId}:${config.modelId}`, | |
| providerType: config.providerType, | |
| requiresApiKey: config.requiresApiKey, | |
| }; | |
| } | |
Xet Storage Details
- Size:
- 2.05 kB
- Xet hash:
- 1c5bb6bba42675f1a8a18a0e8d155d6dcead691605fbc23145eafd44c8963429
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.