feat: add WWDC26 Apple Intelligence APIs#218
Conversation
|
@JKobrynski is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Exposes Apple Foundation Models “history management” utilities (summarization, rolling window, completed tool-call pruning) as fluent JS model wrappers in @react-native-ai/apple, adds native support for model info + Image Playground, and extends the Expo example app to toggle/demo the new behaviors.
Changes:
- Add fluent Apple language model wrappers (
summarizeHistory,rollingWindow,droppingCompletedToolCalls) and apply transforms before bothdoGenerateanddoStream. - Add native APIs for
getModelInfoandgenerateImages, plus JS exports/types and updated docs/README. - Add “Apple History Demo” toggles + sliders in the Expo example app and preserve existing chat behavior when disabled.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| website/src/docs/apple/generating.md | Updates Apple provider docs (availability, PCC, images, history helpers, error handling). |
| packages/apple-llm/src/NativeAppleLLM.ts | Extends TurboModule typings to support attachments/providerOptions + new native methods. |
| packages/apple-llm/src/index.ts | Exports new Apple provider types + trimAppleMessagesForContext. |
| packages/apple-llm/src/AppleFoundationModels.ts | Adds JS fallbacks/wrappers for getModelInfo and generateImages. |
| packages/apple-llm/src/ai-sdk.ts | Implements fluent history wrappers, image model, prompt attachment handling, and model-info API. |
| packages/apple-llm/README.md | Documents new features and requirements + shows fluent history usage. |
| packages/apple-llm/ios/AppleLLMImpl.swift | Implements getModelInfo, Image Playground generation, attachments, PCC, Vision tools plumbing. |
| packages/apple-llm/ios/AppleLLMError.swift | Refines invalid-message error shape/message. |
| packages/apple-llm/ios/AppleLLM.mm | Bridges new options + adds getModelInfo/generateImages TurboModule methods. |
| apps/expo-example/src/store/chatStore.ts | Adds persisted settings for the Apple History Demo. |
| apps/expo-example/src/screens/ChatScreen/SettingsSheet.tsx | Adds History Demo toggle + sliders for window/threshold. |
| apps/expo-example/src/screens/ChatScreen/index.tsx | Applies fluent history wrappers when demo enabled; improves empty state text plumbing. |
| apps/expo-example/src/screens/ChatScreen/ChatMessages.tsx | Accepts precomputed empty-state subtitle from parent. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function isToolRelatedMessage(message: LanguageModelV3Message) { | ||
| if (message.role === 'tool') { | ||
| return true | ||
| } | ||
|
|
||
| if (message.role !== 'assistant') { | ||
| return false | ||
| } | ||
|
|
||
| return message.content.some( | ||
| (part) => part.type === 'tool-call' || part.type === 'tool-result' | ||
| ) | ||
| } |
| export interface AppleContextOptions { | ||
| /** | ||
| * Keep the first system message and only the last N non-system messages. | ||
| */ | ||
| rollingWindowMessages?: number | ||
| /** | ||
| * Remove completed tool-call/tool-result entries from older context. | ||
| */ | ||
| dropCompletedToolCalls?: boolean | ||
| } |
| if (file.type === 'url') { | ||
| return { | ||
| mediaType: 'image/png', | ||
| data: file.url, | ||
| } | ||
| } |
| throw new Error( | ||
| `Unsupported Apple Foundation Models message content type: ${JSON.stringify(part)}` | ||
| ) |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Please have a look at outstanding copilot comments and decide whether to address them or not. Quick comment:
Would that be AI SDK native way, or shall we instead use options via I am more familiar with the latter. |
|
Please do a follow-up after this one is merged to #217 - I guess partial support for private cloud compute is done here, but we also need to do support for "reasoning" option, some errors and potentially other things (exact diff to be checked). |
Related PR - #215
Summary
Builds on the WWDC26 Apple Intelligence API work from #215 and finishes the JS-facing history management API for
@react-native-ai/apple.PR #215 added the broader Apple Intelligence surface, including Apple provider options, model info APIs, iOS 27 Private Cloud Compute support, image prompts, Image Playground generation, Vision built-in tools, and lower-level native helpers. It also introduced context/history utilities internally.
This change exposes those history management utilities as fluent AI SDK model wrappers so consumers can compose Apple history behavior directly from JS:
It also adds demo app controls for testing the behavior without replacing the existing basic chat flow.
Changes
summarizeHistory(threshold, model)rollingWindow(entries)droppingCompletedToolCalls()doGenerateanddoStreamTesting
bun run --filter='@react-native-ai/apple' typecheckbun run --filter='@react-native-ai/example' typecheckbun lintgit diff --check