Created
January 15, 2025 03:31
-
-
Save kunal732/a18e83f3e477b687e5c925a54abb4f0c to your computer and use it in GitHub Desktop.
Adding Microsoft's Phi-4 LLM in your swift MacOS application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import MLXModelManager | |
struct ContentView: View { | |
@StateObject var Phi4Manager = ModelManager(modelPath: "mlx-community/phi-4-4bit") | |
var body: some View { | |
VStack { | |
Button("answer prompt"){ | |
Task { | |
//load model | |
try await Phi4Manager.loadModel() | |
//inference | |
await Phi4Manager.generate( | |
prompt: "why is the sky blue ?" | |
) | |
} | |
} | |
//Model Output | |
Text(Phi4Manager.output) | |
} | |
.padding() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment