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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -14
  3. data/README.md +140 -328
  4. data/Rakefile +1 -1
  5. data/docs/Gemfile +10 -0
  6. data/docs/_config.yml +20 -0
  7. data/docs/_layouts/default.html +14 -0
  8. data/docs/_layouts/home.html +33 -0
  9. data/docs/_layouts/page.html +20 -0
  10. data/docs/_site/api/overview/index.html +145 -0
  11. data/docs/_site/assets/main.css +649 -0
  12. data/docs/_site/assets/main.css.map +1 -0
  13. data/docs/_site/assets/minima-social-icons.svg +33 -0
  14. data/docs/_site/assets/style.css +295 -0
  15. data/docs/_site/community/contributing/index.html +110 -0
  16. data/docs/_site/examples/basic-usage/index.html +117 -0
  17. data/docs/_site/examples/index.html +58 -0
  18. data/docs/_site/feed.xml +1 -0
  19. data/docs/_site/guides/getting-started/index.html +106 -0
  20. data/docs/_site/guides/installation/index.html +82 -0
  21. data/docs/_site/index.html +92 -0
  22. data/docs/_site/providers/index.html +119 -0
  23. data/docs/_site/providers/pgvector/index.html +155 -0
  24. data/docs/_site/providers/pinecone/index.html +121 -0
  25. data/docs/_site/providers/qdrant/index.html +124 -0
  26. data/docs/_site/providers/weaviate/index.html +123 -0
  27. data/docs/_site/robots.txt +1 -0
  28. data/docs/_site/sitemap.xml +39 -0
  29. data/docs/api/overview.md +126 -0
  30. data/docs/assets/style.css +295 -0
  31. data/docs/community/contributing.md +89 -0
  32. data/docs/examples/basic-usage.md +102 -0
  33. data/docs/examples/index.md +32 -0
  34. data/docs/guides/getting-started.md +90 -0
  35. data/docs/guides/installation.md +67 -0
  36. data/docs/index.md +53 -0
  37. data/docs/providers/index.md +62 -0
  38. data/docs/providers/pgvector.md +95 -0
  39. data/docs/providers/pinecone.md +72 -0
  40. data/docs/providers/qdrant.md +73 -0
  41. data/docs/providers/weaviate.md +72 -0
  42. data/lib/vectra/configuration.rb +10 -1
  43. data/lib/vectra/providers/base.rb +10 -0
  44. data/lib/vectra/providers/qdrant.rb +399 -12
  45. data/lib/vectra/version.rb +1 -1
  46. data/lib/vectra.rb +9 -2
  47. data/netlify.toml +12 -0
  48. metadata +43 -9
  49. data/IMPLEMENTATION_GUIDE.md +0 -686
  50. data/NEW_FEATURES_v0.2.0.md +0 -459
  51. data/RELEASE_CHECKLIST_v0.2.0.md +0 -383
  52. data/USAGE_EXAMPLES.md +0 -787
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23e0684b20e30c7083b21676f50611b82c2926baec2cd2596a02aa9d0f1524b2
4
- data.tar.gz: 892a0094e23003e7c4647a931dca2b785c243439bad35d3511391df0b3275587
3
+ metadata.gz: 4fb1baf885e79af651a89ca695ead6a909a39c495241586ec3a46bdbecfb48ec
4
+ data.tar.gz: 9e7d3c14ea8108531821790c2d6d9f3d76901f122ab2d78472bf9ac6dbfc32dc
5
5
  SHA512:
6
- metadata.gz: 356585c134240dc3b36734f85f3a68965ee18f16dfe1437737628d1c8b9c0c9fcbaca11e7092e1328501fd861f1e1c297a8bad38197a1b0033a9af5159ddb075
7
- data.tar.gz: 0abf8ee4bf16c01065db7dad529ff3da125a0f4bb45a91be19a94842405fdfc8e8c86a9aed7ae153b68323e528111fbea13ffbb2888b1216b1b045cbf1937888
6
+ metadata.gz: b27299838743d313b9416e7c1d54f0bf694853df45526e9e6cdc51f3c2744b2254730100704ca980435ed982baf4d9341ce94a57e9eee8d9da3cc18ceb452fd1
7
+ data.tar.gz: a4a1ba817e2d094dde020471c63ec954f40de90e5389726b9c486da1aecd7140b80e3f4a0f4a773d654ccb75e3e65dd793bfd655ae749ae2c80a001e9a0259a8
data/CHANGELOG.md CHANGED
@@ -7,6 +7,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.1] - 2025-01-08
11
+
12
+ ### Added
13
+
14
+ - **Qdrant Provider** - Full Qdrant vector database support:
15
+ - Vector upsert, query, fetch, update, delete operations
16
+ - Collection management (create, list, describe, delete)
17
+ - Multiple similarity metrics: cosine, euclidean, dot product
18
+ - Namespace support via payload filtering
19
+ - Advanced metadata filtering with Qdrant operators ($eq, $ne, $gt, $gte, $lt, $lte, $in, $nin)
20
+ - Automatic point ID hashing for string IDs
21
+ - Support for both local and cloud Qdrant instances
22
+ - Optional API key authentication for local deployments
23
+
24
+ ### Improved
25
+
26
+ - Enhanced error handling with `Faraday::RetriableResponse` support
27
+ - Configuration now allows optional API key for Qdrant and pgvector (local instances)
28
+ - Better retry middleware integration across all providers
29
+
30
+ ### Provider Support
31
+
32
+ - ✅ Pinecone - Fully implemented
33
+ - ✅ pgvector (PostgreSQL) - Fully implemented
34
+ - ✅ Qdrant - Fully implemented
35
+ - 🚧 Weaviate - Stub implementation (planned for v0.3.0)
36
+
10
37
  ## [0.2.0] - 2025-01-08
11
38
 
12
39
  ### Added
@@ -49,13 +76,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
49
76
  - Updated gemspec description to include pgvector
50
77
  - Added `pg` gem as development dependency
51
78
 
52
- ### Provider Support
53
-
54
- - ✅ Pinecone - Fully implemented
55
- - ✅ pgvector (PostgreSQL) - Fully implemented
56
- - 🚧 Qdrant - Stub implementation (planned for v0.2.0)
57
- - 🚧 Weaviate - Stub implementation (planned for v0.3.0)
58
-
59
79
  ## [0.1.0] - 2024-XX-XX
60
80
 
61
81
  ### Added
@@ -89,13 +109,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
89
109
 
90
110
  ## Planned
91
111
 
92
- ### [0.2.0]
93
-
94
- - Qdrant provider implementation
95
- - Enhanced error messages
96
- - Connection pooling
97
- - Improved retry strategies
98
-
99
112
  ### [0.3.0]
100
113
 
101
114
  - Weaviate provider implementation
data/README.md CHANGED
@@ -1,434 +1,246 @@
1
- # Vectra
1
+ # Vectra 🚀
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/vectra.svg)](https://badge.fury.io/rb/vectra)
3
+ [![Gem Version](https://badge.fury.io/rb/vectra-client.svg)](https://rubygems.org/gems/vectra-client)
4
4
  [![CI](https://github.com/stokry/vectra/actions/workflows/ci.yml/badge.svg)](https://github.com/stokry/vectra/actions)
5
5
  [![codecov](https://codecov.io/gh/stokry/vectra/branch/main/graph/badge.svg)](https://codecov.io/gh/stokry/vectra)
6
6
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
8
  [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](CODE_OF_CONDUCT.md)
9
9
 
10
- **Vectra** is a unified Ruby client for vector databases. Write once, switch providers seamlessly.
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
- ## Features
12
+ ## 📖 Complete Documentation
13
13
 
14
- - 🔌 **Unified API** - One interface for multiple vector databases
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
- ## Supported Providers
16
+ This README provides a quick overview. For detailed guides, examples, and API documentation, visit the official documentation site above.
22
17
 
23
- | Provider | Status | Version |
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) | 🚧 Planned | v0.2.0 |
28
- | [Weaviate](https://weaviate.io) | 🚧 Planned | v0.3.0 |
18
+ ---
29
19
 
30
- ## Installation
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
- And then execute:
50
+ Then execute:
39
51
 
40
52
  ```bash
41
53
  bundle install
42
54
  ```
43
55
 
44
- Or install it yourself:
56
+ Or install directly:
45
57
 
46
58
  ```bash
47
- gem install vectra
59
+ gem install vectra-client
48
60
  ```
49
61
 
50
- ### Provider-Specific Dependencies
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
- For **pgvector** support, add the `pg` gem:
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
- ## Quick Start
59
-
60
- ### Configuration
61
-
80
+ **For Instrumentation:**
62
81
  ```ruby
63
- require 'vectra'
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
- Or use per-client configuration:
86
+ ## 🚀 Quick Start
87
+
88
+ ### 1. Initialize a Client
77
89
 
78
90
  ```ruby
79
- # Shortcut for Pinecone
80
- client = Vectra.pinecone(
91
+ require 'vectra'
92
+
93
+ # Pinecone
94
+ client = Vectra::Client.new(
95
+ provider: :pinecone,
81
96
  api_key: ENV['PINECONE_API_KEY'],
82
- environment: 'us-east-1'
97
+ environment: 'us-west-4'
83
98
  )
84
99
 
85
- # Shortcut for pgvector (PostgreSQL)
86
- client = Vectra.pgvector(
87
- connection_url: 'postgres://user:password@localhost/mydb'
100
+ # PostgreSQL + pgvector
101
+ client = Vectra::Client.new(
102
+ provider: :pgvector,
103
+ database: 'my_app_production',
104
+ host: 'localhost'
88
105
  )
89
106
 
90
- # Generic client with options
107
+ # Qdrant
91
108
  client = Vectra::Client.new(
92
- provider: :pinecone,
93
- api_key: ENV['PINECONE_API_KEY'],
94
- environment: 'us-east-1',
95
- timeout: 60,
96
- max_retries: 5
109
+ provider: :qdrant,
110
+ host: 'http://localhost:6333'
97
111
  )
98
112
  ```
99
113
 
100
- ### Basic Operations
101
-
102
- #### Upsert Vectors
114
+ ### 2. Upsert Vectors
103
115
 
104
116
  ```ruby
105
117
  client.upsert(
106
- index: 'my-index',
107
118
  vectors: [
108
- { id: 'vec1', values: [0.1, 0.2, 0.3], metadata: { text: 'Hello world' } },
109
- { id: 'vec2', values: [0.4, 0.5, 0.6], metadata: { text: 'Ruby is great' } }
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
+ }
110
129
  ]
111
130
  )
112
- # => { upserted_count: 2 }
113
131
  ```
114
132
 
115
- #### Query Vectors
133
+ ### 3. Search for Similar Vectors
116
134
 
117
135
  ```ruby
118
136
  results = client.query(
119
- index: 'my-index',
120
137
  vector: [0.1, 0.2, 0.3],
121
- top_k: 5,
122
- include_metadata: true
138
+ top_k: 5
123
139
  )
124
140
 
125
- # Iterate over results
126
- results.each do |match|
127
- puts "ID: #{match.id}, Score: #{match.score}"
128
- puts "Metadata: #{match.metadata}"
141
+ results.matches.each do |match|
142
+ puts "#{match['id']}: #{match['score']}"
143
+ puts " Metadata: #{match['metadata']}"
129
144
  end
130
-
131
- # Access specific results
132
- results.first # First match
133
- results.ids # All matching IDs
134
- results.scores # All scores
135
- results.max_score # Highest score
136
-
137
- # Filter by score
138
- high_quality = results.above_score(0.8)
139
145
  ```
140
146
 
141
- #### Query with Filters
147
+ ### 4. Delete Vectors
142
148
 
143
149
  ```ruby
144
- results = client.query(
145
- index: 'my-index',
146
- vector: [0.1, 0.2, 0.3],
147
- top_k: 10,
148
- filter: { category: 'programming', language: 'ruby' }
149
- )
150
- ```
151
-
152
- #### Fetch Vectors by ID
153
-
154
- ```ruby
155
- vectors = client.fetch(index: 'my-index', ids: ['vec1', 'vec2'])
156
-
157
- vectors['vec1'].values # [0.1, 0.2, 0.3]
158
- vectors['vec1'].metadata # { 'text' => 'Hello world' }
150
+ client.delete(ids: ['doc-1', 'doc-2'])
159
151
  ```
160
152
 
161
- #### Update Vector Metadata
153
+ ## 📖 Full Documentation
162
154
 
163
- ```ruby
164
- client.update(
165
- index: 'my-index',
166
- id: 'vec1',
167
- metadata: { category: 'updated', processed: true }
168
- )
169
- ```
170
-
171
- #### Delete Vectors
172
-
173
- ```ruby
174
- # Delete by IDs
175
- client.delete(index: 'my-index', ids: ['vec1', 'vec2'])
155
+ For complete documentation, examples, and guides, visit:
176
156
 
177
- # Delete by filter
178
- client.delete(index: 'my-index', filter: { category: 'old' })
157
+ **👉 [https://vectra-docs.netlify.app/](https://vectra-docs.netlify.app/)**
179
158
 
180
- # Delete all (use with caution!)
181
- client.delete(index: 'my-index', delete_all: true)
182
- ```
159
+ ### Documentation Includes:
183
160
 
184
- ### Working with Vectors
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/)
185
171
 
186
- ```ruby
187
- # Create a Vector object
188
- vector = Vectra::Vector.new(
189
- id: 'my-vector',
190
- values: [0.1, 0.2, 0.3],
191
- metadata: { text: 'Example' }
192
- )
172
+ ---
193
173
 
194
- vector.dimension # => 3
195
- vector.metadata? # => true
196
- vector.to_h # Convert to hash
174
+ ## 💡 Use Cases
197
175
 
198
- # Calculate similarity
199
- other = Vectra::Vector.new(id: 'other', values: [0.1, 0.2, 0.3])
200
- vector.cosine_similarity(other) # => 1.0 (identical)
201
- vector.euclidean_distance(other) # => 0.0
202
- ```
176
+ ### Semantic Search
177
+ Build intelligent search that understands meaning, not just keywords. Perfect for product discovery, knowledge base search, and content recommendation.
203
178
 
204
- ### Index Management
179
+ ### Retrieval Augmented Generation (RAG)
180
+ Combine vector databases with LLMs to enable precise information retrieval for AI applications, chatbots, and knowledge systems.
205
181
 
206
- ```ruby
207
- # List all indexes
208
- indexes = client.list_indexes
209
- indexes.each { |idx| puts idx[:name] }
210
-
211
- # Describe an index
212
- info = client.describe_index(index: 'my-index')
213
- puts info[:dimension] # => 384
214
- puts info[:metric] # => "cosine"
215
-
216
- # Get index statistics
217
- stats = client.stats(index: 'my-index')
218
- puts stats[:total_vector_count]
219
- ```
182
+ ### Duplicate Detection
183
+ Identify and deduplicate similar items across your dataset using vector similarity.
220
184
 
221
- ### Namespaces
185
+ ### Recommendation Systems
186
+ Power personalized recommendations based on user behavior and content similarity.
222
187
 
223
- Namespaces allow you to partition vectors within an index:
188
+ ---
224
189
 
225
- ```ruby
226
- # Upsert to a namespace
227
- client.upsert(
228
- index: 'my-index',
229
- namespace: 'production',
230
- vectors: [...]
231
- )
232
190
 
233
- # Query within a namespace
234
- client.query(
235
- index: 'my-index',
236
- namespace: 'production',
237
- vector: [0.1, 0.2, 0.3],
238
- top_k: 5
239
- )
240
- ```
191
+ ## 🛠️ Development
241
192
 
242
- ### pgvector (PostgreSQL)
243
-
244
- pgvector uses PostgreSQL tables as indexes. Each "index" is a table with a vector column.
245
-
246
- #### Setup PostgreSQL with pgvector
193
+ ### Set Up Development Environment
247
194
 
248
195
  ```bash
249
- # Using Docker
250
- docker run -d --name pgvector \
251
- -e POSTGRES_PASSWORD=password \
252
- -p 5432:5432 \
253
- pgvector/pgvector:pg16
254
- ```
255
-
256
- #### Create an Index (Table)
257
-
258
- ```ruby
259
- client = Vectra.pgvector(connection_url: 'postgres://postgres:password@localhost/postgres')
260
-
261
- # Create a new index with cosine similarity
262
- client.provider.create_index(
263
- name: 'documents',
264
- dimension: 384,
265
- metric: 'cosine' # or 'euclidean', 'inner_product'
266
- )
267
- ```
268
-
269
- #### Supported Metrics
270
-
271
- | Metric | Description | pgvector Operator |
272
- |--------|-------------|-------------------|
273
- | `cosine` | Cosine similarity (default) | `<=>` |
274
- | `euclidean` | Euclidean distance | `<->` |
275
- | `inner_product` | Inner product / dot product | `<#>` |
276
-
277
- #### Table Structure
278
-
279
- Vectra creates tables with the following structure:
280
-
281
- ```sql
282
- CREATE TABLE documents (
283
- id TEXT PRIMARY KEY,
284
- embedding vector(384),
285
- metadata JSONB DEFAULT '{}',
286
- namespace TEXT DEFAULT '',
287
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
288
- );
289
-
290
- -- IVFFlat index for fast similarity search
291
- CREATE INDEX ON documents USING ivfflat (embedding vector_cosine_ops);
292
- ```
293
-
294
- ## Configuration Options
295
-
296
- | Option | Description | Default |
297
- |--------|-------------|---------|
298
- | `provider` | Vector database provider (`:pinecone`, `:pgvector`, `:qdrant`, `:weaviate`) | Required |
299
- | `api_key` | API key for authentication (password for pgvector) | Required* |
300
- | `environment` | Environment/region (Pinecone) | - |
301
- | `host` | Direct host URL or PostgreSQL connection URL | - |
302
- | `timeout` | Request timeout in seconds | 30 |
303
- | `open_timeout` | Connection timeout in seconds | 10 |
304
- | `max_retries` | Maximum retry attempts | 3 |
305
- | `retry_delay` | Initial retry delay in seconds | 1 |
306
- | `logger` | Logger instance for debugging | nil |
307
-
308
- *For pgvector, `api_key` is used as the PostgreSQL password.
309
-
310
- ## Error Handling
311
-
312
- Vectra provides specific error classes for different failure scenarios:
313
-
314
- ```ruby
315
- begin
316
- client.query(index: 'my-index', vector: [0.1, 0.2], top_k: 5)
317
- rescue Vectra::AuthenticationError => e
318
- puts "Authentication failed: #{e.message}"
319
- rescue Vectra::RateLimitError => e
320
- puts "Rate limited. Retry after #{e.retry_after} seconds"
321
- rescue Vectra::NotFoundError => e
322
- puts "Resource not found: #{e.message}"
323
- rescue Vectra::ValidationError => e
324
- puts "Invalid request: #{e.message}"
325
- rescue Vectra::ServerError => e
326
- puts "Server error (#{e.status_code}): #{e.message}"
327
- rescue Vectra::Error => e
328
- puts "General error: #{e.message}"
329
- end
330
- ```
331
-
332
- ## Logging
333
-
334
- Enable debug logging to see request details:
335
-
336
- ```ruby
337
- require 'logger'
338
-
339
- Vectra.configure do |config|
340
- config.provider = :pinecone
341
- config.api_key = ENV['PINECONE_API_KEY']
342
- config.environment = 'us-east-1'
343
- config.logger = Logger.new($stdout)
344
- end
196
+ git clone https://github.com/stokry/vectra.git
197
+ cd vectra
198
+ bundle install
345
199
  ```
346
200
 
347
- ## Best Practices
201
+ ### Run Tests
348
202
 
349
- ### Batch Upserts
203
+ ```bash
204
+ # All tests
205
+ bundle exec rspec
350
206
 
351
- For large datasets, batch your upserts:
207
+ # Unit tests only
208
+ bundle exec rspec spec/vectra
352
209
 
353
- ```ruby
354
- vectors = large_dataset.each_slice(100).map do |batch|
355
- client.upsert(index: 'my-index', vectors: batch)
356
- end
210
+ # Integration tests only
211
+ bundle exec rspec spec/integration
357
212
  ```
358
213
 
359
- ### Connection Reuse
214
+ ### Code Quality
360
215
 
361
- Create a single client instance and reuse it:
216
+ ```bash
217
+ # Run RuboCop linter
218
+ bundle exec rubocop
362
219
 
363
- ```ruby
364
- # Good: Reuse the client
365
- client = Vectra::Client.new(...)
366
- client.query(...)
367
- client.upsert(...)
368
-
369
- # Avoid: Creating new clients for each operation
370
- Vectra::Client.new(...).query(...)
371
- Vectra::Client.new(...).upsert(...)
220
+ # Generate documentation
221
+ bundle exec rake docs
372
222
  ```
373
223
 
374
- ### Error Recovery
224
+ ## 🤝 Contributing
375
225
 
376
- Implement retry logic for transient failures:
226
+ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
377
227
 
378
- ```ruby
379
- def query_with_retry(client, **params, retries: 3)
380
- client.query(**params)
381
- rescue Vectra::RateLimitError => e
382
- if retries > 0
383
- sleep(e.retry_after || 1)
384
- retry(retries: retries - 1)
385
- else
386
- raise
387
- end
388
- end
389
- ```
228
+ See [CHANGELOG.md](CHANGELOG.md) for the complete history of changes.
390
229
 
391
- ## Development
230
+ ## 🔗 Links
392
231
 
393
- After checking out the repo:
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)
394
236
 
395
- ```bash
396
- # Install dependencies
397
- bundle install
237
+ ## 📄 License
398
238
 
399
- # Run tests
400
- bundle exec rspec
401
-
402
- # Run linter
403
- bundle exec rubocop
239
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
404
240
 
405
- # Generate documentation
406
- bundle exec rake docs
407
- ```
241
+ ---
408
242
 
409
- ## Roadmap
410
-
411
- ### v0.1.0
412
- - ✅ Pinecone provider
413
- - ✅ Basic CRUD operations
414
- - ✅ Configuration system
415
- - ✅ Error handling with retries
416
- - ✅ Comprehensive tests
417
-
418
- ### v0.1.1 (Current)
419
- - ✅ pgvector (PostgreSQL) provider
420
- - ✅ Multiple similarity metrics (cosine, euclidean, inner product)
421
- - ✅ Namespace support for pgvector
422
- - ✅ IVFFlat index creation
423
-
424
- ### v0.2.0
425
- - 🚧 Qdrant provider
426
- - 🚧 Enhanced error handling
427
- - 🚧 Connection pooling
428
-
429
- ### v0.3.0
430
- - 🚧 Weaviate provider
431
- - 🚧 Batch operations
243
+ **Built with ❤️ by the Vectra community**
432
244
  - 🚧 Performance optimizations
433
245
 
434
246
  ### v1.0.0
data/Rakefile CHANGED
@@ -34,7 +34,7 @@ task :changelog do
34
34
  end
35
35
 
36
36
  desc "Bump version to VERSION"
37
- task :bump_version, [:version] do |t, args|
37
+ task :bump_version, [:version] do |_t, args|
38
38
  version = args[:version]
39
39
  raise "Version required: rake bump_version[1.2.3]" unless version
40
40
 
data/docs/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "jekyll", "~> 4.4"
6
+ gem "jekyll-feed", "~> 0.12"
7
+ gem "jekyll-seo-tag"
8
+ gem "jekyll-sitemap"
9
+ gem "minima", "~> 2.5"
10
+ gem "webrick", "~> 1.8"
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/