Update LLMHelper diagnostic reporting and swiftc target version
This commit is contained in:
+15
-14
@@ -1,9 +1,4 @@
|
||||
// LLMHelper.swift - Interface with macOS native on-device LLM (FoundationModels / Apple Intelligence)
|
||||
//
|
||||
// Usage:
|
||||
// llm-helper --check
|
||||
// llm-helper --prompt "Hello" [--system "System prompt"]
|
||||
|
||||
// LLMHelper.swift - Interface with macOS native Apple Intelligence FoundationModels
|
||||
import Foundation
|
||||
import FoundationModels
|
||||
|
||||
@@ -48,17 +43,28 @@ func fail(_ message: String) -> Never {
|
||||
}
|
||||
|
||||
@main
|
||||
@available(macOS 26.0, *)
|
||||
struct LLMHelperApp {
|
||||
static func main() async {
|
||||
let options = parseArguments()
|
||||
|
||||
let model = SystemLanguageModel.default
|
||||
let isAvailable = model.isAvailable
|
||||
|
||||
if options.check {
|
||||
let model = SystemLanguageModel.default
|
||||
let isAvailable = model.isAvailable
|
||||
var attemptError: String = ""
|
||||
do {
|
||||
let session = LanguageModelSession(model: model)
|
||||
_ = try await session.respond(to: "test")
|
||||
} catch {
|
||||
attemptError = error.localizedDescription
|
||||
}
|
||||
|
||||
emit([
|
||||
"available": isAvailable,
|
||||
"model": "macOS SystemLanguageModel",
|
||||
"reason": isAvailable ? "macOS Apple Intelligence model available" : "SystemLanguageModel unavailable on this hardware/OS configuration"
|
||||
"attemptError": attemptError,
|
||||
"reason": isAvailable ? "macOS Apple Intelligence model available" : "SystemLanguageModel isAvailable returned false (\(attemptError))"
|
||||
])
|
||||
exit(0)
|
||||
}
|
||||
@@ -68,11 +74,6 @@ struct LLMHelperApp {
|
||||
}
|
||||
|
||||
do {
|
||||
let model = SystemLanguageModel.default
|
||||
guard model.isAvailable else {
|
||||
fail("macOS SystemLanguageModel is not available on this machine")
|
||||
}
|
||||
|
||||
let instructions = options.systemPrompt ?? ""
|
||||
let session: LanguageModelSession
|
||||
if !instructions.isEmpty {
|
||||
|
||||
Reference in New Issue
Block a user