Tool plugin for zk-rag to generate images with stable diffusion 3.5 medium
Project description
zk-rag-image-generator
A plugin for zk-rag that enables image generation using Stable Diffusion 3.5 Medium model.
Description
This plugin provides a tool to generate images from textual descriptions using the Stable Diffusion 3.5 Medium model. It can be used to enhance your RAG (Retrieval-Augmented Generation) applications with image generation capabilities.
Features
- Generate images from textual descriptions
- Save generated images as PNG files
- Integration with mojentic LLM tools
- Comprehensive error handling
- Configurable through a gateway pattern
Installation
pip install zk-rag-image-generator
Usage
The plugin will be automatically discovered by zk-rag when installed. It provides the GenerateImage tool which can be used to create images from textual descriptions.
Example usage through zk-rag:
from zk_rag import get_tool
image_tool = get_tool("generate_image")
filename = image_tool.run(
image_description="A serene mountain landscape at sunset with snow-capped peaks and a clear lake reflecting the orange sky",
base_filename="mountain_sunset"
)
print(f"Image saved as: {filename}") # Will print: Image saved as: mountain_sunset.png
Requirements
- Python >= 3.11
- mojentic (LLM tools framework)
- torch, torchvision, torchaudio (PyTorch stack)
- diffusers (Stable Diffusion implementation)
- transformers (Hugging Face Transformers)
- accelerate (Hardware acceleration support)
- safetensors (Model weight handling)
- Additional dependencies: scipy, protobuf, sentencepiece
For the complete list with specific versions, see requirements.txt.
Local Development
- Clone the repository
- Install dependencies:
pip install -r requirements.txt pip install -r dev-requirements.txt
- Install pre-commit hooks (recommended):
# Create a pre-commit hook that runs pytest cat > .git/hooks/pre-commit << 'EOL' #!/bin/sh # Run pytest echo "Running pytest..." python -m pytest # Store the exit code exit_code=$? # Exit with pytest's exit code exit $exit_code EOL # Make the hook executable chmod +x .git/hooks/pre-commit
Testing Guidelines
- Tests are co-located with implementation files
- Run tests:
pytest - Linting:
flake8 src - Code style:
- Max line length: 127
- Max complexity: 10
- Follow numpy docstring style
Testing Best Practices
- Use pytest for testing, with mocker if you require mocking
- Do not use unittest or MagicMock directly
- Use @fixture markers for pytest fixtures
- Break up fixtures into smaller fixtures if they are too large
- Separate test phases with a single blank line
- Each test must fail for only one clear reason
- Only write mocks for our own gateway classes
License
MIT License
Author
Stacey Vetzal (stacey@vetzal.com)
Project details
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 zk_rag_image_generator-1.0.3.tar.gz.
File metadata
- Download URL: zk_rag_image_generator-1.0.3.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a05a8501a76a199221325dc1f4f73013e6e290fe29f17e6e366b17fbacf10623
|
|
| MD5 |
344e766ace491d100f501b435eaa5154
|
|
| BLAKE2b-256 |
1c9703c9d26573c754201c795ffa8c1b651be89902ee4c930b83bfbc1e15f61b
|
Provenance
The following attestation bundles were made for zk_rag_image_generator-1.0.3.tar.gz:
Publisher:
python-publish.yml on svetzal/zk-rag-image-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zk_rag_image_generator-1.0.3.tar.gz -
Subject digest:
a05a8501a76a199221325dc1f4f73013e6e290fe29f17e6e366b17fbacf10623 - Sigstore transparency entry: 179469965
- Sigstore integration time:
-
Permalink:
svetzal/zk-rag-image-generator@835b56947226a07bd0272f4334b0cb97492fb70d -
Branch / Tag:
refs/tags/RELEASE-1.0.3 - Owner: https://github.com/svetzal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@835b56947226a07bd0272f4334b0cb97492fb70d -
Trigger Event:
release
-
Statement type:
File details
Details for the file zk_rag_image_generator-1.0.3-py3-none-any.whl.
File metadata
- Download URL: zk_rag_image_generator-1.0.3-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40030fa59c4ef04681cbc102096a3bc561d892429a0c94081aff425b6ba59730
|
|
| MD5 |
7e07309521f26354404478337fa45e64
|
|
| BLAKE2b-256 |
895cdecb1156726d927c6ed24cbdb8050274230b5cfed6ca178c999a316e5b28
|
Provenance
The following attestation bundles were made for zk_rag_image_generator-1.0.3-py3-none-any.whl:
Publisher:
python-publish.yml on svetzal/zk-rag-image-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zk_rag_image_generator-1.0.3-py3-none-any.whl -
Subject digest:
40030fa59c4ef04681cbc102096a3bc561d892429a0c94081aff425b6ba59730 - Sigstore transparency entry: 179469966
- Sigstore integration time:
-
Permalink:
svetzal/zk-rag-image-generator@835b56947226a07bd0272f4334b0cb97492fb70d -
Branch / Tag:
refs/tags/RELEASE-1.0.3 - Owner: https://github.com/svetzal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@835b56947226a07bd0272f4334b0cb97492fb70d -
Trigger Event:
release
-
Statement type: