Vectra offers a unified Ruby client for vector databases, allowing developers to write once and easily switch between providers without hassle. Whether using Pinecone, Qdrant, Weaviate, or pgvector, Vectra simplifies integration with each through a consistent interface, enabling smooth transitions and efficient data management.
Vectra is an advanced, unified Ruby client designed to facilitate seamless interactions with various vector databases. This library allows for a single codebase, enabling developers to effortlessly switch between different database providers with minimal changes.
Key Features
- Provider Agnostic: Easily shift between different vector database providers with just a single line of code change.
- Production Ready: Compatible with Ruby 3.2+ and boasts over 95% test coverage to ensure reliability.
- Resilient: Implements retry logic with exponential backoff to handle transient errors effectively.
- Observable: Comes with built-in instrumentation for Datadog and New Relic, aiding in performance monitoring and troubleshooting.
- Rails Ready: Integrates smoothly with Ruby on Rails, offering ActiveRecord support through a simple and intuitive DSL.
Supported Providers
Vectra currently supports the following vector database providers:
| Provider | Type | Status |
|---|---|---|
| Pinecone | Managed Cloud | ✅ Supported |
| Qdrant | Open Source | ✅ Supported |
| Weaviate | Open Source | ✅ Supported |
| pgvector | PostgreSQL | ✅ Supported |
Quick Start
To use Vectra, simply initialize the client with the desired provider and API key:
require 'vectra'
client = Vectra::Client.new(
provider: :pinecone,
api_key: ENV['PINECONE_API_KEY'],
environment: 'us-west-4'
)
You can then perform operations like inserting, querying, and deleting vectors:
# Upsert vectors
client.upsert(
vectors: [
{ id: 'doc-1', values: [0.1, 0.2, 0.3], metadata: { title: 'Hello' } },
{ id: 'doc-2', values: [0.4, 0.5, 0.6], metadata: { title: 'World' } }
]
)
# Search vectors
results = client.query(vector: [0.1, 0.2, 0.3], top_k: 5)
results.each { |match| puts "#{match.id}: #{match.score}" }
# Delete vectors
client.delete(ids: ['doc-1', 'doc-2'])
Rails Integration
For Ruby on Rails applications, integrate with ActiveRecord for easy embedding management:
class Document < ApplicationRecord
include Vectra::ActiveRecord
has_vector :embedding,
provider: :qdrant,
index: 'documents',
dimension: 1536
end
# Auto-indexing on save
Document.create!(title: 'Hello', embedding: [0.1, 0.2, ...])
# Vector search
Document.vector_search(embedding: query_vector, limit: 10)
For comprehensive documentation, refer to the official documentation site. Vectra streamlines interaction with vector databases, enhancing productivity and maintaining flexibility in application development.
No comments yet.
Sign in to be the first to comment.