Skip to content

Commit 77b258e

Browse files
Restore MLXLM compatibility
1 parent 913ae3f commit 77b258e

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

Sources/MLXInferenceCore/InferenceEngine.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,11 @@ public final class InferenceEngine: ObservableObject {
610610
continuation.yield(GenerationToken(text: "\n\n[Error: \(error.localizedDescription)]"))
611611
}
612612

613-
if case .error = self.state {
613+
if let latchedError = SSDStreamingErrorLatch.shared.consume() {
614+
let msg = "Model weights are corrupted or incomplete. Please re-download the model."
615+
print("[InferenceEngine] Latched SSD error after generation: \(latchedError.localizedDescription)")
616+
self.markModelCorrupted(modelId: self.currentModelId, message: msg)
617+
} else if case .error = self.state {
614618
// Already in error state from catch block above
615619
} else {
616620
self.state = self.currentModelId.map { .ready(modelId: $0) } ?? .idle

Sources/SwiftLM/Server.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,8 +1904,6 @@ func handleChatStreaming(
19041904
switch info.stopReason {
19051905
case .length:
19061906
reason = "length"
1907-
case .error:
1908-
reason = "error"
19091907
case .cancelled, .stop:
19101908
reason = hasToolCalls ? "tool_calls" : "stop"
19111909
}
@@ -2266,8 +2264,6 @@ func handleTextStreaming(
22662264
switch info.stopReason {
22672265
case .length:
22682266
reason = "length"
2269-
case .error:
2270-
reason = "error"
22712267
case .cancelled, .stop:
22722268
reason = "stop"
22732269
}

0 commit comments

Comments
 (0)