{ private var model = SystemLanguageModel.default var body: some View { switch model.availability { case .available: // Show your intelligence UI. case .unavailable(.deviceNotEligible): // Show an alternative UI. case .unavailable(.appleIntelligenceNotEnabled): // Ask the person to turn on Apple Intelligence. case .unavailable(.modelNotReady): // The model isn't ready because it's downloading or because of other system reasons. case .unavailable(let other): // The model is unavailable for an unknown reason. } } }
{ let name = "getWeather" let description = "Retrieve the latest weather information for a city" @Generable struct Arguments { @Guide(description: "The city to fetch the weather for") var city: String } func call(arguments: Arguments) async throws -> ToolOutput { // Fetch the weather for the given city } } let session = LanguageModelSession( tools: [GetWeatherTool()], instructions: "Help the user with weather forecasts." ) let response = try await session.respond( to: "What is the temperature in Cupertino?" )
description = "Generates a VoxelModel based on input parameters." let generator = VoxelModelGenerator() @Generable struct Arguments { @Guide(description: "The name of voxel model to be generated") var modelName: String @Guide(description: "The size of each voxel") var voxelSize: Float @Guide(description: "The size of voxel model") var modelSize: Float } func call(arguments: Arguments) async throws -> VoxelModel? { let prompt = generator.prompt(modelName: arguments.modelName, voxelSize: arguments.voxelSize, modelSize: arguments.modelSize) return await generateVoxelModel(prompt: prompt) } … }
か? ツール呼び出し以外にもカスタムアダプターという機能があり、アダプターを適用 すれ 特定 ユースケースで 他 LLMを上回る性能があるらしい ※Apple Foundation Models Framework Benchmarks and Custom Adapters Training with Datawizzを参照 let adapter = try SystemLanguageModel.Adapter(fileURL: localURL) let adaptedModel = SystemLanguageModel(adapter: adapter) let session = LanguageModelSession(model: adaptedModel)
dive into the Foundation Models framework • Foundation Models Framework 概要 • 【WWDC25】 セッションメモ 「Meet the Foundation Models framework」 でApple オンデ バイスLLMについて学ぶ • うさぎでもわかる Apple Foundation Models Framework入門 - WWDC 2025で発表された オンデバイス AI 革命 • Unleashing Foundation Models • Apple Foundation Models Framework Benchmarks and Custom Adapters Training with Datawizz