awvision
Ask questions about images using a vision-capable model.
What it does
awvision is a lightweight client for vision-capable, OpenAI-compatible LLM services. Send an image and a question, get an answer.
The contract: Ask a question about an image and get an answer.
Installation
pip install -e .
Or with dev dependencies:
pip install -e ".[dev]"
Usage
Ask a question about an image
awvision ask image.png "What is in this image?"
Describe an image
awvision describe image.jpg
Compare two images
awvision compare image1.png image2.png
Configuration
Set environment variables to customize the endpoint and model:
export AWVISION_URL=http://localhost:8150
export AWVISION_MODEL=gpt-4-vision
Or pass them as options:
awvision --endpoint http://localhost:8150 --model gpt-4-vision ask image.png "What's this?"
Self-test
Run the self-tests to verify awvision is working correctly:
awvision --self-test
This will:
- Test image loading and encoding
- Verify media type detection
- Check endpoint configuration
- Validate error handling
Requirements
- Python 3.10+
- A vision-capable LLM service (e.g., OpenAI-compatible API)
- The service must support the
image_urlcontent block format
How it works
awvision:
- Loads the image file and encodes it as base64
- Wraps it in an OpenAI-compatible chat message with
image_urlformat - Sends it to the configured vision service
- Returns the model's response
Important: Empty response detection
If a text-only model receives an image, it typically returns HTTP 200 with an empty response. awvision detects this and raises a clear error:
ERROR: Model 'gpt-4-vision' at http://localhost:8150 returned empty content.
This indicates the model does not support vision or cannot process image_url content blocks.
Verify that:
1. The model 'gpt-4-vision' is vision-capable
2. The endpoint supports the image_url format
3. The image was properly encoded as a data URL
This prevents silent failures where an empty response looks like a successful query.
API
For programmatic use:
from awvision import ask_vision, describe_image, compare_images
# Ask a question
answer = ask_vision("image.png", "What color is this?")
print(answer)
# Describe an image
description = describe_image("image.jpg")
print(description)
# Compare two images
comparison = compare_images("image1.png", "image2.png")
print(comparison)
Error handling
awvision provides clear error messages for common issues:
- FileNotFoundError: Image file not found
- IOError: Image file is empty or unreadable
- RuntimeError: Vision service is unavailable, model has no vision, or response is empty
All error messages include guidance on what to check.
Testing
Run the test suite:
pytest tests/ -v
Supported image formats
- PNG (image/png)
- JPEG (image/jpeg)
- GIF (image/gif)
- WebP (image/webp)
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file awvision-0.1.0.tar.gz.
File metadata
- Download URL: awvision-0.1.0.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72c3177ec98331e66ab3f3158aa8613c0dc8987ea4a410fd8b7f3ae7422b017b
|
|
| MD5 |
3e30fb191d8d51c02f9a3ec28a553b56
|
|
| BLAKE2b-256 |
5b9b39b7d509b5523ab5a7693d804be3d26743aac42b54178ef1aa4187061e58
|
File details
Details for the file awvision-0.1.0-py3-none-any.whl.
File metadata
- Download URL: awvision-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dbb88bdcc3b1512fd646c48a3aef84e1d42a77dbc4c7eca6243d1d1ca0c5e18
|
|
| MD5 |
c235c63d526dcb2ace72da0153248718
|
|
| BLAKE2b-256 |
5c2263a774ea3e5d4ff9a7618d9217a286b84d5158a054901abc67fbff4ca038
|