gongxiangp2/lib/ai-model-types.ts

74 lines
3.0 KiB
TypeScript

export const AI_MODEL_STAGES = ['analysis', 'copy', 'image'] as const
export type AiModelStage = typeof AI_MODEL_STAGES[number]
export const AI_MODEL_TEST_PURPOSES = ['analysis-copy', ...AI_MODEL_STAGES] as const
export type AiModelTestPurpose = typeof AI_MODEL_TEST_PURPOSES[number]
export function aiModelTestStages(purpose: AiModelTestPurpose): AiModelStage[] { return purpose === 'analysis-copy' ? ['analysis', 'copy'] : [purpose] }
export type AiModelDefaults = Record<AiModelStage, string | null>
export const AI_MODEL_KINDS = ['text', 'vision', 'image', 'tts', 'asr', 'music', 'video', 'embedding', 'image-tool', 'three-d', 'other', 'unknown'] as const
export type AiModelKind = typeof AI_MODEL_KINDS[number]
export interface AiModelVerificationSummary {
status: 'untested' | 'running' | 'passed' | 'failed' | 'unknown' | 'stale'
id: string | null
checkedAt: string | null
requestId: string | null
message: string | null
canResume?: boolean
canReconcile?: boolean
reconciled?: boolean
taskId?: string | null
submissionKey?: string
purpose?: AiModelTestPurpose
verifiedReferenceImageCount?: number
}
export interface AiModelCapabilities {
kind: AiModelKind
allowedStages: AiModelStage[]
source: 'upstream' | 'verified' | 'unknown'
reason: string
protocols?: Partial<Record<AiModelStage, { id: string; path: string; scopeId?: string; routeId?: string; operationId?: string; maxImages?: number; referenceLimitSource?: 'verification' }>>
combinedTextTest?: boolean
}
export interface AiModelCatalogEntry {
key: string
id: string
enabled: boolean
stages: AiModelStage[]
present: boolean
verification: Record<AiModelStage, AiModelVerificationSummary>
capabilities: AiModelCapabilities
}
export interface AiModelProvider {
id: string
name: string
baseUrl: string
enabled: boolean
credentialSource: 'encrypted' | 'environment'
hasApiKey: boolean
revision: number
syncedAt: string | null
models: AiModelCatalogEntry[]
}
export interface AiModelAdminState {
providers: AiModelProvider[]
defaults: AiModelDefaults
revision: number
encryptionConfigured: boolean
legacyAvailable: boolean
submissionCheck?: { idempotencyKey: string; modelKey: string; stage: AiModelTestPurpose; received: boolean }
}
export interface AiModelConfigurationInput {
revision: number
defaults: AiModelDefaults
providers: Array<{ id: string; revision: number; models: Array<{ key: string; enabled: boolean; stages: AiModelStage[] }> }>
}
export interface AiModelChoice { value: string; label: string; providerName: string }
export interface AiModelRuntimeState {
configured: boolean
models: Record<AiModelStage, string[]>
defaults: Record<AiModelStage, string>
modelOptions: Record<AiModelStage, AiModelChoice[]>
legacyModels: Record<AiModelStage, string[]>
}
export interface AiModelBinding { providerId: string; modelKey: string; modelId: string; providerName: string; baseUrl: string; revision: number; protocolFingerprint?: string; verificationId?: string }
export type AiModelBindings = Record<AiModelStage, AiModelBinding>