LlamaIndex Multi_Modal Integration: Nvidia
This project integrates Nvidia vlm into the LlamaIndex framework, enabling advanced multimodal capabilities for various AI applications.
Features
- Seamless integration of NVIDIA vlm with LlamaIndex
- Support for multiple state-of-the-art vision-language models:
- Easy-to-use interface for multimodal tasks like image captioning and visual question answering
- Configurable model parameters for fine-tuned performance
Installation
pip install llama-index-multi-modal-llms-nvidia
Make sure to set your NVIDIA API key as an environment variable:
export NVIDIA_API_KEY=your_api_key_here
Usage
Here's a basic example of how to use the Nvidia vlm integration:
from llama_index.multi_modal_llms.nvidia import NVIDIAMultiModal
from llama_index.core.schema import ImageDocument
# Initialize the model
model = NVIDIAMultiModal()
# Prepare your image and prompt
image_document = ImageDocument(image_path="path/to/your/image.jpg")
prompt = "Describe this image in detail."
# Generate a response
response = model.complete(prompt, image_documents=[image_document])
print(response.text)
Streaming
from llama_index.multi_modal_llms.nvidia import NVIDIAMultiModal
from llama_index.core.schema import ImageDocument
# Initialize the model
model = NVIDIAMultiModal()
# Prepare your image and prompt
image_document = ImageDocument(image_path="downloaded_image.jpg")
prompt = "Describe this image in detail."
import nest_asyncio
import asyncio
nest_asyncio.apply()
response = model.stream_complete(
prompt=f"Describe the image",
image_documents=[
ImageDocument(metadata={"asset_id": asset_id}, mimetype="png")
],
)
for r in response:
print(r.text, end="")
Passing an image as an NVCF asset
If your image is sufficiently large or you will pass it multiple times in a chat conversation, you may upload it once and reference it in your chat conversation
See https://docs.nvidia.com/cloud-functions/user-guide/latest/cloud-function/assets.html for details about how upload the image.
import requests
content_type = "image/jpg"
description = "example-image-from-lc-nv-ai-e-notebook"
create_response = requests.post(
"https://api.nvcf.nvidia.com/v2/nvcf/assets",
headers={
"Authorization": f"Bearer {os.environ['NVIDIA_API_KEY']}",
"accept": "application/json",
"Content-Type": "application/json",
},
json={"contentType": content_type, "description": description},
)
create_response.raise_for_status()
upload_response = requests.put(
create_response.json()["uploadUrl"],
headers={
"Content-Type": content_type,
"x-amz-meta-nvcf-asset-description": description,
},
data=img_response.content,
)
upload_response.raise_for_status()
asset_id = create_response.json()["assetId"]
response = llm.complete(
prompt=f"Describe the image",
image_documents=[
ImageDocument(metadata={"asset_id": asset_id}, mimetype="png")
],
)
Metadata
Release files for llama-index-multi-modal-llms-nvidia 0.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llama_index_multi_modal_llms_nvidia-0.5.2.tar.gz | 10.9 kB | Without provenance | Details for llama_index_multi_modal_llms_nvidia-0.5.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_multi_modal_llms_nvidia-0.5.2-py3-none-any.whl | Python 3 | none | any | Details for llama_index_multi_modal_llms_nvidia-0.5.2-py3-none-any.whl |
Total release size: 22.2 kB
Release files / llama_index_multi_modal_llms_nvidia-0.5.2.tar.gz
| Download URL | llama_index_multi_modal_llms_nvidia-0.5.2.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
892c089aef14d1e5a969ba54081047fc97a2de47118c8146a37e05437c924cd5
|
|
BLAKE2b-256 checksum How to use checksums |
b4d2e7c5b434e6a069c3a34d5089ea6aa9e890dcb6744cd0dfd71a72d4693c9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Release files / llama_index_multi_modal_llms_nvidia-0.5.2-py3-none-any.whl
| Download URL | llama_index_multi_modal_llms_nvidia-0.5.2-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6c64a27ab52a58a41f15589438a979a45d6e057455f06126aff014ca271eb5f
|
|
BLAKE2b-256 checksum How to use checksums |
a78017d151f797f16295aac0ba396d4b525d552badf8b18cbacd7aab0e9c1956
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Security for llama-index-multi-modal-llms-nvidia 0.5.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.