feat: add image upload search via local Ollama vision#1072
Open
tsgdgszjj-sketch wants to merge 2 commits intoItzCrazyKns:masterfrom
Open
feat: add image upload search via local Ollama vision#1072tsgdgszjj-sketch wants to merge 2 commits intoItzCrazyKns:masterfrom
tsgdgszjj-sketch wants to merge 2 commits intoItzCrazyKns:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
2 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/components/MessageInputActions/Attach.tsx">
<violation number="1" location="src/components/MessageInputActions/Attach.tsx:42">
P2: Early return on any selected image prevents uploading/attaching other selected files, causing mixed selections to be dropped.</violation>
</file>
<file name="src/app/api/vision/route.ts">
<violation number="1" location="src/app/api/vision/route.ts:13">
P2: Uploaded image is read into memory and base64-encoded without any size/type validation, allowing oversized or invalid uploads to consume memory and be forwarded to the model.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| data.append('files', e.target.files![i]); | ||
| } | ||
|
|
||
| if (hasImage && imageFile) { |
Contributor
There was a problem hiding this comment.
P2: Early return on any selected image prevents uploading/attaching other selected files, causing mixed selections to be dropped.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/components/MessageInputActions/Attach.tsx, line 42:
<comment>Early return on any selected image prevents uploading/attaching other selected files, causing mixed selections to be dropped.</comment>
<file context>
@@ -29,10 +29,30 @@ const Attach = () => {
data.append('files', e.target.files![i]);
}
+ if (hasImage && imageFile) {
+ const visionData = new FormData();
+ visionData.append('image', imageFile);
</file context>
Suggested change
| if (hasImage && imageFile) { | |
| if (hasImage && imageFile && e.target.files!.length === 1) { |
| return NextResponse.json({ message: 'Missing image' }, { status: 400 }); | ||
| } | ||
|
|
||
| const buffer = Buffer.from(await imageFile.arrayBuffer()); |
Contributor
There was a problem hiding this comment.
P2: Uploaded image is read into memory and base64-encoded without any size/type validation, allowing oversized or invalid uploads to consume memory and be forwarded to the model.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/app/api/vision/route.ts, line 13:
<comment>Uploaded image is read into memory and base64-encoded without any size/type validation, allowing oversized or invalid uploads to consume memory and be forwarded to the model.</comment>
<file context>
@@ -0,0 +1,50 @@
+ return NextResponse.json({ message: 'Missing image' }, { status: 400 });
+ }
+
+ const buffer = Buffer.from(await imageFile.arrayBuffer());
+ const base64Image = buffer.toString('base64');
+ const mimeType = imageFile.type;
</file context>
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
Notes
Summary by cubic
Adds image upload search powered by a local Ollama vision model via the new
/api/visionroute. When users attach an image, we generate a concise search query and run it through the existing text search flow.New Features
Attach.tsx, calls/api/vision, then sends a search message with the returned query.POST /api/visionthat reads an image and usesopenaiwith an Ollama-compatiblebaseURLto produce a query.image/*.Migration
OLLAMA_BASE_URLto your OpenAI-compatible Ollama endpoint.OLLAMA_VISION_MODELto a vision model (e.g.,qwen3-vl:latest).Written for commit d31ba3d. Summary will update on new commits.