feat(ai): support provider-managed files#1460
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1460 +/- ##
==========================================
- Coverage 69.28% 69.27% -0.01%
==========================================
Files 368 368
Lines 29151 29276 +125
==========================================
+ Hits 20196 20281 +85
- Misses 8042 8069 +27
- Partials 913 926 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds first-class, provider-managed AI file handles (by ID) so callers can reuse previously uploaded files in later prompts, retrieve their content, and delete them—bringing Goravel’s AI attachments closer to a full upload/get/delete lifecycle across providers.
Changes:
- Extend
contracts/ai.FileProviderwithGetFileandDeleteFile, plus newFileResponse/ProviderFilecontracts. - Add
DocumentFromID/ImageFromIDconstructors (andai/document+ai/imagewrappers) to attach stored file IDs and laterGet/Deletethem. - Update OpenAI provider to serialize
from IDattachments viafile_idreferences and implement file get/delete, with expanded tests and mocks.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
contracts/ai/provider.go |
Extends FileProvider contract with GetFile/DeleteFile. |
contracts/ai/attachment.go |
Introduces FileResponse and ProviderFile interfaces for stored-file handles. |
ai/application.go |
Adds getFile / deleteFile routing through provider resolution and capability checks. |
errors/list.go |
Adds a centralized error for empty stored file IDs. |
ai/file.go |
Implements ID-backed attachments (stored) supporting Get/Delete and file_id reuse. |
ai/document/file.go |
Re-exports FromID for document handles. |
ai/image/file.go |
Re-exports FromID for image handles. |
ai/openai/provider.go |
Adds OpenAI GetFile/DeleteFile and serializes ID-backed attachments as file_id. |
ai/openai/response.go |
Adds OpenAI fileResponse implementation for FileResponse. |
ai/openai/provider_test.go |
Adds tests for file_id attachment serialization and OpenAI get/delete file flows. |
ai/application_test.go |
Adds tests for Application.getFile/deleteFile including empty-id validation. |
ai/file_test.go |
Adds tests for DocumentFromID get/delete behavior and facade-not-set errors. |
mocks/ai/FileProvider.go |
Updates mock to include new GetFile/DeleteFile methods. |
mocks/ai/FileResponse.go |
Adds mock for new contracts/ai.FileResponse. |
mocks/ai/ProviderFile.go |
Adds mock for new contracts/ai.ProviderFile. |
hwbrzzl
force-pushed
the
bowen/optimize-files-1
branch
from
May 3, 2026 14:36
eee9e94 to
744ebe1
Compare
| } | ||
| r.mu.Unlock() | ||
|
|
||
| return content, nil |
Comment on lines
+336
to
+341
| r.mu.RLock() | ||
| if len(r.content) > 0 { | ||
| content := bytes.Clone(r.content) | ||
| r.mu.RUnlock() | ||
| return content, nil | ||
| } |
LinboLen
added a commit
to LinboLen/framework
that referenced
this pull request
May 3, 2026
* origin/master: fix(ai): remove context from image response content (goravel#1462) feat(ai): support provider-managed files (goravel#1460) feat(ai): add image generation support (goravel#1461) fix: [goravel#946] stop WithContext from leaking framework context keys (goravel#1456) feat(ai): add attachment upload support (goravel#1459) feat(ai): add attachment helper subpackages (goravel#1458) feat(ai): switch OpenAI provider to responses API (goravel#1457) feat(ai): add attachment support (goravel#1455)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Why
Goravel already supported uploading attachments, but it stopped at returning a provider file ID. That left no user-facing way to fetch a stored file later, delete it, or reuse it in a later conversation like the Laravel AI SDK files guide describes.
This change closes that gap by making ID-backed files first-class handles in the AI package and teaching the OpenAI provider to resolve and delete stored files as well as serialize
from IDattachments withfile_idreferences.