You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add Foundation Models 27 prompt attachments - #310
add the Foundation Models 27-style typed image Attachment prompt surface
preserve ordered text and image segments through Prompt builders and LanguageModelSession transcripts
bridge CGImage and local image URLs to the native FoundationModels API on OS 27, with explicit errors on unsupported system runtimes
Scope
This PR is intentionally prompt-only. Tool-output attachments, instruction attachments, labels, CIImage, pixel buffers, and data attachments are left for separate reviewable changes.
Validation
swift format lint --strict --recursive .
swift test --filter PromptAttachmentTests (4 tests)
Duplicate suppression lowers the prompt a second time. For an oriented URL attachment this rereads and re-encodes the file after the session has already recorded its segments; if the file changes or becomes unreadable between those operations, the payload comparison fails and the same current prompt remains in history while also being passed as fmPrompt. CGImage prompts also pay for PNG encoding twice. Compare against the already-lowered current prompt occurrence instead of regenerating attachment payloads here.
Addressed the previously missed attachment re-lowering issue in 94deb2e. Recorded prompt occurrences now use deterministic segment IDs, duplicate suppression matches those IDs without reopening/re-encoding attachment sources, and empty Prompt builders retain one empty text segment. Added regression coverage for deleting an attachment file after transcript recording and for empty builders. Fresh verification: CI=1 swift test (687 tests passed).
These thrown errors are internal and have no localized description, so callers only receive an opaque message such as PromptBridgeError error 0 when an attachment is rejected. Add actionable messages that distinguish an unsupported runtime/toolchain from a non-file URL.
Document Swift and platform requirements accurately
README.md:404
This overstates platform support: the bridge is compiled only with Swift 6.4+ and explicitly excludes tvOS and watchOS, where line 467 throws attachmentsUnavailable even on OS 27. Document the actual compiler and platform requirements so users do not expect this example to work there.
Thanks, @qoli. To get this into 1.0, I opened #321 with your commits and a few fixes on top: the watchOS build, descriptions for the attachment errors, and the platform requirements in the README. I'll close this in favor of that one. #312 and #316 will need a rebase on main after it merges. Thanks again!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Scope
This PR is intentionally prompt-only. Tool-output attachments, instruction attachments, labels, CIImage, pixel buffers, and data attachments are left for separate reviewable changes.
Validation