Initial commit: E4B-MarkBase model integration with passing tests
CI / build-and-test (push) Has been cancelled

- E4B-MarkBase model (42 layers, 4.4GB) loaded successfully
- All Phase 1-6 tests passed (model loading, forward pass, vision/audio towers, token generation, performance)
- All stress tests passed (5/5 in 127.6s)
  - Concurrent inference
  - Memory stress (67.5 tok/s, 0 NaN)
  - Continuous generation
  - Batch processing
  - Long-running stability
- Swift Metal inference engine with multimodal support
This commit is contained in:
MarkBase Admin
2026-06-23 18:12:35 +08:00
commit ac75faa0cc
301 changed files with 63426 additions and 0 deletions
+116
View File
@@ -0,0 +1,116 @@
import Foundation
//
// JSON Schema Response API Models
// OpenAI Compatible Format
//
/// Response format specification
public enum ResponseFormat: Codable {
case text
case jsonObject
case jsonSchema(JSONSchemaDefinition)
private enum CodingKeys: String, CodingKey {
case type
case jsonSchema = "json_schema"
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let type = try container.decode(String.self, forKey: .type)
switch type {
case "text":
self = .text
case "json_object":
self = .jsonObject
case "json_schema":
let schema = try container.decode(JSONSchemaDefinition.self, forKey: .jsonSchema)
self = .jsonSchema(schema)
default:
throw DecodingError.dataCorruptedError(
forKey: .type,
in: container,
debugDescription: "Unknown response format type: \(type)"
)
}
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
switch self {
case .text:
try container.encode("text", forKey: .type)
case .jsonObject:
try container.encode("json_object", forKey: .type)
case .jsonSchema(let schema):
try container.encode("json_schema", forKey: .type)
try container.encode(schema, forKey: .jsonSchema)
}
}
}
/// JSON Schema definition
public struct JSONSchemaDefinition: Codable {
public let name: String
public let description: String?
public let schema: JSONSchema
public let strict: Bool?
public init(
name: String,
description: String? = nil,
schema: JSONSchema,
strict: Bool? = nil
) {
self.name = name
self.description = description
self.schema = schema
self.strict = strict
}
}
/// JSON Schema
public struct JSONSchema: Codable {
public let type: String
public let properties: [String: SchemaProperty]?
public let required: [String]?
public let additionalProperties: Bool?
public init(
type: String,
properties: [String: SchemaProperty]? = nil,
required: [String]? = nil,
additionalProperties: Bool? = false
) {
self.type = type
self.properties = properties
self.required = required
self.additionalProperties = additionalProperties
}
}
/// Schema property
public struct SchemaProperty: Codable {
public let type: String
public let description: String?
public let `enum`: [String]?
public let properties: [String: SchemaProperty]?
public let required: [String]?
public init(
type: String,
description: String? = nil,
enum: [String]? = nil,
properties: [String: SchemaProperty]? = nil,
required: [String]? = nil
) {
self.type = type
self.description = description
self.enum = `enum`
self.properties = properties
self.required = required
}
}