```
feat(AI): 集成MNN推理引擎替换MLX作为主AI运行时 - 引入MNN(alibaba) + Arm SME2 + CPU作为主AI运行时,支持A19/iPhone17的 SME2和A17的NEON加速 - 添加MLX Swift作为兜底GPU推理方案,实现双后端切换机制 - 使用单一Qwen3.5-2B多模态模型(1.2GB),替代原有的LLM+VL分离架构 - 实现InferenceEngine.current引擎选择逻辑,真机默认MNN,模拟器回退MLX - 更新AIAgent架构,通过MNNLLMBridge(ObjC++) → MNNBackend进行推理 - 修改队列机制防止并发推理导致OOM,使用信号量闸门控制显存占用 - 更新文档中的技术栈说明、模块边界和周次交付计划 ```
This commit is contained in:
@@ -17,6 +17,7 @@ struct ModelsSchemaTests {
|
||||
UserProfile.self,
|
||||
MetricReminder.self,
|
||||
CustomMonitorMetric.self,
|
||||
Medication.self,
|
||||
])
|
||||
let config = ModelConfiguration(schema: schema, isStoredInMemoryOnly: true)
|
||||
return try ModelContainer(for: schema, configurations: [config])
|
||||
@@ -190,4 +191,42 @@ struct ModelsSchemaTests {
|
||||
#expect(fetched.bloodTypeRaw == "A")
|
||||
#expect(fetched.chronicConditions == ["高血压"])
|
||||
}
|
||||
|
||||
@Test func medicationRoundtripAndDetailLine() throws {
|
||||
let container = try makeContainer()
|
||||
let ctx = ModelContext(container)
|
||||
|
||||
let med = Medication(name: "缬沙坦胶囊", strength: "80mg×7粒", usage: "一日一次,一次一粒")
|
||||
ctx.insert(med)
|
||||
try ctx.save()
|
||||
|
||||
let fetched = try #require(try ctx.fetch(FetchDescriptor<Medication>()).first)
|
||||
#expect(fetched.name == "缬沙坦胶囊")
|
||||
#expect(fetched.detailLine == "80mg×7粒 · 一日一次,一次一粒")
|
||||
#expect(fetched.updatedAt == fetched.createdAt)
|
||||
}
|
||||
|
||||
@Test func medicationDetailLineOmitsEmptyParts() {
|
||||
#expect(Medication(name: "维生素C").detailLine == "")
|
||||
#expect(Medication(name: "钙片", strength: "600mg").detailLine == "600mg")
|
||||
}
|
||||
|
||||
@Test func cascadeDeleteMedicationRemovesAssets() throws {
|
||||
let container = try makeContainer()
|
||||
let ctx = ModelContext(container)
|
||||
|
||||
let med = Medication(name: "二甲双胍缓释片", strength: "0.5g×30片")
|
||||
let asset = Asset(relativePath: "med-1.jpg", bytes: 2048)
|
||||
ctx.insert(asset)
|
||||
med.assets.append(asset)
|
||||
ctx.insert(med)
|
||||
try ctx.save()
|
||||
#expect(med.assets.count == 1)
|
||||
|
||||
ctx.delete(med)
|
||||
try ctx.save()
|
||||
|
||||
#expect(try ctx.fetch(FetchDescriptor<Medication>()).isEmpty)
|
||||
#expect(try ctx.fetch(FetchDescriptor<Asset>()).isEmpty)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user