Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ObjectBox VectorStore For LlamaIndex

About

This package contains the ObjectBox integrations for LlamaIndex

Getting Started

Install the llama-index-vector-stores-objectbox package from PyPI via pip.

pip install llama-index-vector-stores-objectbox

You can import the ObjectBox vector-store with from llama_index.vector_stores.objectbox import ObjectBoxVectorStore and start using it,

from llama_index.vector_stores.objectbox import ObjectBoxVectorStore
from objectbox import VectorDistanceType

embedding_dim = 384 # size of the embeddings to be stored

vector_store = ObjectBoxVectorStore(
    embedding_dim,
    distance_type=VectorDistanceType.COSINE,
    db_directory="obx_data",
    clear_db=False,
    do_log=True
)
  • embedding_dim (required): The dimensions of the embeddings that the vector DB will hold
  • distance_type: Choose from COSINE, DOT_PRODUCT, DOT_PRODUCT_NON_NORMALIZED and EUCLIDEAN
  • db_directory: The path of the directory where the .mdb ObjectBox database file should be created
  • clear_db: Deletes the existing database file if it exists on db_directory
  • do_log: Enables logging from the ObjectBox integration

A complete RAG example

Along the llama-index-vector-stores-objectbox, install the following packages,

pip install llama-index --quiet
pip install llama-index-embeddings-huggingface --quiet
pip install llama-index-llms-gemini --quiet

Download a sample text file,

mkdir -p 'data/paul_graham/'
wget 'https://raw.githubusercontent.com/run-llama/llama_index/main/docs/docs/examples/data/paul_graham/paul_graham_essay.txt' -O 'data/paul_graham/paul_graham_essay.txt'

This example will require a Gemini API key. You can get an API-key from the Gemini developer console. Execute the following Python script to generate an answer for Who is Paul Graham? from the text file,

from llama_index.llms.gemini import Gemini
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.vector_stores.objectbox import ObjectBoxVectorStore
from llama_index.core import StorageContext, VectorStoreIndex, Settings
from llama_index.core import SimpleDirectoryReader
from llama_index.core.node_parser import SentenceSplitter
from objectbox import VectorDistanceType
import getpass

gemini_key_api = getpass.getpass("Gemini API Key: ")
gemini_llm = Gemini(api_key=gemini_key_api)

# Configure embedding model from HuggingFace
hf_embedding = HuggingFaceEmbedding(model_name="BAAI/bge-base-en-v1.5")
embedding_dim = 384

# Setup file reader and text splitter
reader = SimpleDirectoryReader("./data/paul_graham")
documents = reader.load_data()

node_parser = SentenceSplitter(chunk_size=512, chunk_overlap=20)
nodes = node_parser.get_nodes_from_documents(documents)

# Configure ObjectBox as a vector-store
vector_store = ObjectBoxVectorStore(
    embedding_dim,
    distance_type=VectorDistanceType.COSINE,
    db_directory="obx_data",
    clear_db=False,
    do_log=True
)

storage_context = StorageContext.from_defaults(
    vector_store=vector_store
)

Settings.llm = gemini_llm
Settings.embed_model = hf_embedding

index = VectorStoreIndex(
    nodes=nodes,
    storage_context=storage_context
)

query_engine = index.as_query_engine()
response = query_engine.query("Who is Paul Graham?")
print(response)

License

MIT License

Copyright (c) 2024 ObjectBox, Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Metadata

Release files for llama-index-vector-stores-objectbox 0.1.0a0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-vector-stores-objectbox 0.1.0a0
File Size Uploaded Provenance
llama_index_vector_stores_objectbox-0.1.0a0.tar.gz 6.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-vector-stores-objectbox 0.1.0a0
File Interpreter ABI Platform
llama_index_vector_stores_objectbox-0.1.0a0-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / llama_index_vector_stores_objectbox-0.1.0a0.tar.gz

Download URL llama_index_vector_stores_objectbox-0.1.0a0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8c33cf0e854f37d35229ea19d774dfae1cef9bb09b00ca0c78908a1bb47f159f
BLAKE2b-256 checksum
How to use checksums
d6576f17b216fca5a858fb1bcc09bea92c98a75e373d4396776a5fa47b042ba1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.4 Windows/10

Release files / llama_index_vector_stores_objectbox-0.1.0a0-py3-none-any.whl

Download URL llama_index_vector_stores_objectbox-0.1.0a0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c221da2c63b6e4cb946f80f3412658ff4c6fa3e0dda41f80f2fa0e3243eaf26
BLAKE2b-256 checksum
How to use checksums
d111581a13f2b623f0ad80d4b37c553572845ef67ef699b0b1b810f351a7794d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.4 Windows/10

Security for llama-index-vector-stores-objectbox 0.1.0a0

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.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page