feat(vision): image + screen input for jarvis ask#486
Open
joshazmy wants to merge 1 commit into
Open
Conversation
OpenJarvis can run vision-capable local models (gemma3, qwen2.5-vl), but the CLI had no way to send them a picture -- the Ollama engine only serialized text. This adds end-to-end image input. What's new - `jarvis ask -i/--image <file>` attaches one or more images to the query. - `jarvis ask -S/--screen` captures the primary monitor (dependency-free on Windows via .NET; mss/Pillow fallback elsewhere). - Vision auto-routes to direct-to-engine mode; with an explicit --agent it warns rather than silently dropping the image. - Privacy guard: warns before sending an image to a non-local engine, keeping OpenJarvis local-first by default. - Context-window default raised 8k -> 16k (JARVIS_NUM_CTX) so an image plus a conversation fit. Implementation - Message.images carries base64 data; messages_to_dicts() forwards it to Ollama's /api/chat "images" field. Text-only messages are unchanged. - GuardrailsEngine preserves images when it rewrites a flagged message. Tests (tests/test_vision.py, 6/6 pass, ruff-clean) - payload forwarding, text path untouched, num_ctx override, guardrail image preservation. Verified on AMD RX 9070 XT (Ollama/Vulkan, 100% GPU) with gemma3:4b: solid-color image, file image, and live screen capture all described. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What does this PR do?
Adds image input to
jarvis askso OpenJarvis can use vision-capable localmodels (e.g.
gemma3:4b) without giving up its local-first promise.-i/--image <file>— attach one or more images (repeatable).-S/--screen— capture the primary monitor and send it.Message.images(base64) →messages_to_dicts()→ Ollama/api/chatimages. Text-only requests are unchanged.--agentitwarns instead of silently dropping the image.
security guardrail preserves images when sanitizing a flagged prompt.
JARVIS_NUM_CTX(default16384) to size the Ollama context windowfor an image plus a conversation.
Closes #485.
How was this tested?
tests/test_vision.pycovering the data-flow contract:image forwarding to the serializer, text-only messages unaffected, the
guardrail preserving images through sanitization, and
JARVIS_NUM_CTXparsing (default + override + invalid-fallback). All pass locally.
gemma3:4b(both--imageand--screen), running 100% on-GPU.mss/Pillow) isimplemented but I have only verified the Windows
.NETpath on realhardware — a macOS/Linux check would be appreciated.
Checklist
tests/test_vision.pypasses locally; the full suiteruns on CI (my local venv lacks some optional engine test deps, e.g.
respx).uv run ruff check src/ tests/)ruff format --check). I left the78 unrelated pre-existing files alone — they differ only because of a ruff
version mismatch, not this change.
adds no new registry component.
docs/user-guide/cli.md(new "Vision Input"section + flag table) and
CHANGELOG.md.