LangChain integration for ViscribeAI image analysis - AI-powered tools for image understanding
Project description
langchain-viscribe
AI-powered image analysis tools for LangChain. Seamlessly integrate ViscribeAI's image understanding capabilities into your LangChain agents.
Installation
pip install langchain-viscribe
For the agent example below you also need:
pip install langchain langchain-openai
export OPENAI_API_KEY="your-openai-key"
First example: agent comparing a URL image and a local image
Minimal script using LangChain’s create_agent with CompareImagesTool to compare an image from a URL and a local file:
from dotenv import load_dotenv
from langchain.agents import create_agent
from langchain_core.messages import HumanMessage
from langchain_openai import ChatOpenAI
from langchain_viscribe.tools import CompareImagesTool
load_dotenv()
tools = [CompareImagesTool()]
llm = ChatOpenAI(temperature=0, model="gpt-4o-mini")
agent = create_agent(
llm,
tools=tools,
system_prompt="You compare images. Use the CompareImages tool when the user asks to compare two images.",
)
result = agent.invoke({
"messages": [
HumanMessage(content=(
"Compare the image at https://example.com/photo.jpg with the local image at /path/to/my/image.png "
"and describe similarities and differences."
))
]
})
# Final answer is the last AI message
print(result["messages"][-1].content)
Replace the URL and /path/to/my/image.png with your image URL and local file path. The tool accepts image1_url / image2_url, image1_base64 / image2_base64, or image1_path / image2_path.
Quick Start
from langchain_viscribe.tools import DescribeImageTool
tool = DescribeImageTool()
# From URL
result = tool.invoke({
"image_url": "https://example.com/image.jpg",
"generate_tags": True
})
# From local file (read and sent as base64)
result = tool.invoke({
"image_path": "/path/to/your/image.png",
"generate_tags": True
})
print(result["image_description"])
print(result["tags"])
Configuration
Option 1: Using .env file (Recommended)
Create a .env file in your project root:
cp .env.example .env
Then add your API key to .env:
VISCRIBE_API_KEY=vscrb-your-api-key-here
The tools will automatically load the environment variables from .env.
Option 2: Export environment variable
export VISCRIBE_API_KEY="vscrb-your-api-key-here"
Option 3: Pass directly to tools
tool = DescribeImageTool(api_key="vscrb-your-api-key-here")
Available Tools
DescribeImageTool
Generate natural language descriptions and tags for images.
ExtractImageTool
Extract structured data from images (receipts, forms, documents).
ClassifyImageTool
Classify images into predefined categories (single or multi-label).
AskImageTool
Visual Question Answering - ask questions about images.
CompareImagesTool
Compare two images and describe similarities and differences.
GetCreditsTool
Check your remaining API credits.
SubmitFeedbackTool
Submit feedback on API responses to improve quality.
Examples
Example scripts are in the examples/ directory.
Individual tools
| Script | Description |
|---|---|
| describe_image_example.py | Describe images and get tags (URL input) |
| local_image_example.py | Use tools with a local image file (image_path); uses examples/cat.png |
Run: python examples/describe_image_example.py or python examples/local_image_example.py
Agent integration
For agent examples, install the LangChain stack and set OPENAI_API_KEY:
pip install langchain langchain-openai
export OPENAI_API_KEY="your-openai-key"
| Script | Description |
|---|---|
| agent_example.py | Agent with create_agent and image tools (image URLs) |
| agent_local_image_example.py | Same agent using a local image (examples/cat.png) via image_path |
Run: python examples/agent_example.py or python examples/agent_local_image_example.py
Agent examples use the current LangChain Agents API (create_agent, message-based state).
Documentation
For comprehensive documentation, visit https://docs.viscribe.ai
License
MIT License - see LICENSE file for details.
Support
- Issues: https://github.com/viscribeai/langchain-viscribe/issues
- Documentation: https://docs.viscribe.ai
- Website: https://viscribe.ai
Project details
Release history Release notifications | RSS feed
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 langchain_viscribe-0.1.0.tar.gz.
File metadata
- Download URL: langchain_viscribe-0.1.0.tar.gz
- Upload date:
- Size: 1.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50441341becdbf18fecbdd267b7051e01d1c1a4af97e29fbd731ca53ecbabef4
|
|
| MD5 |
52297bd2fe1b76220e718fa786687ba5
|
|
| BLAKE2b-256 |
617662a8183be24ffcbb3b54389cc98f9dc70680df5a7cc61fac3fe6cfe28a09
|
File details
Details for the file langchain_viscribe-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_viscribe-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a7b797269e8bd62a1948b16995509b053370a998196349e0f176540a11072b3
|
|
| MD5 |
c016aec0a90bcf3058c1de914c5bc59c
|
|
| BLAKE2b-256 |
9ca8c4672b685221748dae5c2bef87c81eaab29fce17d08064b3d2f6d7ce5f48
|