feat: initial release v0.3.0
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { findBuiltinCapabilities } from '@/lib/model-capabilities/catalog'
|
||||
|
||||
describe('bailian video capabilities catalog', () => {
|
||||
it('registers bailian i2v models as normal-mode only', () => {
|
||||
const models = [
|
||||
'wan2.6-i2v-flash',
|
||||
'wan2.6-i2v',
|
||||
'wan2.5-i2v-preview',
|
||||
'wan2.2-i2v-plus',
|
||||
]
|
||||
|
||||
for (const modelId of models) {
|
||||
const capabilities = findBuiltinCapabilities('video', 'bailian', modelId)
|
||||
expect(capabilities?.video?.generationModeOptions).toEqual(['normal'])
|
||||
expect(capabilities?.video?.firstlastframe).toBe(false)
|
||||
}
|
||||
})
|
||||
|
||||
it('registers bailian kf2v models as firstlastframe-only', () => {
|
||||
const models = [
|
||||
'wan2.2-kf2v-flash',
|
||||
'wanx2.1-kf2v-plus',
|
||||
]
|
||||
|
||||
for (const modelId of models) {
|
||||
const capabilities = findBuiltinCapabilities('video', 'bailian', modelId)
|
||||
expect(capabilities?.video?.generationModeOptions).toEqual(['firstlastframe'])
|
||||
expect(capabilities?.video?.firstlastframe).toBe(true)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,57 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
type CapabilitySelections,
|
||||
type ModelCapabilities,
|
||||
type UnifiedModelType,
|
||||
} from '@/lib/model-config-contract'
|
||||
import { resolveGenerationOptionsForModel } from '@/lib/model-capabilities/lookup'
|
||||
|
||||
describe('model-capabilities/lookup - image resolution defaulting', () => {
|
||||
const modelType: UnifiedModelType = 'image'
|
||||
const modelKey = 'google::test-image-model'
|
||||
|
||||
const capabilities: ModelCapabilities = {
|
||||
image: {
|
||||
resolutionOptions: ['0.5K', '1K', '2K'],
|
||||
},
|
||||
}
|
||||
|
||||
it('auto-fills resolution with first option when missing and required', () => {
|
||||
const capabilityDefaults: CapabilitySelections = {}
|
||||
|
||||
const result = resolveGenerationOptionsForModel({
|
||||
modelType,
|
||||
modelKey,
|
||||
capabilities,
|
||||
capabilityDefaults,
|
||||
requireAllFields: true,
|
||||
})
|
||||
|
||||
expect(result.issues).toEqual([])
|
||||
expect(result.options).toEqual({
|
||||
resolution: '0.5K',
|
||||
})
|
||||
})
|
||||
|
||||
it('does not override user-provided resolution', () => {
|
||||
const capabilityDefaults: CapabilitySelections = {
|
||||
[modelKey]: {
|
||||
resolution: '2K',
|
||||
},
|
||||
}
|
||||
|
||||
const result = resolveGenerationOptionsForModel({
|
||||
modelType,
|
||||
modelKey,
|
||||
capabilities,
|
||||
capabilityDefaults,
|
||||
requireAllFields: true,
|
||||
})
|
||||
|
||||
expect(result.issues).toEqual([])
|
||||
expect(result.options).toEqual({
|
||||
resolution: '2K',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
66
tests/unit/model-capabilities/video-effective.test.ts
Normal file
66
tests/unit/model-capabilities/video-effective.test.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
normalizeVideoGenerationSelections,
|
||||
resolveEffectiveVideoCapabilityDefinitions,
|
||||
resolveEffectiveVideoCapabilityFields,
|
||||
} from '@/lib/model-capabilities/video-effective'
|
||||
import type { VideoPricingTier } from '@/lib/model-pricing/video-tier'
|
||||
|
||||
const GOOGLE_VEO_TIERS: VideoPricingTier[] = [
|
||||
{ when: { resolution: '720p', duration: 4 } },
|
||||
{ when: { resolution: '720p', duration: 6 } },
|
||||
{ when: { resolution: '720p', duration: 8 } },
|
||||
{ when: { resolution: '1080p', duration: 8 } },
|
||||
{ when: { resolution: '4k', duration: 8 } },
|
||||
]
|
||||
|
||||
describe('model-capabilities/video-effective', () => {
|
||||
it('derives capability definitions from pricing tiers', () => {
|
||||
const definitions = resolveEffectiveVideoCapabilityDefinitions({
|
||||
pricingTiers: GOOGLE_VEO_TIERS,
|
||||
})
|
||||
const byField = new Map(definitions.map((item) => [item.field, item.options]))
|
||||
|
||||
expect(byField.get('resolution')).toEqual(['720p', '1080p', '4k'])
|
||||
expect(byField.get('duration')).toEqual([4, 6, 8])
|
||||
})
|
||||
|
||||
it('keeps pinned field and adjusts the linked field to nearest supported combo', () => {
|
||||
const definitions = resolveEffectiveVideoCapabilityDefinitions({
|
||||
pricingTiers: GOOGLE_VEO_TIERS,
|
||||
})
|
||||
|
||||
const normalized = normalizeVideoGenerationSelections({
|
||||
definitions,
|
||||
pricingTiers: GOOGLE_VEO_TIERS,
|
||||
selection: {
|
||||
resolution: '1080p',
|
||||
duration: 4,
|
||||
},
|
||||
pinnedFields: ['resolution'],
|
||||
})
|
||||
|
||||
expect(normalized).toEqual({
|
||||
resolution: '1080p',
|
||||
duration: 8,
|
||||
})
|
||||
})
|
||||
|
||||
it('filters dependent options by current selection', () => {
|
||||
const definitions = resolveEffectiveVideoCapabilityDefinitions({
|
||||
pricingTiers: GOOGLE_VEO_TIERS,
|
||||
})
|
||||
const fields = resolveEffectiveVideoCapabilityFields({
|
||||
definitions,
|
||||
pricingTiers: GOOGLE_VEO_TIERS,
|
||||
selection: {
|
||||
resolution: '1080p',
|
||||
},
|
||||
})
|
||||
const durationField = fields.find((field) => field.field === 'duration')
|
||||
|
||||
expect(durationField?.options).toEqual([8])
|
||||
expect(durationField?.value).toBe(8)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user