Skip to content

Commit 50b6e71

Browse files
authored
Merge pull request #2 from SharpAI/feature/qwen35-support
feat: auto-detect local directory path for --model flag
2 parents 8809805 + 1232bc9 commit 50b6e71

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Sources/mlx-server/main.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,23 @@ struct MLXServer: AsyncParsableCommand {
5959
let modelId = model
6060

6161
// ── Load model ──
62-
let modelConfig = ModelConfiguration(id: modelId)
62+
// Auto-detect: if --model points to an existing local directory, load
63+
// from disk directly (no download). Otherwise treat as HF repo ID.
64+
let modelConfig: ModelConfiguration
65+
let fileManager = FileManager.default
66+
if fileManager.fileExists(atPath: modelId) {
67+
var isDir: ObjCBool = false
68+
fileManager.fileExists(atPath: modelId, isDirectory: &isDir)
69+
if isDir.boolValue {
70+
print("[mlx-server] Loading from local directory: \(modelId)")
71+
modelConfig = ModelConfiguration(directory: URL(filePath: modelId))
72+
} else {
73+
modelConfig = ModelConfiguration(id: modelId)
74+
}
75+
} else {
76+
modelConfig = ModelConfiguration(id: modelId)
77+
}
78+
6379
let container = try await LLMModelFactory.shared.loadContainer(
6480
configuration: modelConfig
6581
) { progress in

0 commit comments

Comments
 (0)