- Delete doc/HOW_TO_BUILD_E4B_IOS_APP.md (entirely obsolete) - Podfile: remove MediaPipeTasksGenAI/C pods (not used, code uses MLX SPM) - pod install: regenerated Podfile.lock (1 pod: Yams only) - README.md: remove E4B from hardware requirements - LLMEngine.swift: clean MediaPipe from comments - MLXLocalLLMService.swift: replace E4B → E2B in inline comments - PromptBuilder.swift: replace E4B → E2B in inline comments - AgentEngine.swift: replace LiteRT-LM comment with MLX - doc/iphone_agent_permissions_*.md: replace E4B → Gemma 4
35 lines
989 B
Swift
35 lines
989 B
Swift
import Foundation
|
|
import CoreImage
|
|
|
|
// MARK: - LLM Engine Protocol
|
|
|
|
/// Thin protocol for on-device LLM inference engines.
|
|
public protocol LLMEngine {
|
|
func load() async throws
|
|
func warmup() async throws
|
|
func generateStream(prompt: String, images: [CIImage]) -> AsyncThrowingStream<String, Error>
|
|
func cancel()
|
|
func unload()
|
|
var stats: LLMStats { get }
|
|
var isLoaded: Bool { get }
|
|
var isGenerating: Bool { get }
|
|
}
|
|
|
|
public extension LLMEngine {
|
|
func generateStream(prompt: String) -> AsyncThrowingStream<String, Error> {
|
|
generateStream(prompt: prompt, images: [])
|
|
}
|
|
}
|
|
|
|
/// Runtime statistics for the inference engine.
|
|
public struct LLMStats {
|
|
public var loadTimeMs: Double = 0
|
|
public var ttftMs: Double = 0 // time to first token
|
|
public var tokensPerSec: Double = 0
|
|
public var peakMemoryMB: Double = 0
|
|
public var totalTokens: Int = 0
|
|
public var backend: String = "unknown" // "mlx-gpu"
|
|
|
|
public init() {}
|
|
}
|