v2: Initial clean branch with unit tests + CI/CD pipeline
- Started from ac75faa (initial E4B-MarkBase integration)
- Kept Sources/ (all engine code) + Package.swift + .gitignore
- Removed all ad-hoc tests, documentation, scripts, Python files
- Added Tests/00_Unit/ (MathTest, TokenizerTest, SamplerTest)
- Added .gitea/workflows/ci.yaml (build + unit tests + lint)
- Added Scripts/check_resources.sh (memory-aware test runner)
- Added Tests/Manifest.json (resource requirements for all tests)
- Focus: 4-bit quantized models only
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
import Foundation
|
||||
import MarkBase
|
||||
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
// Model API Models
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
|
||||
/// Chat completion request (for testing)
|
||||
public struct ChatCompletionRequest: Codable {
|
||||
public let model: String
|
||||
public let messages: [ChatMessage]
|
||||
public let max_tokens: Int?
|
||||
public let temperature: Float?
|
||||
public let stream: Bool?
|
||||
|
||||
public func toGenerationConfig() -> GenerationConfig {
|
||||
GenerationConfig(
|
||||
maxTokens: max_tokens ?? 100,
|
||||
temperature: temperature ?? 1.0
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Multimodal chat completion request (for testing)
|
||||
public struct MultimodalChatCompletionRequest: Codable {
|
||||
public let model: String
|
||||
public let messages: [MultimodalMessage]
|
||||
public let max_tokens: Int?
|
||||
public let stream: Bool?
|
||||
|
||||
public func toGenerationConfig() -> GenerationConfig {
|
||||
GenerationConfig(maxTokens: max_tokens ?? 100)
|
||||
}
|
||||
}
|
||||
|
||||
/// Model capabilities
|
||||
public struct ModelCapabilities: Codable, Sendable {
|
||||
public let text: Bool
|
||||
public let vision: Bool
|
||||
public let audio: Bool
|
||||
public let embeddings: Bool
|
||||
public let streaming: Bool
|
||||
|
||||
public init(
|
||||
text: Bool = true,
|
||||
vision: Bool = true,
|
||||
audio: Bool = true,
|
||||
embeddings: Bool = true,
|
||||
streaming: Bool = true
|
||||
) {
|
||||
self.text = text
|
||||
self.vision = vision
|
||||
self.audio = audio
|
||||
self.embeddings = embeddings
|
||||
self.streaming = streaming
|
||||
}
|
||||
}
|
||||
|
||||
/// Model parameters
|
||||
public struct ModelParameters: Codable, Sendable {
|
||||
public let context_length: Int
|
||||
public let num_hidden_layers: Int
|
||||
public let hidden_size: Int
|
||||
public let vocab_size: Int
|
||||
public let num_attention_heads: Int
|
||||
public let num_kv_heads: Int
|
||||
|
||||
public init(
|
||||
context_length: Int,
|
||||
num_hidden_layers: Int,
|
||||
hidden_size: Int,
|
||||
vocab_size: Int,
|
||||
num_attention_heads: Int,
|
||||
num_kv_heads: Int
|
||||
) {
|
||||
self.context_length = context_length
|
||||
self.num_hidden_layers = num_hidden_layers
|
||||
self.hidden_size = hidden_size
|
||||
self.vocab_size = vocab_size
|
||||
self.num_attention_heads = num_attention_heads
|
||||
self.num_kv_heads = num_kv_heads
|
||||
}
|
||||
}
|
||||
|
||||
/// Model details response
|
||||
public struct ModelDetails: Codable, Sendable {
|
||||
public let id: String
|
||||
public let object: String
|
||||
public let created: Int
|
||||
public let owned_by: String
|
||||
public let capabilities: ModelCapabilities
|
||||
public let parameters: ModelParameters
|
||||
|
||||
public init(
|
||||
id: String,
|
||||
object: String = "model",
|
||||
created: Int = Int(Date().timeIntervalSince1970),
|
||||
owned_by: String = "markbase",
|
||||
capabilities: ModelCapabilities,
|
||||
parameters: ModelParameters
|
||||
) {
|
||||
self.id = id
|
||||
self.object = object
|
||||
self.created = created
|
||||
self.owned_by = owned_by
|
||||
self.capabilities = capabilities
|
||||
self.parameters = parameters
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user