[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-74309":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":25,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":27,"readmeContent":28,"aiSummary":29,"trendingCount":16,"starSnapshotCount":16,"syncStatus":30,"lastSyncTime":31,"discoverSource":32},74309,"python-apple-fm-sdk","apple\u002Fpython-apple-fm-sdk","apple","Python bindings for access to the on-device model at the core of Apple Intelligence through the Foundation Models framework","https:\u002F\u002Fapple.github.io\u002Fpython-apple-fm-sdk\u002F",null,"Python",1130,66,12,4,0,83,92,105,249,18.48,"Apache License 2.0",false,"main",true,[],"2026-06-12 02:03:25","# Foundation Models SDK for Python\n\nPython bindings for Apple's [Foundation Models framework](https:\u002F\u002Fdeveloper.apple.com\u002Fdocumentation\u002Ffoundationmodels), providing access to the on-device foundation model\nat the core of Apple Intelligence on macOS.\n\n## Overview\n\nThe Foundation Models SDK for Python provides a Pythonic interface to Apple's Foundation Models framework.\n\nYou can:\n\n- **Evaluate Swift Foundation Models app features** by running batch inference and analyzing results from Python\n- Perform **on-device inference** with the system foundation model\n- Stream **real-time text generation** responses\n- Use **guided generation** with structured output schemas and constraints\n- Get **type-safe responses** using Python decorators for guided generation\n- Configure **custom model settings** for different model options\n- Process **transcripts exported from Swift apps** for quality analysis\n\nKeep in mind that it's your responsibility to design AI experiences with care.\nTo learn about practical strategies you can implement in code, **check out:**\n[Improving the safety of generative model output](https:\u002F\u002Fdeveloper.apple.com\u002Fdocumentation\u002Ffoundationmodels\u002Fimproving-the-safety-of-generative-model-output)\nand Apple's [Human Interface Guidelines on Generative AI](https:\u002F\u002Fdeveloper.apple.com\u002Fdesign\u002Fhuman-interface-guidelines\u002Fgenerative-ai).\n\n## Requirements\n\n- macOS 26.0+\n- Download [Xcode 26.0+](https:\u002F\u002Fdeveloper.apple.com\u002Fxcode\u002F) and agree to the [Xcode and Apple SDKs agreement](https:\u002F\u002Fwww.apple.com\u002Flegal\u002Fsla\u002Fdocs\u002Fxcode.pdf) in the Xcode app.\n- Python 3.10+\n- Apple Intelligence turned on for [a compatible Mac](https:\u002F\u002Fsupport.apple.com\u002Fen-us\u002F121115)\n\n## Contributing\n\nThis project is not yet taking contributions. Stay tuned!\n\n## Installation\n\n```bash\npip install apple-fm-sdk\n```\n\nAlternatively, you can use the development install instructions below.\n\n## Documentation\n\n- [Documentation page](https:\u002F\u002Fapple.github.io\u002Fpython-apple-fm-sdk\u002F)\n- [Code examples](https:\u002F\u002Fgithub.com\u002Fapple\u002Fpython-apple-fm-sdk\u002Ftree\u002Fmain\u002Fexamples)\n\n## Basic usage\n\n```python\nimport apple_fm_sdk as fm\nimport asyncio\n\nasync def main():\n    # Get the default system foundation model\n    model = fm.SystemLanguageModel()\n\n    # Check if the model is available\n    is_available, reason = model.is_available()\n    if is_available:\n        # Create a session\n        session = fm.LanguageModelSession()\n\n        # Generate a response\n        response = await session.respond(\"Hello, how are you?\")\n        print(f\"Model response: {response}\")\n    else:\n        print(f\"Foundation Models not available: {reason}\")\n\n# Run async function\nasyncio.run(main())\n```\n\nYou can also use guided generation to ask the model to generate an\nobject from a specific Python class marked with the `generable` decorator:\n\n```python\nimport apple_fm_sdk as fm\n\n@fm.generable # This decorator signals this type be generated by a model\nclass Cat:\n    name: str\n    age:int = fm.guide(\"Age in years\", range=(0, 20))\n\nasync def generate_cat():\n    # Get the default system foundation model\n    model = fm.SystemLanguageModel()\n\n    # Check if the model is available\n    is_available, reason = model.is_available()\n    if is_available:\n        # Create a session\n        session = fm.LanguageModelSession()\n\n        # Generate a response of the type Cat\n        cat = await session.respond(\"Generate an adorable rescue cat\", generating=Cat)\n        print(f\"Model response: {cat}\")\n    else:\n        print(f\"Foundation Models not available: {reason}\")\n```\n\n### Development Installation\n\nIf you need to modify the SDK or install from source:\n\n1. Get the code\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fapple\u002Fpython-apple-fm-sdk\ncd python-apple-fm-sdk\n```\n\n2. (Optional but recommended) Make a virtual environment. Install [uv](https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002Fgetting-started\u002Finstallation\u002F) (or your package manager of choice) then:\n\n```bash\nuv venv\nsource .venv\u002Fbin\u002Factivate\n```\n\n3. Install the package locally in editable mode:\n\n```bash\nuv sync\n```\n\n4. After making any change, be sure to build the project again and test:\n\n```bash\nuv pip install -e .\npytest\n```\n\n---\n\nFor licensing see accompanying LICENSE file.\nCopyright (C) 2026 Apple Inc. All Rights Reserved.\n","apple\u002Fpython-apple-fm-sdk 项目提供了 Python 绑定，以访问 Apple 设备上基于 Foundation Models 框架的核心模型。核心功能包括通过 Python 接口进行批量推理、实时文本生成、以及使用结构化输出模式和约束的引导生成等。技术特点涵盖类型安全响应、自定义模型设置，并支持处理从 Swift 应用导出的转录文件。适用于 macOS 开发者希望在本地设备上利用 Apple Intelligence 进行 AI 功能评估与开发的场景，特别是在需要确保生成内容安全性的情况下。",2,"2026-06-11 03:49:54","high_star"]