帮助开发者在 iOS 26+ 中集成端侧大模型生成、工具调用与流式输出。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "foundation-models-on-device" 技能: 1. 下载 https://raw.githubusercontent.com/affaan-m/ECC/main/skills/foundation-models-on-device/SKILL.md 2. 保存为 ~/.claude/skills/foundation-models-on-device/SKILL.md 3. 装好后重载技能,告诉我可以用了
请为 iOS 26+ 编写一个使用 Apple FoundationModels framework 的 Swift 示例,演示基础文本生成流程,包括模型调用、提示词传入、结果展示,以及适合 SwiftUI 应用集成的代码结构。
一份可参考的 Swift/SwiftUI 集成示例,说明如何在应用中接入端侧文本生成。
请用 Apple FoundationModels framework 说明如何使用 @Generable 定义结构化输出,生成一个“会议纪要”对象,包含标题、摘要、行动项和负责人,并给出完整 Swift 示例。
包含 @Generable 数据模型与调用代码的示例,可用于稳定生成结构化结果。
请演示在 Apple FoundationModels framework 中实现 tool calling 和 snapshot streaming:定义一个获取天气的工具,让模型根据用户问题调用它,并实时流式返回中间与最终结果,使用 Swift 编写。
一套展示工具定义、模型调用和流式更新 UI 的 Swift 实现方案。
Patterns for integrating Apple's on-device language model into apps using the FoundationModels framework. Covers text generation, structured output with @Generable, custom tool calling, and snapshot streaming — all running on-device for privacy and offline support.
Always check model availability before creating a session:
struct GenerativeView: View {
private var model = SystemLanguageModel.default
var body: some View {
switch model.availability {
case .available:
ContentView()
case .unavailable(.deviceNotEligible):
Text("Device not eligible for Apple Intelligence")
case .unavailable(.appleIntelligenceNotEnabled):
Text("Please enable Apple Intelligence in Settings")
case .unavailable(.modelNotReady):
Text("Model is downloading or not ready")
case .unavailable(let other):
Text("Model unavailable: \(other)")
}
}
}
// Single-turn: create a new session each time
let session = LanguageModelSession()
let response = try await session.respond(to: "What's a good month to visit Paris?")
print(response.content)
// Multi-turn: reuse session for conversation context
let session = LanguageModelSession(instructions: """
You are a cooking assistant.
Provide recipe suggestions based on ingredients.
Keep suggestions brief and practical.
""")
let first = try await session.respond(to: "I have chicken and rice")
let followUp = try await session.respond(to: "What about a vegetarian option?")
Key points for instructions:
Generate structured Swift types instead of raw strings:
@Generable(description: "Basic profile information about a cat")
struct CatProfile {
var name: String
@Guide(description: "The age of the cat", .range(0...20))
var age: Int
@Guide(description: "A one sentence profile about the cat's personality")
var profile: String
}
let response = try await session.respond(
to: "Generate a cute rescue cat",
generating: CatProfile.self
)
// Access structured fields directly
print("Name: \(response.content.name)")
print("Age: \(response.content.age)")
print("Profile: \(response.content.profile)")
.range(0...20) — numeric range.count(3) — array element countdescription: — semantic guidance for generationLet the model invoke custom code for domain-specific tasks:
struct RecipeSearchTool: Tool {
let name = "recipe_search"
let description = "Search for recipes matching a given term and return a list of results."
@Generable
struct Arguments {
var searchTerm: String
var numberOfResults: Int
}
func call(arguments: Arguments) async throws -> ToolOutput {
let recipes = await searchRecipes(
term: arguments.searchTerm,
limit: arguments.numberOfResults
)
return .string(recipes.map { "- \($0.name): \($0.description)" }.joined(separator: "\n"))
}
}
…
帮助开发者用 Node/TypeScript 快速构建符合规范的 MCP 服务器与工具能力
帮助开发者为 React 与 Next.js 交互界面实现无障碍设计与可用性优化。
将本地 Hermes 工作流清理并转换为可公开复用的 ECC 技能与发布产物。
帮助开发者处理 Vite 配置、插件、构建优化与 SSR 等实战问题
用安全的 Netmiko 模式批量执行 SSH 采集、解析与受控变更。
帮助你在 EVM 多链应用中安全处理代币精度与小数位差异
调用 Apple 端侧基础模型,完成文本生成、摘要与分类等智能处理。
通过 MCP 客户端在 macOS 上调用本地 Apple 端侧模型进行生成与对话
在安卓设备上本地运行多模态 AI,完成对话、识图、转写与生图任务
帮助开发者完成苹果平台应用的验证、编码与上架优化等开发任务。
帮助 Apple 开发者实时查文档、分析 Xcode 报错并核对 Swift 提案
帮助开发者在 iOS 模拟器中构建、运行并交互测试应用,节省调试上下文。