mirror of
https://github.com/h3pdesign/Neon-Vision-Editor
synced 2026-04-21 13:27:16 +00:00
fix: gate FoundationModels on availability
This commit is contained in:
parent
5cc6b49b14
commit
4cc5a608b3
4 changed files with 11 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import Foundation
|
||||
|
||||
#if USE_FOUNDATION_MODELS
|
||||
#if USE_FOUNDATION_MODELS && canImport(FoundationModels)
|
||||
import FoundationModels
|
||||
#endif
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ public struct AppleIntelligenceAIClient: AIClient {
|
|||
public init() {}
|
||||
|
||||
public func streamSuggestions(prompt: String) -> AsyncStream<String> {
|
||||
#if USE_FOUNDATION_MODELS
|
||||
#if USE_FOUNDATION_MODELS && canImport(FoundationModels)
|
||||
// Delegate to the centralized Apple Foundation Models streaming helper.
|
||||
return AppleFM.appleFMStream(prompt: prompt)
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ struct NeonVisionEditorApp: App {
|
|||
.environment(\.grokErrorMessage, $grokErrorMessage)
|
||||
.frame(minWidth: 600, minHeight: 400)
|
||||
.task {
|
||||
#if USE_FOUNDATION_MODELS
|
||||
#if USE_FOUNDATION_MODELS && canImport(FoundationModels)
|
||||
do {
|
||||
let start = Date()
|
||||
_ = try await AppleFM.appleFMHealthCheck()
|
||||
|
|
@ -350,7 +350,7 @@ struct NeonVisionEditorApp: App {
|
|||
let geminiToken = SecureTokenStore.token(for: .gemini)
|
||||
|
||||
let client: AIClient? = {
|
||||
#if USE_FOUNDATION_MODELS
|
||||
#if USE_FOUNDATION_MODELS && canImport(FoundationModels)
|
||||
if useAppleIntelligence {
|
||||
return AIClientFactory.makeClient(for: AIModel.appleIntelligence)
|
||||
}
|
||||
|
|
@ -358,7 +358,7 @@ struct NeonVisionEditorApp: App {
|
|||
if !grokToken.isEmpty { return AIClientFactory.makeClient(for: .grok, grokAPITokenProvider: { grokToken }) }
|
||||
if !openAIToken.isEmpty { return AIClientFactory.makeClient(for: .openAI, openAIKeyProvider: { openAIToken }) }
|
||||
if !geminiToken.isEmpty { return AIClientFactory.makeClient(for: .gemini, geminiKeyProvider: { geminiToken }) }
|
||||
#if USE_FOUNDATION_MODELS
|
||||
#if USE_FOUNDATION_MODELS && canImport(FoundationModels)
|
||||
return AIClientFactory.makeClient(for: .appleIntelligence)
|
||||
#else
|
||||
return nil
|
||||
|
|
@ -385,7 +385,7 @@ struct NeonVisionEditorApp: App {
|
|||
Divider()
|
||||
Button("Run AI Check") {
|
||||
Task {
|
||||
#if USE_FOUNDATION_MODELS
|
||||
#if USE_FOUNDATION_MODELS && canImport(FoundationModels)
|
||||
do {
|
||||
let start = Date()
|
||||
_ = try await AppleFM.appleFMHealthCheck()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#if USE_FOUNDATION_MODELS
|
||||
#if USE_FOUNDATION_MODELS && canImport(FoundationModels)
|
||||
import Foundation
|
||||
import FoundationModels
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import AppKit
|
|||
#elseif canImport(UIKit)
|
||||
import UIKit
|
||||
#endif
|
||||
#if USE_FOUNDATION_MODELS
|
||||
#if USE_FOUNDATION_MODELS && canImport(FoundationModels)
|
||||
import FoundationModels
|
||||
#endif
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ struct ContentView: View {
|
|||
@State private var languagePromptSelection: String = "plain"
|
||||
@State private var languagePromptInsertTemplate: Bool = false
|
||||
|
||||
#if USE_FOUNDATION_MODELS
|
||||
#if USE_FOUNDATION_MODELS && canImport(FoundationModels)
|
||||
var appleModelAvailable: Bool { true }
|
||||
#else
|
||||
var appleModelAvailable: Bool { false }
|
||||
|
|
@ -1132,7 +1132,7 @@ struct ContentView: View {
|
|||
}
|
||||
isAutoCompletionEnabled.toggle()
|
||||
if willEnable {
|
||||
#if USE_FOUNDATION_MODELS
|
||||
#if USE_FOUNDATION_MODELS && canImport(FoundationModels)
|
||||
AppleFM.isEnabled = true
|
||||
#endif
|
||||
maybePromptForLanguageSetup()
|
||||
|
|
@ -1346,7 +1346,7 @@ struct ContentView: View {
|
|||
// Supported languages in our picker
|
||||
let supported = ["swift", "python", "javascript", "typescript", "php", "java", "kotlin", "go", "ruby", "rust", "cobol", "dotenv", "proto", "graphql", "rst", "nginx", "sql", "html", "css", "c", "cpp", "objective-c", "csharp", "json", "xml", "yaml", "toml", "csv", "ini", "vim", "log", "ipynb", "markdown", "bash", "zsh", "powershell", "standard", "plain"]
|
||||
|
||||
#if USE_FOUNDATION_MODELS
|
||||
#if USE_FOUNDATION_MODELS && canImport(FoundationModels)
|
||||
// Attempt a lightweight model-based detection via AppleIntelligenceAIClient if available
|
||||
do {
|
||||
let client = AppleIntelligenceAIClient()
|
||||
|
|
|
|||
Loading…
Reference in a new issue