vectra-client 0.2.1 → 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/README.md +140 -334
- 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/version.rb +1 -1
- data/netlify.toml +12 -0
- metadata +39 -5
- 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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4fb1baf885e79af651a89ca695ead6a909a39c495241586ec3a46bdbecfb48ec
|
|
4
|
+
data.tar.gz: 9e7d3c14ea8108531821790c2d6d9f3d76901f122ab2d78472bf9ac6dbfc32dc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b27299838743d313b9416e7c1d54f0bf694853df45526e9e6cdc51f3c2744b2254730100704ca980435ed982baf4d9341ce94a57e9eee8d9da3cc18ceb452fd1
|
|
7
|
+
data.tar.gz: a4a1ba817e2d094dde020471c63ec954f40de90e5389726b9c486da1aecd7140b80e3f4a0f4a773d654ccb75e3e65dd793bfd655ae749ae2c80a001e9a0259a8
|
data/README.md
CHANGED
|
@@ -1,440 +1,246 @@
|
|
|
1
|
-
# Vectra
|
|
1
|
+
# Vectra 🚀
|
|
2
2
|
|
|
3
|
-
[](https://
|
|
3
|
+
[](https://rubygems.org/gems/vectra-client)
|
|
4
4
|
[](https://github.com/stokry/vectra/actions)
|
|
5
5
|
[](https://codecov.io/gh/stokry/vectra)
|
|
6
6
|
[](https://github.com/rubocop/rubocop)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
[](CODE_OF_CONDUCT.md)
|
|
9
9
|
|
|
10
|
-
**
|
|
10
|
+
> **A unified Ruby client for vector databases.** Write once, switch vector database providers seamlessly. Perfect for AI/ML applications, semantic search, and RAG (Retrieval Augmented Generation) systems.
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## 📖 Complete Documentation
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
- 🚀 **Modern Ruby** - Built for Ruby 3.2+ with modern patterns
|
|
16
|
-
- 🔄 **Automatic Retries** - Built-in retry logic with exponential backoff
|
|
17
|
-
- 📊 **Rich Results** - Enumerable query results with filtering capabilities
|
|
18
|
-
- 🛡️ **Type Safety** - Comprehensive validation and meaningful errors
|
|
19
|
-
- 📝 **Well Documented** - Extensive YARD documentation
|
|
14
|
+
**Full documentation, guides, and API reference available at:** [**https://vectra-docs.netlify.app/**](https://vectra-docs.netlify.app/)
|
|
20
15
|
|
|
21
|
-
|
|
16
|
+
This README provides a quick overview. For detailed guides, examples, and API documentation, visit the official documentation site above.
|
|
22
17
|
|
|
23
|
-
|
|
24
|
-
|----------|--------|---------|
|
|
25
|
-
| [Pinecone](https://pinecone.io) | ✅ Fully Supported | v0.1.0 |
|
|
26
|
-
| [PostgreSQL + pgvector](https://github.com/pgvector/pgvector) | ✅ Fully Supported | v0.1.1 |
|
|
27
|
-
| [Qdrant](https://qdrant.tech) | ✅ Fully Supported | v0.2.1 |
|
|
28
|
-
| [Weaviate](https://weaviate.io) | 🚧 Planned | v0.3.0 |
|
|
18
|
+
---
|
|
29
19
|
|
|
30
|
-
##
|
|
20
|
+
## ✨ Key Features
|
|
21
|
+
|
|
22
|
+
- 🔌 **Provider Agnostic** - Switch between vector database providers with minimal code changes
|
|
23
|
+
- 🚀 **Production Ready** - Built for Ruby 3.2+ with comprehensive test coverage (95%+)
|
|
24
|
+
- 🔄 **Resilient** - Built-in retry logic with exponential backoff and circuit breaker patterns
|
|
25
|
+
- 📊 **Rich Results** - Enumerable query results with advanced filtering and mapping capabilities
|
|
26
|
+
- 🛡️ **Type Safe** - Comprehensive input validation and meaningful error messages
|
|
27
|
+
- 📈 **Observable** - Native instrumentation support for Datadog and New Relic
|
|
28
|
+
- 🏗️ **Rails Ready** - Seamless ActiveRecord integration with migrations support
|
|
29
|
+
- 📚 **Well Documented** - Extensive YARD documentation and comprehensive examples
|
|
30
|
+
|
|
31
|
+
## 🗄️ Supported Vector Databases
|
|
32
|
+
|
|
33
|
+
| Provider | Type | Status | Docs |
|
|
34
|
+
|----------|------|--------|------|
|
|
35
|
+
| **Pinecone** | Managed Cloud | ✅ Fully Supported | [Guide](https://vectra-docs.netlify.app/providers/pinecone) |
|
|
36
|
+
| **PostgreSQL + pgvector** | SQL Database | ✅ Fully Supported | [Guide](https://vectra-docs.netlify.app/providers/pgvector) |
|
|
37
|
+
| **Qdrant** | Open Source | ✅ Fully Supported | [Guide](https://vectra-docs.netlify.app/providers/qdrant) |
|
|
38
|
+
| **Weaviate** | Open Source | ✅ Fully Supported | [Guide](https://vectra-docs.netlify.app/providers/weaviate) |
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## 📦 Installation
|
|
31
43
|
|
|
32
44
|
Add this line to your application's Gemfile:
|
|
33
45
|
|
|
34
46
|
```ruby
|
|
35
|
-
gem 'vectra'
|
|
47
|
+
gem 'vectra-client'
|
|
36
48
|
```
|
|
37
49
|
|
|
38
|
-
|
|
50
|
+
Then execute:
|
|
39
51
|
|
|
40
52
|
```bash
|
|
41
53
|
bundle install
|
|
42
54
|
```
|
|
43
55
|
|
|
44
|
-
Or install
|
|
56
|
+
Or install directly:
|
|
45
57
|
|
|
46
58
|
```bash
|
|
47
|
-
gem install vectra
|
|
59
|
+
gem install vectra-client
|
|
48
60
|
```
|
|
49
61
|
|
|
50
|
-
###
|
|
62
|
+
### RubyGems Information
|
|
63
|
+
|
|
64
|
+
- **Gem Name:** `vectra-client`
|
|
65
|
+
- **Latest Version:** 0.2.1
|
|
66
|
+
- **Repository:** [stokry/vectra](https://github.com/stokry/vectra)
|
|
67
|
+
- **RubyGems Page:** [vectra-client](https://rubygems.org/gems/vectra-client)
|
|
68
|
+
- **License:** MIT
|
|
69
|
+
- **Ruby Requirement:** >= 3.2.0
|
|
51
70
|
|
|
52
|
-
|
|
71
|
+
### Provider-Specific Setup
|
|
53
72
|
|
|
73
|
+
Each vector database may require additional dependencies:
|
|
74
|
+
|
|
75
|
+
**PostgreSQL + pgvector:**
|
|
54
76
|
```ruby
|
|
55
77
|
gem 'pg', '~> 1.5'
|
|
56
78
|
```
|
|
57
79
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
### Configuration
|
|
61
|
-
|
|
80
|
+
**For Instrumentation:**
|
|
62
81
|
```ruby
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
# Global configuration
|
|
66
|
-
Vectra.configure do |config|
|
|
67
|
-
config.provider = :pinecone
|
|
68
|
-
config.api_key = ENV['PINECONE_API_KEY']
|
|
69
|
-
config.environment = 'us-east-1' # or config.host = 'your-index-host.pinecone.io'
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# Create a client
|
|
73
|
-
client = Vectra::Client.new
|
|
82
|
+
gem 'dogstatsd-ruby' # Datadog
|
|
83
|
+
gem 'newrelic_rpm' # New Relic
|
|
74
84
|
```
|
|
75
85
|
|
|
76
|
-
|
|
86
|
+
## 🚀 Quick Start
|
|
87
|
+
|
|
88
|
+
### 1. Initialize a Client
|
|
77
89
|
|
|
78
90
|
```ruby
|
|
79
|
-
|
|
80
|
-
client = Vectra.pinecone(
|
|
81
|
-
api_key: ENV['PINECONE_API_KEY'],
|
|
82
|
-
environment: 'us-east-1'
|
|
83
|
-
)
|
|
91
|
+
require 'vectra'
|
|
84
92
|
|
|
85
|
-
#
|
|
86
|
-
client = Vectra.
|
|
87
|
-
|
|
93
|
+
# Pinecone
|
|
94
|
+
client = Vectra::Client.new(
|
|
95
|
+
provider: :pinecone,
|
|
96
|
+
api_key: ENV['PINECONE_API_KEY'],
|
|
97
|
+
environment: 'us-west-4'
|
|
88
98
|
)
|
|
89
99
|
|
|
90
|
-
#
|
|
91
|
-
client = Vectra.
|
|
92
|
-
|
|
93
|
-
|
|
100
|
+
# PostgreSQL + pgvector
|
|
101
|
+
client = Vectra::Client.new(
|
|
102
|
+
provider: :pgvector,
|
|
103
|
+
database: 'my_app_production',
|
|
104
|
+
host: 'localhost'
|
|
94
105
|
)
|
|
95
106
|
|
|
96
|
-
#
|
|
107
|
+
# Qdrant
|
|
97
108
|
client = Vectra::Client.new(
|
|
98
|
-
provider: :
|
|
99
|
-
|
|
100
|
-
environment: 'us-east-1',
|
|
101
|
-
timeout: 60,
|
|
102
|
-
max_retries: 5
|
|
109
|
+
provider: :qdrant,
|
|
110
|
+
host: 'http://localhost:6333'
|
|
103
111
|
)
|
|
104
112
|
```
|
|
105
113
|
|
|
106
|
-
###
|
|
107
|
-
|
|
108
|
-
#### Upsert Vectors
|
|
114
|
+
### 2. Upsert Vectors
|
|
109
115
|
|
|
110
116
|
```ruby
|
|
111
117
|
client.upsert(
|
|
112
|
-
index: 'my-index',
|
|
113
118
|
vectors: [
|
|
114
|
-
{
|
|
115
|
-
|
|
119
|
+
{
|
|
120
|
+
id: 'doc-1',
|
|
121
|
+
values: [0.1, 0.2, 0.3],
|
|
122
|
+
metadata: { title: 'Introduction to AI' }
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: 'doc-2',
|
|
126
|
+
values: [0.2, 0.3, 0.4],
|
|
127
|
+
metadata: { title: 'Advanced ML Techniques' }
|
|
128
|
+
}
|
|
116
129
|
]
|
|
117
130
|
)
|
|
118
|
-
# => { upserted_count: 2 }
|
|
119
131
|
```
|
|
120
132
|
|
|
121
|
-
|
|
133
|
+
### 3. Search for Similar Vectors
|
|
122
134
|
|
|
123
135
|
```ruby
|
|
124
136
|
results = client.query(
|
|
125
|
-
index: 'my-index',
|
|
126
137
|
vector: [0.1, 0.2, 0.3],
|
|
127
|
-
top_k: 5
|
|
128
|
-
include_metadata: true
|
|
138
|
+
top_k: 5
|
|
129
139
|
)
|
|
130
140
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
puts "
|
|
134
|
-
puts "Metadata: #{match.metadata}"
|
|
141
|
+
results.matches.each do |match|
|
|
142
|
+
puts "#{match['id']}: #{match['score']}"
|
|
143
|
+
puts " Metadata: #{match['metadata']}"
|
|
135
144
|
end
|
|
136
|
-
|
|
137
|
-
# Access specific results
|
|
138
|
-
results.first # First match
|
|
139
|
-
results.ids # All matching IDs
|
|
140
|
-
results.scores # All scores
|
|
141
|
-
results.max_score # Highest score
|
|
142
|
-
|
|
143
|
-
# Filter by score
|
|
144
|
-
high_quality = results.above_score(0.8)
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
### 4. Delete Vectors
|
|
148
148
|
|
|
149
149
|
```ruby
|
|
150
|
-
|
|
151
|
-
index: 'my-index',
|
|
152
|
-
vector: [0.1, 0.2, 0.3],
|
|
153
|
-
top_k: 10,
|
|
154
|
-
filter: { category: 'programming', language: 'ruby' }
|
|
155
|
-
)
|
|
150
|
+
client.delete(ids: ['doc-1', 'doc-2'])
|
|
156
151
|
```
|
|
157
152
|
|
|
158
|
-
|
|
153
|
+
## 📖 Full Documentation
|
|
159
154
|
|
|
160
|
-
|
|
161
|
-
vectors = client.fetch(index: 'my-index', ids: ['vec1', 'vec2'])
|
|
155
|
+
For complete documentation, examples, and guides, visit:
|
|
162
156
|
|
|
163
|
-
|
|
164
|
-
vectors['vec1'].metadata # { 'text' => 'Hello world' }
|
|
165
|
-
```
|
|
157
|
+
**👉 [https://vectra-docs.netlify.app/](https://vectra-docs.netlify.app/)**
|
|
166
158
|
|
|
167
|
-
|
|
159
|
+
### Documentation Includes:
|
|
168
160
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
)
|
|
175
|
-
|
|
161
|
+
- [Installation Guide](https://vectra-docs.netlify.app/guides/installation)
|
|
162
|
+
- [Getting Started](https://vectra-docs.netlify.app/guides/getting-started)
|
|
163
|
+
- [Provider Guides](https://vectra-docs.netlify.app/providers)
|
|
164
|
+
- [Pinecone](https://vectra-docs.netlify.app/providers/pinecone)
|
|
165
|
+
- [PostgreSQL + pgvector](https://vectra-docs.netlify.app/providers/pgvector)
|
|
166
|
+
- [Qdrant](https://vectra-docs.netlify.app/providers/qdrant)
|
|
167
|
+
- [Weaviate](https://vectra-docs.netlify.app/providers/weaviate)
|
|
168
|
+
- [API Reference](https://vectra-docs.netlify.app/api/overview)
|
|
169
|
+
- [Code Examples](https://vectra-docs.netlify.app/examples)
|
|
170
|
+
- [Rails Integration Guide](https://vectra-docs.netlify.app/providers/pgvector/)
|
|
176
171
|
|
|
177
|
-
|
|
172
|
+
---
|
|
178
173
|
|
|
179
|
-
|
|
180
|
-
# Delete by IDs
|
|
181
|
-
client.delete(index: 'my-index', ids: ['vec1', 'vec2'])
|
|
174
|
+
## 💡 Use Cases
|
|
182
175
|
|
|
183
|
-
|
|
184
|
-
|
|
176
|
+
### Semantic Search
|
|
177
|
+
Build intelligent search that understands meaning, not just keywords. Perfect for product discovery, knowledge base search, and content recommendation.
|
|
185
178
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
```
|
|
179
|
+
### Retrieval Augmented Generation (RAG)
|
|
180
|
+
Combine vector databases with LLMs to enable precise information retrieval for AI applications, chatbots, and knowledge systems.
|
|
189
181
|
|
|
190
|
-
###
|
|
182
|
+
### Duplicate Detection
|
|
183
|
+
Identify and deduplicate similar items across your dataset using vector similarity.
|
|
191
184
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
vector = Vectra::Vector.new(
|
|
195
|
-
id: 'my-vector',
|
|
196
|
-
values: [0.1, 0.2, 0.3],
|
|
197
|
-
metadata: { text: 'Example' }
|
|
198
|
-
)
|
|
185
|
+
### Recommendation Systems
|
|
186
|
+
Power personalized recommendations based on user behavior and content similarity.
|
|
199
187
|
|
|
200
|
-
|
|
201
|
-
vector.metadata? # => true
|
|
202
|
-
vector.to_h # Convert to hash
|
|
188
|
+
---
|
|
203
189
|
|
|
204
|
-
# Calculate similarity
|
|
205
|
-
other = Vectra::Vector.new(id: 'other', values: [0.1, 0.2, 0.3])
|
|
206
|
-
vector.cosine_similarity(other) # => 1.0 (identical)
|
|
207
|
-
vector.euclidean_distance(other) # => 0.0
|
|
208
|
-
```
|
|
209
190
|
|
|
210
|
-
|
|
191
|
+
## 🛠️ Development
|
|
211
192
|
|
|
212
|
-
|
|
213
|
-
# List all indexes
|
|
214
|
-
indexes = client.list_indexes
|
|
215
|
-
indexes.each { |idx| puts idx[:name] }
|
|
216
|
-
|
|
217
|
-
# Describe an index
|
|
218
|
-
info = client.describe_index(index: 'my-index')
|
|
219
|
-
puts info[:dimension] # => 384
|
|
220
|
-
puts info[:metric] # => "cosine"
|
|
221
|
-
|
|
222
|
-
# Get index statistics
|
|
223
|
-
stats = client.stats(index: 'my-index')
|
|
224
|
-
puts stats[:total_vector_count]
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### Namespaces
|
|
228
|
-
|
|
229
|
-
Namespaces allow you to partition vectors within an index:
|
|
230
|
-
|
|
231
|
-
```ruby
|
|
232
|
-
# Upsert to a namespace
|
|
233
|
-
client.upsert(
|
|
234
|
-
index: 'my-index',
|
|
235
|
-
namespace: 'production',
|
|
236
|
-
vectors: [...]
|
|
237
|
-
)
|
|
238
|
-
|
|
239
|
-
# Query within a namespace
|
|
240
|
-
client.query(
|
|
241
|
-
index: 'my-index',
|
|
242
|
-
namespace: 'production',
|
|
243
|
-
vector: [0.1, 0.2, 0.3],
|
|
244
|
-
top_k: 5
|
|
245
|
-
)
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
### pgvector (PostgreSQL)
|
|
249
|
-
|
|
250
|
-
pgvector uses PostgreSQL tables as indexes. Each "index" is a table with a vector column.
|
|
251
|
-
|
|
252
|
-
#### Setup PostgreSQL with pgvector
|
|
193
|
+
### Set Up Development Environment
|
|
253
194
|
|
|
254
195
|
```bash
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
-p 5432:5432 \
|
|
259
|
-
pgvector/pgvector:pg16
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
#### Create an Index (Table)
|
|
263
|
-
|
|
264
|
-
```ruby
|
|
265
|
-
client = Vectra.pgvector(connection_url: 'postgres://postgres:password@localhost/postgres')
|
|
266
|
-
|
|
267
|
-
# Create a new index with cosine similarity
|
|
268
|
-
client.provider.create_index(
|
|
269
|
-
name: 'documents',
|
|
270
|
-
dimension: 384,
|
|
271
|
-
metric: 'cosine' # or 'euclidean', 'inner_product'
|
|
272
|
-
)
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
#### Supported Metrics
|
|
276
|
-
|
|
277
|
-
| Metric | Description | pgvector Operator |
|
|
278
|
-
|--------|-------------|-------------------|
|
|
279
|
-
| `cosine` | Cosine similarity (default) | `<=>` |
|
|
280
|
-
| `euclidean` | Euclidean distance | `<->` |
|
|
281
|
-
| `inner_product` | Inner product / dot product | `<#>` |
|
|
282
|
-
|
|
283
|
-
#### Table Structure
|
|
284
|
-
|
|
285
|
-
Vectra creates tables with the following structure:
|
|
286
|
-
|
|
287
|
-
```sql
|
|
288
|
-
CREATE TABLE documents (
|
|
289
|
-
id TEXT PRIMARY KEY,
|
|
290
|
-
embedding vector(384),
|
|
291
|
-
metadata JSONB DEFAULT '{}',
|
|
292
|
-
namespace TEXT DEFAULT '',
|
|
293
|
-
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
294
|
-
);
|
|
295
|
-
|
|
296
|
-
-- IVFFlat index for fast similarity search
|
|
297
|
-
CREATE INDEX ON documents USING ivfflat (embedding vector_cosine_ops);
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
## Configuration Options
|
|
301
|
-
|
|
302
|
-
| Option | Description | Default |
|
|
303
|
-
|--------|-------------|---------|
|
|
304
|
-
| `provider` | Vector database provider (`:pinecone`, `:pgvector`, `:qdrant`, `:weaviate`) | Required |
|
|
305
|
-
| `api_key` | API key for authentication (password for pgvector) | Required* |
|
|
306
|
-
| `environment` | Environment/region (Pinecone) | - |
|
|
307
|
-
| `host` | Direct host URL or PostgreSQL connection URL | - |
|
|
308
|
-
| `timeout` | Request timeout in seconds | 30 |
|
|
309
|
-
| `open_timeout` | Connection timeout in seconds | 10 |
|
|
310
|
-
| `max_retries` | Maximum retry attempts | 3 |
|
|
311
|
-
| `retry_delay` | Initial retry delay in seconds | 1 |
|
|
312
|
-
| `logger` | Logger instance for debugging | nil |
|
|
313
|
-
|
|
314
|
-
*For pgvector, `api_key` is used as the PostgreSQL password.
|
|
315
|
-
|
|
316
|
-
## Error Handling
|
|
317
|
-
|
|
318
|
-
Vectra provides specific error classes for different failure scenarios:
|
|
319
|
-
|
|
320
|
-
```ruby
|
|
321
|
-
begin
|
|
322
|
-
client.query(index: 'my-index', vector: [0.1, 0.2], top_k: 5)
|
|
323
|
-
rescue Vectra::AuthenticationError => e
|
|
324
|
-
puts "Authentication failed: #{e.message}"
|
|
325
|
-
rescue Vectra::RateLimitError => e
|
|
326
|
-
puts "Rate limited. Retry after #{e.retry_after} seconds"
|
|
327
|
-
rescue Vectra::NotFoundError => e
|
|
328
|
-
puts "Resource not found: #{e.message}"
|
|
329
|
-
rescue Vectra::ValidationError => e
|
|
330
|
-
puts "Invalid request: #{e.message}"
|
|
331
|
-
rescue Vectra::ServerError => e
|
|
332
|
-
puts "Server error (#{e.status_code}): #{e.message}"
|
|
333
|
-
rescue Vectra::Error => e
|
|
334
|
-
puts "General error: #{e.message}"
|
|
335
|
-
end
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
## Logging
|
|
339
|
-
|
|
340
|
-
Enable debug logging to see request details:
|
|
341
|
-
|
|
342
|
-
```ruby
|
|
343
|
-
require 'logger'
|
|
344
|
-
|
|
345
|
-
Vectra.configure do |config|
|
|
346
|
-
config.provider = :pinecone
|
|
347
|
-
config.api_key = ENV['PINECONE_API_KEY']
|
|
348
|
-
config.environment = 'us-east-1'
|
|
349
|
-
config.logger = Logger.new($stdout)
|
|
350
|
-
end
|
|
196
|
+
git clone https://github.com/stokry/vectra.git
|
|
197
|
+
cd vectra
|
|
198
|
+
bundle install
|
|
351
199
|
```
|
|
352
200
|
|
|
353
|
-
|
|
201
|
+
### Run Tests
|
|
354
202
|
|
|
355
|
-
|
|
203
|
+
```bash
|
|
204
|
+
# All tests
|
|
205
|
+
bundle exec rspec
|
|
356
206
|
|
|
357
|
-
|
|
207
|
+
# Unit tests only
|
|
208
|
+
bundle exec rspec spec/vectra
|
|
358
209
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
client.upsert(index: 'my-index', vectors: batch)
|
|
362
|
-
end
|
|
210
|
+
# Integration tests only
|
|
211
|
+
bundle exec rspec spec/integration
|
|
363
212
|
```
|
|
364
213
|
|
|
365
|
-
###
|
|
214
|
+
### Code Quality
|
|
366
215
|
|
|
367
|
-
|
|
216
|
+
```bash
|
|
217
|
+
# Run RuboCop linter
|
|
218
|
+
bundle exec rubocop
|
|
368
219
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
client = Vectra::Client.new(...)
|
|
372
|
-
client.query(...)
|
|
373
|
-
client.upsert(...)
|
|
374
|
-
|
|
375
|
-
# Avoid: Creating new clients for each operation
|
|
376
|
-
Vectra::Client.new(...).query(...)
|
|
377
|
-
Vectra::Client.new(...).upsert(...)
|
|
220
|
+
# Generate documentation
|
|
221
|
+
bundle exec rake docs
|
|
378
222
|
```
|
|
379
223
|
|
|
380
|
-
|
|
224
|
+
## 🤝 Contributing
|
|
381
225
|
|
|
382
|
-
|
|
226
|
+
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
383
227
|
|
|
384
|
-
|
|
385
|
-
def query_with_retry(client, **params, retries: 3)
|
|
386
|
-
client.query(**params)
|
|
387
|
-
rescue Vectra::RateLimitError => e
|
|
388
|
-
if retries > 0
|
|
389
|
-
sleep(e.retry_after || 1)
|
|
390
|
-
retry(retries: retries - 1)
|
|
391
|
-
else
|
|
392
|
-
raise
|
|
393
|
-
end
|
|
394
|
-
end
|
|
395
|
-
```
|
|
228
|
+
See [CHANGELOG.md](CHANGELOG.md) for the complete history of changes.
|
|
396
229
|
|
|
397
|
-
##
|
|
230
|
+
## 🔗 Links
|
|
398
231
|
|
|
399
|
-
|
|
232
|
+
- **Documentation:** [https://vectra-docs.netlify.app/](https://vectra-docs.netlify.app/)
|
|
233
|
+
- **RubyGems:** [vectra-client](https://rubygems.org/gems/vectra-client)
|
|
234
|
+
- **GitHub:** [stokry/vectra](https://github.com/stokry/vectra)
|
|
235
|
+
- **Issues:** [Report a bug](https://github.com/stokry/vectra/issues)
|
|
400
236
|
|
|
401
|
-
|
|
402
|
-
# Install dependencies
|
|
403
|
-
bundle install
|
|
237
|
+
## 📄 License
|
|
404
238
|
|
|
405
|
-
|
|
406
|
-
bundle exec rspec
|
|
407
|
-
|
|
408
|
-
# Run linter
|
|
409
|
-
bundle exec rubocop
|
|
239
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
410
240
|
|
|
411
|
-
|
|
412
|
-
bundle exec rake docs
|
|
413
|
-
```
|
|
241
|
+
---
|
|
414
242
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
### v0.1.0
|
|
418
|
-
- ✅ Pinecone provider
|
|
419
|
-
- ✅ Basic CRUD operations
|
|
420
|
-
- ✅ Configuration system
|
|
421
|
-
- ✅ Error handling with retries
|
|
422
|
-
- ✅ Comprehensive tests
|
|
423
|
-
|
|
424
|
-
### v0.1.1 (Current)
|
|
425
|
-
- ✅ pgvector (PostgreSQL) provider
|
|
426
|
-
- ✅ Multiple similarity metrics (cosine, euclidean, inner product)
|
|
427
|
-
- ✅ Namespace support for pgvector
|
|
428
|
-
- ✅ IVFFlat index creation
|
|
429
|
-
|
|
430
|
-
### v0.2.1
|
|
431
|
-
- ✅ Qdrant provider (fully implemented)
|
|
432
|
-
- ✅ Enhanced error handling
|
|
433
|
-
- ✅ Improved retry middleware
|
|
434
|
-
|
|
435
|
-
### v0.3.0
|
|
436
|
-
- 🚧 Weaviate provider
|
|
437
|
-
- 🚧 Batch operations
|
|
243
|
+
**Built with ❤️ by the Vectra community**
|
|
438
244
|
- 🚧 Performance optimizations
|
|
439
245
|
|
|
440
246
|
### v1.0.0
|
data/docs/Gemfile
ADDED
data/docs/_config.yml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
title: Vectra Documentation
|
|
2
|
+
description: Unified Ruby client for vector databases
|
|
3
|
+
theme: minima
|
|
4
|
+
plugins:
|
|
5
|
+
- jekyll-feed
|
|
6
|
+
- jekyll-sitemap
|
|
7
|
+
|
|
8
|
+
markdown: kramdown
|
|
9
|
+
highlighter: rouge
|
|
10
|
+
|
|
11
|
+
exclude:
|
|
12
|
+
- Gemfile
|
|
13
|
+
- Gemfile.lock
|
|
14
|
+
- node_modules
|
|
15
|
+
- vendor/bundle/
|
|
16
|
+
- vendor/cache/
|
|
17
|
+
- vendor/gems/
|
|
18
|
+
- vendor/ruby/
|
|
19
|
+
|
|
20
|
+
permalink: /:categories/:title/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<head>
|
|
6
|
+
<meta charset="utf-8">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
|
+
<title>{{ page.title }} - Vectra Documentation</title>
|
|
9
|
+
<link rel="stylesheet" href="{{ site.baseurl }}/assets/style.css">
|
|
10
|
+
</head>
|
|
11
|
+
|
|
12
|
+
<body>
|
|
13
|
+
{{ content }}
|
|
14
|
+
</body>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<div class="site-header">
|
|
6
|
+
<nav class="site-nav">
|
|
7
|
+
<div class="nav-container">
|
|
8
|
+
<a href="{{ site.baseurl }}/" class="nav-brand">Vectra</a>
|
|
9
|
+
<ul class="nav-menu">
|
|
10
|
+
<li><a href="{{ site.baseurl }}/guides/installation" class="nav-link">Guides</a></li>
|
|
11
|
+
<li><a href="{{ site.baseurl }}/api/overview" class="nav-link">API</a></li>
|
|
12
|
+
<li><a href="{{ site.baseurl }}/providers" class="nav-link">Providers</a></li>
|
|
13
|
+
<li><a href="{{ site.baseurl }}/examples" class="nav-link">Examples</a></li>
|
|
14
|
+
<li><a href="https://github.com/stokry/vectra" target="_blank" class="nav-link">GitHub</a></li>
|
|
15
|
+
</ul>
|
|
16
|
+
</div>
|
|
17
|
+
</nav>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<main class="site-main home-main">
|
|
21
|
+
{{ content }}
|
|
22
|
+
</main>
|
|
23
|
+
|
|
24
|
+
<footer class="site-footer">
|
|
25
|
+
<div class="footer-content">
|
|
26
|
+
<p>© 2024 Vectra. MIT License.</p>
|
|
27
|
+
<ul class="footer-links">
|
|
28
|
+
<li><a href="https://github.com/stokry/vectra">GitHub</a></li>
|
|
29
|
+
<li><a href="https://rubygems.org/gems/vectra-client">RubyGems</a></li>
|
|
30
|
+
<li><a href="{{ site.baseurl }}/community/contributing">Contributing</a></li>
|
|
31
|
+
</ul>
|
|
32
|
+
</div>
|
|
33
|
+
</footer>
|