Adopt Foundation Models OS 27 surfaces: image attachments, capabilities, context size - #206
Adopt Foundation Models OS 27 surfaces: image attachments, capabilities, context size#206james-333i wants to merge 2 commits into
Conversation
|
Hi @james-333i. Thank you for this. The Here's what I'm thinking for the project overall (details in #210):
Since everything here is availability-gated and doesn't change the OS 26 surface, I'm inclined to take it now rather than hold it for 2.0. Two small things before I merge: can you split out the Does that sound reasonable? |
bc12b2c to
4750a4f
Compare
|
@mattt Sounds good. I've split the maximumResponseTokens fix into its own commit so it cherry-picks cleanly. On contextSize and supportsImageInput, I kept both as passthroughs on SystemLanguageModel since the LanguageModel protocol has no capability surface today. |
This updates the Foundation Models adapter for OS 27 while keeping the package building unchanged on Xcode 26.
Image input:
Transcriptimage segments were previously dropped when converting to a FoundationModels transcript. On OS 27 they now map toTranscript.Segment.attachmentwith anImageAttachment, built directly for URL sources and via ImageIO decoding for data sources. Verified end to end on an iPhone running iOS 27 (image prompt answered by the on-device model).Capabilities and context:
SystemLanguageModelnow exposescontextSize(back-deployed by Apple to OS 26) andsupportsImageInput, which reports the OS 27visioncapability and returns false on earlier OS versions.Generation options: the adapter now sets
maximumResponseTokensonFoundationModels.GenerationOptions. The property has existed since OS 26 but was never assigned, so response token limits were silently ignored on the Foundation Models backend. Verified on device: a capped request now terminates at the limit.The OS 27 references are behind
#if compiler(>=6.4)with runtime availability checks, so Xcode 26 builds still compile and the deployment floor is unchanged