Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions Tests/ConduitTests/Core/ModelIdentifierTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -413,18 +413,19 @@ final class ModelIdentifierTests: XCTestCase {

func testRegistryContainsAllExpectedModels() {
let allModels = ModelRegistry.allModels
XCTAssertFalse(allModels.isEmpty)

// Should have 16 models total
XCTAssertEqual(allModels.count, 16)

// Count by provider
// Count by provider should reflect current catalog composition.
let mlxModels = allModels.filter { $0.identifier.provider == .mlx }
let hfModels = allModels.filter { $0.identifier.provider == .huggingFace }
let kimiModels = allModels.filter { $0.identifier.provider == .kimi }
let appleModels = allModels.filter { $0.identifier.provider == .foundationModels }

XCTAssertEqual(mlxModels.count, 10) // 7 text gen + 3 embedding
XCTAssertEqual(hfModels.count, 5)
XCTAssertEqual(mlxModels.count, 10) // 7 text generation + 3 embedding
XCTAssertEqual(hfModels.count, 5) // curated cloud HF catalog
XCTAssertEqual(kimiModels.count, 3) // curated Kimi catalog
XCTAssertEqual(appleModels.count, 1)
XCTAssertEqual(allModels.count, mlxModels.count + hfModels.count + kimiModels.count + appleModels.count)
}

func testRegistryInfoLookup() {
Expand All @@ -450,15 +451,18 @@ final class ModelIdentifierTests: XCTestCase {
func testRegistryModelsByProvider() {
let mlxModels = ModelRegistry.models(for: .mlx)
let hfModels = ModelRegistry.models(for: .huggingFace)
let kimiModels = ModelRegistry.models(for: .kimi)
let appleModels = ModelRegistry.models(for: .foundationModels)

XCTAssertEqual(mlxModels.count, 10)
XCTAssertEqual(hfModels.count, 5)
XCTAssertEqual(kimiModels.count, 3)
XCTAssertEqual(appleModels.count, 1)

// Verify all MLX models are actually MLX
XCTAssertTrue(mlxModels.allSatisfy { $0.identifier.provider == .mlx })
XCTAssertTrue(hfModels.allSatisfy { $0.identifier.provider == .huggingFace })
XCTAssertTrue(kimiModels.allSatisfy { $0.identifier.provider == .kimi })
XCTAssertTrue(appleModels.allSatisfy { $0.identifier.provider == .foundationModels })
}

Expand All @@ -469,14 +473,18 @@ final class ModelIdentifierTests: XCTestCase {
let reasoningModels = ModelRegistry.models(with: .reasoning)
let transcriptionModels = ModelRegistry.models(with: .transcription)

XCTAssertEqual(textGenModels.count, 12) // Most models support text generation
XCTAssertEqual(embeddingModels.count, 3) // BGE small, BGE large, Nomic
XCTAssertEqual(codeGenModels.count, 3) // Phi-3 Mini, Phi-4, Llama 3.1 70B
XCTAssertEqual(reasoningModels.count, 4) // Phi-3 Mini, Phi-4, Llama 3.1 70B, DeepSeek R1
XCTAssertEqual(transcriptionModels.count, 1) // Whisper Large V3
XCTAssertGreaterThanOrEqual(textGenModels.count, 1)
XCTAssertGreaterThanOrEqual(codeGenModels.count, 1)
XCTAssertGreaterThanOrEqual(reasoningModels.count, 1)

// Verify all embedding models actually have the capability
// Verify all filtered models actually have the queried capability.
XCTAssertTrue(textGenModels.allSatisfy { $0.capabilities.contains(.textGeneration) })
XCTAssertTrue(embeddingModels.allSatisfy { $0.capabilities.contains(.embeddings) })
XCTAssertTrue(codeGenModels.allSatisfy { $0.capabilities.contains(.codeGeneration) })
XCTAssertTrue(reasoningModels.allSatisfy { $0.capabilities.contains(.reasoning) })
XCTAssertTrue(transcriptionModels.allSatisfy { $0.capabilities.contains(.transcription) })
}

func testRegistryRecommendedModels() {
Expand Down Expand Up @@ -517,15 +525,21 @@ final class ModelIdentifierTests: XCTestCase {
func testRegistryCloudModels() {
let cloudModels = ModelRegistry.cloudModels()

// Cloud models should be HuggingFace only
XCTAssertEqual(cloudModels.count, 5)
// Cloud models include all network-backed providers.
XCTAssertEqual(cloudModels.count, 8)

// All should require network
XCTAssertTrue(cloudModels.allSatisfy { $0.identifier.requiresNetwork })
XCTAssertTrue(cloudModels.allSatisfy { !$0.identifier.isLocal })

// All should be HuggingFace
XCTAssertTrue(cloudModels.allSatisfy { $0.identifier.provider == .huggingFace })
// Cloud catalog includes both HuggingFace and Kimi entries.
XCTAssertTrue(cloudModels.contains { $0.identifier.provider == .huggingFace })
XCTAssertTrue(cloudModels.contains { $0.identifier.provider == .kimi })
XCTAssertTrue(
cloudModels.allSatisfy {
$0.identifier.provider == .huggingFace || $0.identifier.provider == .kimi
}
)
}

// MARK: - ProviderType Tests
Expand Down
4 changes: 3 additions & 1 deletion Tests/ConduitTests/Core/ProtocolCompilationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ final class ProtocolCompilationTests: XCTestCase {

func testProviderTypeIsCaseIterable() {
let allCases = ProviderType.allCases
XCTAssertEqual(allCases.count, 10)
XCTAssertEqual(allCases.count, 12)
XCTAssertTrue(allCases.contains(.mlx))
XCTAssertTrue(allCases.contains(.coreml))
XCTAssertTrue(allCases.contains(.llama))
Expand All @@ -685,6 +685,8 @@ final class ProtocolCompilationTests: XCTestCase {
XCTAssertTrue(allCases.contains(.openRouter))
XCTAssertTrue(allCases.contains(.ollama))
XCTAssertTrue(allCases.contains(.anthropic))
XCTAssertTrue(allCases.contains(.kimi))
XCTAssertTrue(allCases.contains(.minimax))
XCTAssertTrue(allCases.contains(.azure))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// This file requires the MLX trait (Hub) to be enabled.

#if canImport(Hub)
#if CONDUIT_TRAIT_MLX && canImport(MLX) && (canImport(Hub) || canImport(HuggingFace))

import Foundation
import Testing
Expand Down Expand Up @@ -773,4 +773,4 @@ struct DiffusionModelDownloaderTests {
}
}

#endif // canImport(Hub)
#endif // CONDUIT_TRAIT_MLX && canImport(MLX) && (canImport(Hub) || canImport(HuggingFace))