vectra-client 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -14
- data/README.md +140 -328
- data/Rakefile +1 -1
- data/docs/Gemfile +10 -0
- data/docs/_config.yml +20 -0
- data/docs/_layouts/default.html +14 -0
- data/docs/_layouts/home.html +33 -0
- data/docs/_layouts/page.html +20 -0
- data/docs/_site/api/overview/index.html +145 -0
- data/docs/_site/assets/main.css +649 -0
- data/docs/_site/assets/main.css.map +1 -0
- data/docs/_site/assets/minima-social-icons.svg +33 -0
- data/docs/_site/assets/style.css +295 -0
- data/docs/_site/community/contributing/index.html +110 -0
- data/docs/_site/examples/basic-usage/index.html +117 -0
- data/docs/_site/examples/index.html +58 -0
- data/docs/_site/feed.xml +1 -0
- data/docs/_site/guides/getting-started/index.html +106 -0
- data/docs/_site/guides/installation/index.html +82 -0
- data/docs/_site/index.html +92 -0
- data/docs/_site/providers/index.html +119 -0
- data/docs/_site/providers/pgvector/index.html +155 -0
- data/docs/_site/providers/pinecone/index.html +121 -0
- data/docs/_site/providers/qdrant/index.html +124 -0
- data/docs/_site/providers/weaviate/index.html +123 -0
- data/docs/_site/robots.txt +1 -0
- data/docs/_site/sitemap.xml +39 -0
- data/docs/api/overview.md +126 -0
- data/docs/assets/style.css +295 -0
- data/docs/community/contributing.md +89 -0
- data/docs/examples/basic-usage.md +102 -0
- data/docs/examples/index.md +32 -0
- data/docs/guides/getting-started.md +90 -0
- data/docs/guides/installation.md +67 -0
- data/docs/index.md +53 -0
- data/docs/providers/index.md +62 -0
- data/docs/providers/pgvector.md +95 -0
- data/docs/providers/pinecone.md +72 -0
- data/docs/providers/qdrant.md +73 -0
- data/docs/providers/weaviate.md +72 -0
- data/lib/vectra/configuration.rb +10 -1
- data/lib/vectra/providers/base.rb +10 -0
- data/lib/vectra/providers/qdrant.rb +399 -12
- data/lib/vectra/version.rb +1 -1
- data/lib/vectra.rb +9 -2
- data/netlify.toml +12 -0
- metadata +43 -9
- data/IMPLEMENTATION_GUIDE.md +0 -686
- data/NEW_FEATURES_v0.2.0.md +0 -459
- data/RELEASE_CHECKLIST_v0.2.0.md +0 -383
- data/USAGE_EXAMPLES.md +0 -787
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Providers
|
|
4
|
+
permalink: /providers/
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Vector Database Providers
|
|
8
|
+
|
|
9
|
+
Vectra supports multiple vector database providers. Choose the one that best fits your needs:
|
|
10
|
+
|
|
11
|
+
## Supported Providers
|
|
12
|
+
|
|
13
|
+
| Provider | Type | Best For | Documentation |
|
|
14
|
+
|----------|------|----------|---|
|
|
15
|
+
| **Pinecone** | Managed Cloud | Production, Fully managed | [Guide]({{ site.baseurl }}/providers/pinecone) |
|
|
16
|
+
| **Qdrant** | Open Source | Self-hosted, High performance | [Guide]({{ site.baseurl }}/providers/qdrant) |
|
|
17
|
+
| **Weaviate** | Open Source | Semantic search, GraphQL | [Guide]({{ site.baseurl }}/providers/weaviate) |
|
|
18
|
+
| **PostgreSQL + pgvector** | SQL Database | SQL integration, ACID | [Guide]({{ site.baseurl }}/providers/pgvector) |
|
|
19
|
+
|
|
20
|
+
## Quick Comparison
|
|
21
|
+
|
|
22
|
+
### Pinecone
|
|
23
|
+
- ✅ Fully managed service
|
|
24
|
+
- ✅ Easy setup
|
|
25
|
+
- ✅ Scalable
|
|
26
|
+
- ❌ Cloud only
|
|
27
|
+
- ❌ Paid service
|
|
28
|
+
|
|
29
|
+
### Qdrant
|
|
30
|
+
- ✅ Open source
|
|
31
|
+
- ✅ Self-hosted
|
|
32
|
+
- ✅ High performance
|
|
33
|
+
- ✅ Multiple deployment options
|
|
34
|
+
- ❌ More configuration needed
|
|
35
|
+
|
|
36
|
+
### Weaviate
|
|
37
|
+
- ✅ Open source
|
|
38
|
+
- ✅ Semantic search
|
|
39
|
+
- ✅ GraphQL API
|
|
40
|
+
- ✅ Multi-model support
|
|
41
|
+
- ❌ More complex
|
|
42
|
+
|
|
43
|
+
### PostgreSQL + pgvector
|
|
44
|
+
- ✅ SQL database
|
|
45
|
+
- ✅ ACID transactions
|
|
46
|
+
- ✅ Existing infrastructure
|
|
47
|
+
- ✅ Affordable
|
|
48
|
+
- ❌ Not specialized for vectors
|
|
49
|
+
|
|
50
|
+
## Switching Providers
|
|
51
|
+
|
|
52
|
+
One of Vectra's key features is easy provider switching:
|
|
53
|
+
|
|
54
|
+
```ruby
|
|
55
|
+
# All it takes is changing one line!
|
|
56
|
+
client = Vectra::Client.new(provider: :qdrant)
|
|
57
|
+
|
|
58
|
+
# All your code remains the same
|
|
59
|
+
results = client.query(vector: [0.1, 0.2, 0.3])
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
See the [Getting Started Guide]({{ site.baseurl }}/guides/getting-started) for more information.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: PostgreSQL with pgvector
|
|
4
|
+
permalink: /providers/pgvector/
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PostgreSQL with pgvector Provider
|
|
8
|
+
|
|
9
|
+
[pgvector](https://github.com/pgvector/pgvector) is a PostgreSQL extension for vector data.
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
### Prerequisites
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Install PostgreSQL with pgvector extension
|
|
17
|
+
# macOS with Homebrew
|
|
18
|
+
brew install postgresql
|
|
19
|
+
|
|
20
|
+
# Enable pgvector extension
|
|
21
|
+
psql -d your_database -c "CREATE EXTENSION IF NOT EXISTS vector;"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Connect with Vectra
|
|
25
|
+
|
|
26
|
+
```ruby
|
|
27
|
+
client = Vectra::Client.new(
|
|
28
|
+
provider: :pgvector,
|
|
29
|
+
database: 'my_database',
|
|
30
|
+
host: 'localhost',
|
|
31
|
+
port: 5432,
|
|
32
|
+
user: 'postgres',
|
|
33
|
+
password: ENV['DB_PASSWORD']
|
|
34
|
+
)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
- ✅ Upsert vectors
|
|
40
|
+
- ✅ Query/search
|
|
41
|
+
- ✅ Delete vectors
|
|
42
|
+
- ✅ SQL integration
|
|
43
|
+
- ✅ ACID transactions
|
|
44
|
+
- ✅ Complex queries
|
|
45
|
+
- ✅ Rails ActiveRecord integration
|
|
46
|
+
|
|
47
|
+
## Example
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
# Initialize client
|
|
51
|
+
client = Vectra::Client.new(
|
|
52
|
+
provider: :pgvector,
|
|
53
|
+
database: 'vectors_db',
|
|
54
|
+
host: 'localhost'
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Upsert vectors
|
|
58
|
+
client.upsert(
|
|
59
|
+
vectors: [
|
|
60
|
+
{ id: 'doc-1', values: [0.1, 0.2, 0.3], metadata: { title: 'Doc 1' } }
|
|
61
|
+
]
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# Search using cosine distance
|
|
65
|
+
results = client.query(vector: [0.1, 0.2, 0.3], top_k: 5)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## ActiveRecord Integration
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
class Document < ApplicationRecord
|
|
72
|
+
include Vectra::ActiveRecord
|
|
73
|
+
|
|
74
|
+
vector_search :embedding_vector
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Search
|
|
78
|
+
docs = Document.vector_search([0.1, 0.2, 0.3], limit: 10)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Configuration Options
|
|
82
|
+
|
|
83
|
+
| Option | Type | Required | Description |
|
|
84
|
+
|--------|------|----------|-------------|
|
|
85
|
+
| `database` | String | Yes | Database name |
|
|
86
|
+
| `host` | String | Yes | PostgreSQL host |
|
|
87
|
+
| `port` | Integer | No | PostgreSQL port (default: 5432) |
|
|
88
|
+
| `user` | String | No | Database user |
|
|
89
|
+
| `password` | String | No | Database password |
|
|
90
|
+
| `schema` | String | No | Database schema |
|
|
91
|
+
|
|
92
|
+
## Documentation
|
|
93
|
+
|
|
94
|
+
- [pgvector GitHub](https://github.com/pgvector/pgvector)
|
|
95
|
+
- [pgvector Docs](https://github.com/pgvector/pgvector#readme)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Pinecone
|
|
4
|
+
permalink: /providers/pinecone/
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pinecone Provider
|
|
8
|
+
|
|
9
|
+
[Pinecone](https://www.pinecone.io/) is a managed vector database in the cloud.
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
1. Create a Pinecone account at https://www.pinecone.io/
|
|
14
|
+
2. Create an index and get your API key
|
|
15
|
+
3. Set up Vectra:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
client = Vectra::Client.new(
|
|
19
|
+
provider: :pinecone,
|
|
20
|
+
api_key: ENV['PINECONE_API_KEY'],
|
|
21
|
+
index_name: 'my-index',
|
|
22
|
+
environment: 'us-west-4'
|
|
23
|
+
)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- ✅ Upsert vectors
|
|
29
|
+
- ✅ Query/search
|
|
30
|
+
- ✅ Delete vectors
|
|
31
|
+
- ✅ Fetch vectors by ID
|
|
32
|
+
- ✅ Index statistics
|
|
33
|
+
- ✅ Metadata filtering
|
|
34
|
+
- ✅ Namespace support
|
|
35
|
+
|
|
36
|
+
## Example
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
# Initialize client
|
|
40
|
+
client = Vectra::Client.new(
|
|
41
|
+
provider: :pinecone,
|
|
42
|
+
api_key: ENV['PINECONE_API_KEY'],
|
|
43
|
+
environment: 'us-west-4'
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
# Upsert vectors
|
|
47
|
+
client.upsert(
|
|
48
|
+
vectors: [
|
|
49
|
+
{ id: 'doc-1', values: [0.1, 0.2, 0.3], metadata: { title: 'Page 1' } },
|
|
50
|
+
{ id: 'doc-2', values: [0.2, 0.3, 0.4], metadata: { title: 'Page 2' } }
|
|
51
|
+
]
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
# Search
|
|
55
|
+
results = client.query(vector: [0.1, 0.2, 0.3], top_k: 5)
|
|
56
|
+
results.matches.each do |match|
|
|
57
|
+
puts "#{match['id']}: #{match['score']}"
|
|
58
|
+
end
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Configuration Options
|
|
62
|
+
|
|
63
|
+
| Option | Type | Required | Description |
|
|
64
|
+
|--------|------|----------|-------------|
|
|
65
|
+
| `api_key` | String | Yes | Your Pinecone API key |
|
|
66
|
+
| `environment` | String | Yes | Pinecone environment (e.g., 'us-west-4') |
|
|
67
|
+
| `index_name` | String | No | Index name (if not set globally) |
|
|
68
|
+
|
|
69
|
+
## Documentation
|
|
70
|
+
|
|
71
|
+
- [Pinecone Docs](https://docs.pinecone.io/)
|
|
72
|
+
- [Pinecone API Reference](https://docs.pinecone.io/reference/api/)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Qdrant
|
|
4
|
+
permalink: /providers/qdrant/
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Qdrant Provider
|
|
8
|
+
|
|
9
|
+
[Qdrant](https://qdrant.tech/) is an open-source vector search engine.
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
### Local Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
docker run -p 6333:6333 qdrant/qdrant
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Connect with Vectra
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
client = Vectra::Client.new(
|
|
23
|
+
provider: :qdrant,
|
|
24
|
+
host: 'localhost',
|
|
25
|
+
port: 6333,
|
|
26
|
+
collection_name: 'my-collection'
|
|
27
|
+
)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- ✅ Upsert vectors
|
|
33
|
+
- ✅ Query/search
|
|
34
|
+
- ✅ Delete vectors
|
|
35
|
+
- ✅ Fetch vectors by ID
|
|
36
|
+
- ✅ Collection management
|
|
37
|
+
- ✅ Metadata filtering
|
|
38
|
+
- ✅ Hybrid search
|
|
39
|
+
|
|
40
|
+
## Example
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
# Initialize client
|
|
44
|
+
client = Vectra::Client.new(
|
|
45
|
+
provider: :qdrant,
|
|
46
|
+
host: 'localhost',
|
|
47
|
+
port: 6333
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
# Upsert vectors
|
|
51
|
+
client.upsert(
|
|
52
|
+
vectors: [
|
|
53
|
+
{ id: 'doc-1', values: [0.1, 0.2, 0.3], metadata: { source: 'web' } }
|
|
54
|
+
]
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Search
|
|
58
|
+
results = client.query(vector: [0.1, 0.2, 0.3], top_k: 10)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Configuration Options
|
|
62
|
+
|
|
63
|
+
| Option | Type | Required | Description |
|
|
64
|
+
|--------|------|----------|-------------|
|
|
65
|
+
| `host` | String | Yes | Qdrant host address |
|
|
66
|
+
| `port` | Integer | Yes | Qdrant port (default: 6333) |
|
|
67
|
+
| `collection_name` | String | No | Collection name |
|
|
68
|
+
| `api_key` | String | No | API key if auth is enabled |
|
|
69
|
+
|
|
70
|
+
## Documentation
|
|
71
|
+
|
|
72
|
+
- [Qdrant Docs](https://qdrant.tech/documentation/)
|
|
73
|
+
- [Qdrant API Reference](https://api.qdrant.tech/)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Weaviate
|
|
4
|
+
permalink: /providers/weaviate/
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Weaviate Provider
|
|
8
|
+
|
|
9
|
+
[Weaviate](https://weaviate.io/) is an open-source vector search engine with semantic search capabilities.
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
### Local Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
docker run -p 8080:8080 semitechnologies/weaviate:latest
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Connect with Vectra
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
client = Vectra::Client.new(
|
|
23
|
+
provider: :weaviate,
|
|
24
|
+
host: 'localhost',
|
|
25
|
+
port: 8080,
|
|
26
|
+
class_name: 'Document'
|
|
27
|
+
)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- ✅ Upsert vectors
|
|
33
|
+
- ✅ Query/search
|
|
34
|
+
- ✅ Delete vectors
|
|
35
|
+
- ✅ Class management
|
|
36
|
+
- ✅ Metadata filtering
|
|
37
|
+
- ✅ Semantic search
|
|
38
|
+
|
|
39
|
+
## Example
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
# Initialize client
|
|
43
|
+
client = Vectra::Client.new(
|
|
44
|
+
provider: :weaviate,
|
|
45
|
+
host: 'localhost',
|
|
46
|
+
port: 8080
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
# Upsert vectors
|
|
50
|
+
client.upsert(
|
|
51
|
+
vectors: [
|
|
52
|
+
{ id: 'doc-1', values: [0.1, 0.2, 0.3], metadata: { category: 'news' } }
|
|
53
|
+
]
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
# Search
|
|
57
|
+
results = client.query(vector: [0.1, 0.2, 0.3], top_k: 5)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Configuration Options
|
|
61
|
+
|
|
62
|
+
| Option | Type | Required | Description |
|
|
63
|
+
|--------|------|----------|-------------|
|
|
64
|
+
| `host` | String | Yes | Weaviate host address |
|
|
65
|
+
| `port` | Integer | Yes | Weaviate port (default: 8080) |
|
|
66
|
+
| `class_name` | String | No | Class name for vectors |
|
|
67
|
+
| `api_key` | String | No | API key if auth is enabled |
|
|
68
|
+
|
|
69
|
+
## Documentation
|
|
70
|
+
|
|
71
|
+
- [Weaviate Docs](https://weaviate.io/developers)
|
|
72
|
+
- [Weaviate API Reference](https://weaviate.io/developers/weaviate/api/rest)
|
data/lib/vectra/configuration.rb
CHANGED
|
@@ -56,7 +56,11 @@ module Vectra
|
|
|
56
56
|
# @raise [ConfigurationError] if configuration is invalid
|
|
57
57
|
def validate!
|
|
58
58
|
raise ConfigurationError, "Provider must be configured" if provider.nil?
|
|
59
|
-
|
|
59
|
+
|
|
60
|
+
# API key is optional for some providers (Qdrant local, pgvector)
|
|
61
|
+
if !api_key_optional_provider? && (api_key.nil? || api_key.empty?)
|
|
62
|
+
raise ConfigurationError, "API key must be configured"
|
|
63
|
+
end
|
|
60
64
|
|
|
61
65
|
validate_provider_specific!
|
|
62
66
|
end
|
|
@@ -106,6 +110,11 @@ module Vectra
|
|
|
106
110
|
|
|
107
111
|
private
|
|
108
112
|
|
|
113
|
+
# Providers that don't require API key (local instances)
|
|
114
|
+
def api_key_optional_provider?
|
|
115
|
+
%i[qdrant pgvector].include?(provider)
|
|
116
|
+
end
|
|
117
|
+
|
|
109
118
|
def validate_provider_specific!
|
|
110
119
|
case provider
|
|
111
120
|
when :pinecone
|
|
@@ -218,6 +218,16 @@ module Vectra
|
|
|
218
218
|
end
|
|
219
219
|
end
|
|
220
220
|
|
|
221
|
+
# Handle Faraday::RetriableResponse from retry middleware
|
|
222
|
+
# This is raised when all retries are exhausted
|
|
223
|
+
#
|
|
224
|
+
# @param exception [Faraday::RetriableResponse] the exception
|
|
225
|
+
# @raise [Error] appropriate error for the response
|
|
226
|
+
def handle_retriable_response(exception)
|
|
227
|
+
response = exception.response
|
|
228
|
+
handle_error(response)
|
|
229
|
+
end
|
|
230
|
+
|
|
221
231
|
# Extract error message from response body
|
|
222
232
|
#
|
|
223
233
|
# @param body [Hash, String, nil] response body
|