Skip to main content

vector-database-loader

Loading content info a vector database is relatively easy to do, especially with frameworks like LangChain. However, the process of curating the content and loading it into the database can be a bit more complex. If you are building a RAG application or similar, the quality and relevance of the content is critical. This project is meant to help with that process.

A use case for this type of project is discussed in more depth in the blog A Cost-Effective AI Chatbot Architecture with AWS Bedrock, Lambda, and Pinecone

Features

  • Vector Database Support - The framework is built to support multiple vector databases but is currently implementing support for Pinecone. More vector databases will be added, but if needed you can fork the project and handle your own needs by extending the base class.
  • Embedding Support - You can use any embedding provided by Langchain, which includes OpenAI, AWS Bedrock, HuggingFace, Cohere and much, much more.
  • Content Curation - The framework is built configure some common content types and sources, but again is meant to be extended a needed.
    • Sources include websites, local folders and google drive
    • Types include PDF, Word, and Web content and google docs
  • Text Splitter - This framework uses the RecursiveCharacterTextSplitter from LangChain.
    This is a powerful tool that can split text into chunks of a specified size, while maintaining the context of the text. This is especially useful for long documents like web pages or PDFs.

Example

Install the package with pip:

Note: The dependencies are kind of beefy!

pip install vector-database-loader

Configuration details:

Add your Pinecone API and OpenAI keys to your .env file, see sample.env for an examples.

Code

import time

from dotenv import load_dotenv, find_dotenv
from langchain_openai import OpenAIEmbeddings

from vector_database_loader.pinecone_vector_db import PineconeVectorLoader, PineconeVectorQuery

# Define your content sources and add them to the array
web_page_content_source = {"name": "SpaceX", "type": "Website", "items": [
    "https://en.wikipedia.org/wiki/SpaceX"

], "chunk_size": 512}
content_sources = [web_page_content_source]

# Load into your vector database.  Be sure to add your Pinecone and OpenAI API keys to your .env file
load_dotenv(find_dotenv())
embedding_client = OpenAIEmbeddings()
index_name = "my-vectordb-index"
vector_db_loader = PineconeVectorLoader(index_name=index_name,
                                        embedding_client=embedding_client)
vector_db_loader.load_sources(content_sources, delete_index=True)

# Query your vector database
print("Waiting 30 seconds before running the query, to make sure the data is available")
time.sleep(30)  # This is needed because there is a latency in the data being available
vector_db_query = PineconeVectorQuery(index_name=index_name,
                                      embedding_client=embedding_client)
query = "What is SpaceX's most recent rocket model being tested?"
documents = vector_db_query.query(query)
print(f"Query: {query} returned {len(documents)} results")
for doc in documents:
    print(f"   {doc.metadata['title']}")
    print(f"   {doc.page_content}")

Metadata

Release files for vector-database-loader 0.2.2

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

Source distribution (sdist)

Source distribution for vector-database-loader 0.2.2
File Size Uploaded
vector_database_loader-0.2.2.tar.gz 13.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vector-database-loader 0.2.2
File Interpreter ABI Platform
vector_database_loader-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 28.2 kB

Release files / vector_database_loader-0.2.2.tar.gz

Download URL vector_database_loader-0.2.2.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
53894ad9a79a5b58c907a660a16a8a76bb2c5faa63c96cdd0a61e9e80ab99f6c
BLAKE2b-256 checksum
How to use checksums
310d4e9bc9605128265856eba996909fb92f2d0ddc3051bae866fe387cd9cac8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.6 Darwin/24.4.0

Release files / vector_database_loader-0.2.2-py3-none-any.whl

Download URL vector_database_loader-0.2.2-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20d2f1cec7ce62508a08a52a55e23e40c6cad7836d33f568516a9a3aba1cb6c2
BLAKE2b-256 checksum
How to use checksums
745aef882c5859f9bd8efa085c334ca9d6c225427e896b9ac644a76390d02ddc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.6 Darwin/24.4.0

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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