vectra-client 0.2.2 → 0.3.1
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/.rubocop.yml +77 -37
- data/CHANGELOG.md +85 -6
- data/README.md +56 -203
- data/docs/Gemfile +0 -1
- data/docs/_config.yml +19 -2
- data/docs/_layouts/default.html +6 -6
- data/docs/_layouts/home.html +183 -29
- data/docs/_layouts/page.html +81 -18
- data/docs/assets/style.css +806 -174
- data/docs/examples/index.md +46 -24
- data/docs/guides/monitoring.md +860 -0
- data/docs/guides/performance.md +200 -0
- data/docs/guides/runbooks/cache-issues.md +267 -0
- data/docs/guides/runbooks/high-error-rate.md +152 -0
- data/docs/guides/runbooks/high-latency.md +287 -0
- data/docs/guides/runbooks/pool-exhausted.md +216 -0
- data/docs/index.md +22 -38
- data/docs/providers/index.md +58 -39
- data/lib/vectra/batch.rb +148 -0
- data/lib/vectra/cache.rb +261 -0
- data/lib/vectra/circuit_breaker.rb +336 -0
- data/lib/vectra/client.rb +2 -0
- data/lib/vectra/configuration.rb +6 -1
- data/lib/vectra/health_check.rb +254 -0
- data/lib/vectra/instrumentation/honeybadger.rb +128 -0
- data/lib/vectra/instrumentation/sentry.rb +117 -0
- data/lib/vectra/logging.rb +242 -0
- data/lib/vectra/pool.rb +256 -0
- data/lib/vectra/rate_limiter.rb +304 -0
- data/lib/vectra/streaming.rb +153 -0
- data/lib/vectra/version.rb +1 -1
- data/lib/vectra.rb +8 -0
- metadata +31 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8a0a1971b5aaa4e71cce684542a9baa8b5c43a47b5e9faa8231bb3dbf5ebe2d1
|
|
4
|
+
data.tar.gz: d80c394c3cfbc4b94e42e649c26333238feb0e946570e6cb918c13c73d491d37
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e422697e86cd942b25d49b88a15254789754dea5646fe5407989c4915f4bb4fc3f36a84f19d38a2409bf684c7ce67bde02d012590e909cb980777e35beabf1c1
|
|
7
|
+
data.tar.gz: 5ef94bacfffe1ce6f67faeaa92febf739b498a14675661612058104dc7d1119e59dc0284a1c32338b08cd73c8cc4aac63e0be249c8250e9d78699dd45eb93b3d
|
data/.rubocop.yml
CHANGED
|
@@ -14,9 +14,11 @@ AllCops:
|
|
|
14
14
|
|
|
15
15
|
# Layout
|
|
16
16
|
Layout/LineLength:
|
|
17
|
-
Max:
|
|
17
|
+
Max: 185
|
|
18
18
|
AllowedPatterns:
|
|
19
19
|
- '\A\s*#' # Allow long comment lines
|
|
20
|
+
Exclude:
|
|
21
|
+
- 'vectra.gemspec'
|
|
20
22
|
|
|
21
23
|
Layout/MultilineMethodCallIndentation:
|
|
22
24
|
EnforcedStyle: indented
|
|
@@ -28,7 +30,7 @@ Metrics/BlockLength:
|
|
|
28
30
|
- 'vectra.gemspec'
|
|
29
31
|
- 'Rakefile'
|
|
30
32
|
- 'benchmarks/**/*'
|
|
31
|
-
|
|
33
|
+
AllowedMethods:
|
|
32
34
|
- 'included'
|
|
33
35
|
- 'class_methods'
|
|
34
36
|
|
|
@@ -82,10 +84,10 @@ Style/FrozenStringLiteralComment:
|
|
|
82
84
|
EnforcedStyle: always
|
|
83
85
|
|
|
84
86
|
Style/SymbolArray:
|
|
85
|
-
|
|
87
|
+
Enabled: false
|
|
86
88
|
|
|
87
89
|
Style/WordArray:
|
|
88
|
-
|
|
90
|
+
Enabled: false
|
|
89
91
|
|
|
90
92
|
Style/TrailingCommaInArrayLiteral:
|
|
91
93
|
EnforcedStyleForMultiline: no_comma
|
|
@@ -96,6 +98,9 @@ Style/TrailingCommaInHashLiteral:
|
|
|
96
98
|
Style/TrailingCommaInArguments:
|
|
97
99
|
EnforcedStyleForMultiline: no_comma
|
|
98
100
|
|
|
101
|
+
Style/MapIntoArray:
|
|
102
|
+
Enabled: false
|
|
103
|
+
|
|
99
104
|
# Naming
|
|
100
105
|
Naming/MethodParameterName:
|
|
101
106
|
AllowedNames:
|
|
@@ -103,6 +108,13 @@ Naming/MethodParameterName:
|
|
|
103
108
|
- to
|
|
104
109
|
- db
|
|
105
110
|
- io
|
|
111
|
+
- n
|
|
112
|
+
|
|
113
|
+
Naming/PredicatePrefix:
|
|
114
|
+
Enabled: false # Allow has_vector DSL method
|
|
115
|
+
|
|
116
|
+
Naming/MemoizedInstanceVariableName:
|
|
117
|
+
Enabled: false # Allow descriptive names
|
|
106
118
|
|
|
107
119
|
# Lint
|
|
108
120
|
Lint/MissingSuper:
|
|
@@ -111,12 +123,15 @@ Lint/MissingSuper:
|
|
|
111
123
|
Lint/ScriptPermission:
|
|
112
124
|
Enabled: false
|
|
113
125
|
|
|
126
|
+
Lint/RedundantDirGlobSort:
|
|
127
|
+
Enabled: false
|
|
128
|
+
|
|
114
129
|
# RSpec specific
|
|
115
130
|
RSpec/ExampleLength:
|
|
116
|
-
Max:
|
|
131
|
+
Max: 25
|
|
117
132
|
|
|
118
133
|
RSpec/MultipleExpectations:
|
|
119
|
-
Max:
|
|
134
|
+
Max: 10
|
|
120
135
|
|
|
121
136
|
RSpec/MultipleMemoizedHelpers:
|
|
122
137
|
Max: 10
|
|
@@ -125,9 +140,7 @@ RSpec/NestedGroups:
|
|
|
125
140
|
Max: 5
|
|
126
141
|
|
|
127
142
|
RSpec/DescribeClass:
|
|
128
|
-
Enabled:
|
|
129
|
-
Exclude:
|
|
130
|
-
- 'spec/integration/**/*'
|
|
143
|
+
Enabled: false
|
|
131
144
|
|
|
132
145
|
RSpec/ContextWording:
|
|
133
146
|
Enabled: false
|
|
@@ -144,60 +157,87 @@ RSpec/VerifiedDoubles:
|
|
|
144
157
|
RSpec/MultipleDescribes:
|
|
145
158
|
Enabled: false
|
|
146
159
|
|
|
147
|
-
RSpec/
|
|
148
|
-
Enabled: false
|
|
160
|
+
RSpec/LeadingSubject:
|
|
161
|
+
Enabled: false
|
|
149
162
|
|
|
150
|
-
|
|
151
|
-
|
|
163
|
+
RSpec/NamedSubject:
|
|
164
|
+
Enabled: false
|
|
165
|
+
|
|
166
|
+
RSpec/SubjectStub:
|
|
167
|
+
Enabled: false
|
|
168
|
+
|
|
169
|
+
RSpec/DescribedClass:
|
|
152
170
|
Enabled: false
|
|
153
171
|
|
|
154
172
|
# Gemspec
|
|
155
173
|
Gemspec/DevelopmentDependencies:
|
|
156
174
|
Enabled: false
|
|
157
175
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
Enabled: false # Allow descriptive names
|
|
176
|
+
Gemspec/OrderedDependencies:
|
|
177
|
+
Enabled: false
|
|
161
178
|
|
|
162
|
-
#
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
Exclude:
|
|
166
|
-
- 'vectra.gemspec'
|
|
179
|
+
# Capybara - disable all (causes errors and not needed for this project)
|
|
180
|
+
Capybara/RSpec/PredicateMatcher:
|
|
181
|
+
Enabled: false
|
|
167
182
|
|
|
168
|
-
|
|
169
|
-
Style/SymbolArray:
|
|
183
|
+
Capybara/CurrentPathExpectation:
|
|
170
184
|
Enabled: false
|
|
171
185
|
|
|
172
|
-
|
|
186
|
+
Capybara/MatchStyle:
|
|
173
187
|
Enabled: false
|
|
174
188
|
|
|
175
|
-
|
|
189
|
+
Capybara/NegationMatcher:
|
|
176
190
|
Enabled: false
|
|
177
191
|
|
|
178
|
-
|
|
192
|
+
Capybara/SpecificActions:
|
|
179
193
|
Enabled: false
|
|
180
194
|
|
|
181
|
-
|
|
195
|
+
Capybara/SpecificFinders:
|
|
182
196
|
Enabled: false
|
|
183
197
|
|
|
184
|
-
|
|
185
|
-
|
|
198
|
+
Capybara/SpecificMatcher:
|
|
199
|
+
Enabled: false
|
|
186
200
|
|
|
187
|
-
|
|
188
|
-
|
|
201
|
+
Capybara/VisibilityMatcher:
|
|
202
|
+
Enabled: false
|
|
189
203
|
|
|
190
|
-
|
|
204
|
+
# FactoryBot - not used in this project
|
|
205
|
+
FactoryBot/AttributeDefinedStatically:
|
|
191
206
|
Enabled: false
|
|
192
207
|
|
|
193
|
-
|
|
208
|
+
FactoryBot/ConsistentParenthesesStyle:
|
|
194
209
|
Enabled: false
|
|
195
210
|
|
|
196
|
-
|
|
211
|
+
FactoryBot/CreateList:
|
|
197
212
|
Enabled: false
|
|
198
213
|
|
|
199
|
-
|
|
200
|
-
Enabled: false
|
|
214
|
+
FactoryBot/FactoryClassName:
|
|
215
|
+
Enabled: false
|
|
201
216
|
|
|
202
|
-
|
|
217
|
+
FactoryBot/FactoryNameStyle:
|
|
218
|
+
Enabled: false
|
|
219
|
+
|
|
220
|
+
FactoryBot/SyntaxMethods:
|
|
221
|
+
Enabled: false
|
|
222
|
+
|
|
223
|
+
# RSpecRails - not used in this project
|
|
224
|
+
RSpecRails/AvoidSetupHook:
|
|
225
|
+
Enabled: false
|
|
226
|
+
|
|
227
|
+
RSpecRails/HaveHttpStatus:
|
|
228
|
+
Enabled: false
|
|
229
|
+
|
|
230
|
+
RSpecRails/HttpStatus:
|
|
231
|
+
Enabled: false
|
|
232
|
+
|
|
233
|
+
RSpecRails/InferredSpecType:
|
|
234
|
+
Enabled: false
|
|
235
|
+
|
|
236
|
+
RSpecRails/MinitestAssertions:
|
|
237
|
+
Enabled: false
|
|
238
|
+
|
|
239
|
+
RSpecRails/NegationBeValid:
|
|
240
|
+
Enabled: false
|
|
241
|
+
|
|
242
|
+
RSpecRails/TravelAround:
|
|
203
243
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,87 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Proactive Rate Limiting** (`Vectra::RateLimiter`)
|
|
13
|
+
- Token bucket algorithm for smooth rate limiting
|
|
14
|
+
- Burst support for handling traffic spikes
|
|
15
|
+
- Per-provider rate limiter registry
|
|
16
|
+
- `RateLimitedClient` wrapper for automatic throttling
|
|
17
|
+
- Prevents API rate limit errors before they occur
|
|
18
|
+
|
|
19
|
+
- **Structured JSON Logging** (`Vectra::JsonLogger`)
|
|
20
|
+
- Machine-readable JSON log format
|
|
21
|
+
- Automatic operation logging via instrumentation
|
|
22
|
+
- Custom metadata support
|
|
23
|
+
- Integration with standard Ruby Logger via `JsonFormatter`
|
|
24
|
+
- Log levels: debug, info, warn, error, fatal
|
|
25
|
+
|
|
26
|
+
- **Health Check Functionality** (`Vectra::HealthCheck`)
|
|
27
|
+
- Built-in `client.health_check` method
|
|
28
|
+
- Connectivity and latency testing
|
|
29
|
+
- Optional index statistics inclusion
|
|
30
|
+
- Pool health checking for pgvector
|
|
31
|
+
- `AggregateHealthCheck` for multi-provider setups
|
|
32
|
+
- JSON-serializable results
|
|
33
|
+
|
|
34
|
+
- **Error Tracking Integrations**
|
|
35
|
+
- Sentry adapter with breadcrumbs, context, and fingerprinting
|
|
36
|
+
- Honeybadger adapter with severity tags and configurable notifications
|
|
37
|
+
- Automatic error context and grouping
|
|
38
|
+
|
|
39
|
+
- **Circuit Breaker Pattern** (`Vectra::CircuitBreaker`)
|
|
40
|
+
- Three-state circuit (closed, open, half-open)
|
|
41
|
+
- Automatic failover with fallback support
|
|
42
|
+
- Per-provider circuit registry
|
|
43
|
+
- Thread-safe implementation
|
|
44
|
+
- Configurable failure/success thresholds
|
|
45
|
+
|
|
46
|
+
## [0.3.0] - 2025-01-08
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
|
|
50
|
+
- **Async Batch Operations** (`Vectra::Batch`)
|
|
51
|
+
- Concurrent batch upsert with configurable worker count
|
|
52
|
+
- Automatic chunking of large vector sets
|
|
53
|
+
- Async delete and fetch operations
|
|
54
|
+
- Error aggregation and partial success handling
|
|
55
|
+
|
|
56
|
+
- **Streaming Results** (`Vectra::Streaming`)
|
|
57
|
+
- Lazy enumeration for large query result sets
|
|
58
|
+
- Memory-efficient processing with automatic pagination
|
|
59
|
+
- `query_each` and `query_stream` methods
|
|
60
|
+
- Duplicate detection across pages
|
|
61
|
+
|
|
62
|
+
- **Caching Layer** (`Vectra::Cache` and `Vectra::CachedClient`)
|
|
63
|
+
- In-memory LRU cache with configurable TTL
|
|
64
|
+
- Transparent caching for query and fetch operations
|
|
65
|
+
- Index-level cache invalidation
|
|
66
|
+
- Thread-safe with mutex synchronization
|
|
67
|
+
|
|
68
|
+
- **Connection Pool with Warmup** (`Vectra::Pool`)
|
|
69
|
+
- Configurable pool size and checkout timeout
|
|
70
|
+
- Connection warmup at startup
|
|
71
|
+
- Health checking and automatic reconnection
|
|
72
|
+
- Pool statistics and monitoring
|
|
73
|
+
|
|
74
|
+
- **CI Benchmark Integration**
|
|
75
|
+
- Weekly scheduled benchmark runs
|
|
76
|
+
- PostgreSQL (pgvector) integration in CI
|
|
77
|
+
- Benchmark result artifact storage
|
|
78
|
+
|
|
79
|
+
### Configuration
|
|
80
|
+
|
|
81
|
+
New configuration options:
|
|
82
|
+
- `cache_enabled` - Enable/disable caching (default: false)
|
|
83
|
+
- `cache_ttl` - Cache time-to-live in seconds (default: 300)
|
|
84
|
+
- `cache_max_size` - Maximum cache entries (default: 1000)
|
|
85
|
+
- `async_concurrency` - Concurrent workers for batch ops (default: 4)
|
|
86
|
+
|
|
87
|
+
### Dependencies
|
|
88
|
+
|
|
89
|
+
- Added `concurrent-ruby ~> 1.2` for thread-safe operations
|
|
90
|
+
|
|
10
91
|
## [0.2.1] - 2025-01-08
|
|
11
92
|
|
|
12
93
|
### Added
|
|
@@ -109,16 +190,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
109
190
|
|
|
110
191
|
## Planned
|
|
111
192
|
|
|
112
|
-
### [0.
|
|
193
|
+
### [0.4.0]
|
|
113
194
|
|
|
114
195
|
- Weaviate provider implementation
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
- Async operations support
|
|
196
|
+
- Additional similarity metrics
|
|
197
|
+
- Vector quantization support
|
|
118
198
|
|
|
119
199
|
### [1.0.0]
|
|
120
200
|
|
|
121
|
-
- Rails integration
|
|
122
|
-
- ActiveRecord-like DSL for vector models
|
|
123
201
|
- Background job integration (Sidekiq, GoodJob)
|
|
124
202
|
- Production-ready with full documentation
|
|
203
|
+
- Performance monitoring dashboard
|
data/README.md
CHANGED
|
@@ -1,268 +1,121 @@
|
|
|
1
|
-
# Vectra
|
|
1
|
+
# Vectra
|
|
2
2
|
|
|
3
3
|
[](https://rubygems.org/gems/vectra-client)
|
|
4
4
|
[](https://github.com/stokry/vectra/actions)
|
|
5
5
|
[](https://codecov.io/gh/stokry/vectra)
|
|
6
|
-
[](https://github.com/rubocop/rubocop)
|
|
7
6
|
[](https://opensource.org/licenses/MIT)
|
|
8
|
-
[](CODE_OF_CONDUCT.md)
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
**A unified Ruby client for vector databases.** Write once, switch providers seamlessly.
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
📖 **Documentation:** [vectra-docs.netlify.app](https://vectra-docs.netlify.app/)
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
## Supported Providers
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
| Provider | Type | Status |
|
|
15
|
+
|----------|------|--------|
|
|
16
|
+
| **Pinecone** | Managed Cloud | ✅ Supported |
|
|
17
|
+
| **Qdrant** | Open Source | ✅ Supported |
|
|
18
|
+
| **Weaviate** | Open Source | ✅ Supported |
|
|
19
|
+
| **pgvector** | PostgreSQL | ✅ Supported |
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
43
|
-
|
|
44
|
-
Add this line to your application's Gemfile:
|
|
21
|
+
## Installation
|
|
45
22
|
|
|
46
23
|
```ruby
|
|
47
24
|
gem 'vectra-client'
|
|
48
25
|
```
|
|
49
26
|
|
|
50
|
-
Then execute:
|
|
51
|
-
|
|
52
27
|
```bash
|
|
53
28
|
bundle install
|
|
54
29
|
```
|
|
55
30
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
gem install vectra-client
|
|
60
|
-
```
|
|
61
|
-
|
|
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
|
|
70
|
-
|
|
71
|
-
### Provider-Specific Setup
|
|
72
|
-
|
|
73
|
-
Each vector database may require additional dependencies:
|
|
74
|
-
|
|
75
|
-
**PostgreSQL + pgvector:**
|
|
76
|
-
```ruby
|
|
77
|
-
gem 'pg', '~> 1.5'
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
**For Instrumentation:**
|
|
81
|
-
```ruby
|
|
82
|
-
gem 'dogstatsd-ruby' # Datadog
|
|
83
|
-
gem 'newrelic_rpm' # New Relic
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## 🚀 Quick Start
|
|
87
|
-
|
|
88
|
-
### 1. Initialize a Client
|
|
31
|
+
## Quick Start
|
|
89
32
|
|
|
90
33
|
```ruby
|
|
91
34
|
require 'vectra'
|
|
92
35
|
|
|
93
|
-
#
|
|
36
|
+
# Initialize client (works with any provider)
|
|
94
37
|
client = Vectra::Client.new(
|
|
95
38
|
provider: :pinecone,
|
|
96
39
|
api_key: ENV['PINECONE_API_KEY'],
|
|
97
40
|
environment: 'us-west-4'
|
|
98
41
|
)
|
|
99
42
|
|
|
100
|
-
#
|
|
101
|
-
client = Vectra::Client.new(
|
|
102
|
-
provider: :pgvector,
|
|
103
|
-
database: 'my_app_production',
|
|
104
|
-
host: 'localhost'
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
# Qdrant
|
|
108
|
-
client = Vectra::Client.new(
|
|
109
|
-
provider: :qdrant,
|
|
110
|
-
host: 'http://localhost:6333'
|
|
111
|
-
)
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### 2. Upsert Vectors
|
|
115
|
-
|
|
116
|
-
```ruby
|
|
43
|
+
# Upsert vectors
|
|
117
44
|
client.upsert(
|
|
118
45
|
vectors: [
|
|
119
|
-
{
|
|
120
|
-
|
|
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
|
-
}
|
|
46
|
+
{ id: 'doc-1', values: [0.1, 0.2, 0.3], metadata: { title: 'Hello' } },
|
|
47
|
+
{ id: 'doc-2', values: [0.4, 0.5, 0.6], metadata: { title: 'World' } }
|
|
129
48
|
]
|
|
130
49
|
)
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### 3. Search for Similar Vectors
|
|
134
|
-
|
|
135
|
-
```ruby
|
|
136
|
-
results = client.query(
|
|
137
|
-
vector: [0.1, 0.2, 0.3],
|
|
138
|
-
top_k: 5
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
results.matches.each do |match|
|
|
142
|
-
puts "#{match['id']}: #{match['score']}"
|
|
143
|
-
puts " Metadata: #{match['metadata']}"
|
|
144
|
-
end
|
|
145
|
-
```
|
|
146
50
|
|
|
147
|
-
|
|
51
|
+
# Search
|
|
52
|
+
results = client.query(vector: [0.1, 0.2, 0.3], top_k: 5)
|
|
53
|
+
results.each { |match| puts "#{match.id}: #{match.score}" }
|
|
148
54
|
|
|
149
|
-
|
|
55
|
+
# Delete
|
|
150
56
|
client.delete(ids: ['doc-1', 'doc-2'])
|
|
151
57
|
```
|
|
152
58
|
|
|
153
|
-
##
|
|
154
|
-
|
|
155
|
-
For complete documentation, examples, and guides, visit:
|
|
59
|
+
## Provider Examples
|
|
156
60
|
|
|
157
|
-
|
|
61
|
+
```ruby
|
|
62
|
+
# Pinecone
|
|
63
|
+
client = Vectra.pinecone(api_key: ENV['PINECONE_API_KEY'], environment: 'us-west-4')
|
|
158
64
|
|
|
159
|
-
|
|
65
|
+
# Qdrant (local)
|
|
66
|
+
client = Vectra.qdrant(host: 'http://localhost:6333')
|
|
160
67
|
|
|
161
|
-
|
|
162
|
-
|
|
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/)
|
|
68
|
+
# Qdrant (cloud)
|
|
69
|
+
client = Vectra.qdrant(host: 'https://your-cluster.qdrant.io', api_key: ENV['QDRANT_API_KEY'])
|
|
171
70
|
|
|
172
|
-
|
|
71
|
+
# Weaviate
|
|
72
|
+
client = Vectra.weaviate(host: 'http://localhost:8080', api_key: ENV['WEAVIATE_API_KEY'])
|
|
173
73
|
|
|
174
|
-
|
|
74
|
+
# pgvector (PostgreSQL)
|
|
75
|
+
client = Vectra.pgvector(connection_url: 'postgres://user:pass@localhost/mydb')
|
|
76
|
+
```
|
|
175
77
|
|
|
176
|
-
|
|
177
|
-
Build intelligent search that understands meaning, not just keywords. Perfect for product discovery, knowledge base search, and content recommendation.
|
|
78
|
+
## Features
|
|
178
79
|
|
|
179
|
-
|
|
180
|
-
|
|
80
|
+
- **Provider Agnostic** - Switch providers with one line change
|
|
81
|
+
- **Production Ready** - Ruby 3.2+, 95%+ test coverage
|
|
82
|
+
- **Resilient** - Retry logic with exponential backoff
|
|
83
|
+
- **Observable** - Datadog & New Relic instrumentation
|
|
84
|
+
- **Rails Ready** - ActiveRecord integration with `has_vector` DSL
|
|
181
85
|
|
|
182
|
-
|
|
183
|
-
Identify and deduplicate similar items across your dataset using vector similarity.
|
|
86
|
+
## Rails Integration
|
|
184
87
|
|
|
185
|
-
|
|
186
|
-
|
|
88
|
+
```ruby
|
|
89
|
+
class Document < ApplicationRecord
|
|
90
|
+
include Vectra::ActiveRecord
|
|
187
91
|
|
|
188
|
-
|
|
92
|
+
has_vector :embedding,
|
|
93
|
+
provider: :qdrant,
|
|
94
|
+
index: 'documents',
|
|
95
|
+
dimension: 1536
|
|
96
|
+
end
|
|
189
97
|
|
|
98
|
+
# Auto-indexes on save
|
|
99
|
+
doc = Document.create!(title: 'Hello', embedding: [0.1, 0.2, ...])
|
|
190
100
|
|
|
191
|
-
|
|
101
|
+
# Search
|
|
102
|
+
Document.vector_search(embedding: query_vector, limit: 10)
|
|
103
|
+
```
|
|
192
104
|
|
|
193
|
-
|
|
105
|
+
## Development
|
|
194
106
|
|
|
195
107
|
```bash
|
|
196
108
|
git clone https://github.com/stokry/vectra.git
|
|
197
109
|
cd vectra
|
|
198
110
|
bundle install
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### Run Tests
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
# All tests
|
|
205
111
|
bundle exec rspec
|
|
206
|
-
|
|
207
|
-
# Unit tests only
|
|
208
|
-
bundle exec rspec spec/vectra
|
|
209
|
-
|
|
210
|
-
# Integration tests only
|
|
211
|
-
bundle exec rspec spec/integration
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### Code Quality
|
|
215
|
-
|
|
216
|
-
```bash
|
|
217
|
-
# Run RuboCop linter
|
|
218
112
|
bundle exec rubocop
|
|
219
|
-
|
|
220
|
-
# Generate documentation
|
|
221
|
-
bundle exec rake docs
|
|
222
113
|
```
|
|
223
114
|
|
|
224
|
-
## 🤝 Contributing
|
|
225
|
-
|
|
226
|
-
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
227
|
-
|
|
228
|
-
See [CHANGELOG.md](CHANGELOG.md) for the complete history of changes.
|
|
229
|
-
|
|
230
|
-
## 🔗 Links
|
|
231
|
-
|
|
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)
|
|
236
|
-
|
|
237
|
-
## 📄 License
|
|
238
|
-
|
|
239
|
-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
240
|
-
|
|
241
|
-
---
|
|
242
|
-
|
|
243
|
-
**Built with ❤️ by the Vectra community**
|
|
244
|
-
- 🚧 Performance optimizations
|
|
245
|
-
|
|
246
|
-
### v1.0.0
|
|
247
|
-
- 🚧 Rails integration
|
|
248
|
-
- 🚧 ActiveRecord-like DSL
|
|
249
|
-
- 🚧 Background job support
|
|
250
|
-
- 🚧 Full documentation
|
|
251
|
-
|
|
252
115
|
## Contributing
|
|
253
116
|
|
|
254
|
-
Bug reports and pull requests
|
|
255
|
-
|
|
256
|
-
1. Fork it
|
|
257
|
-
2. Create your feature branch (`git checkout -b feature/my-new-feature`)
|
|
258
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
259
|
-
4. Push to the branch (`git push origin feature/my-new-feature`)
|
|
260
|
-
5. Create a new Pull Request
|
|
117
|
+
Bug reports and pull requests welcome at [github.com/stokry/vectra](https://github.com/stokry/vectra).
|
|
261
118
|
|
|
262
119
|
## License
|
|
263
120
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
## Acknowledgments
|
|
267
|
-
|
|
268
|
-
Inspired by the simplicity of Ruby database gems and the need for a unified vector database interface.
|
|
121
|
+
MIT License - see [LICENSE](LICENSE) file.
|
data/docs/Gemfile
CHANGED
data/docs/_config.yml
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
title: Vectra Documentation
|
|
2
|
-
description:
|
|
3
|
-
|
|
2
|
+
description: A unified Ruby client for vector databases. Build AI-powered search, RAG applications, and recommendation systems.
|
|
3
|
+
url: "https://vectra-docs.netlify.app"
|
|
4
|
+
baseurl: ""
|
|
5
|
+
|
|
4
6
|
plugins:
|
|
5
7
|
- jekyll-feed
|
|
6
8
|
- jekyll-sitemap
|
|
9
|
+
- jekyll-seo-tag
|
|
7
10
|
|
|
8
11
|
markdown: kramdown
|
|
9
12
|
highlighter: rouge
|
|
10
13
|
|
|
14
|
+
kramdown:
|
|
15
|
+
syntax_highlighter: rouge
|
|
16
|
+
syntax_highlighter_opts:
|
|
17
|
+
block:
|
|
18
|
+
line_numbers: false
|
|
19
|
+
|
|
11
20
|
exclude:
|
|
12
21
|
- Gemfile
|
|
13
22
|
- Gemfile.lock
|
|
@@ -16,5 +25,13 @@ exclude:
|
|
|
16
25
|
- vendor/cache/
|
|
17
26
|
- vendor/gems/
|
|
18
27
|
- vendor/ruby/
|
|
28
|
+
- _site/
|
|
19
29
|
|
|
20
30
|
permalink: /:categories/:title/
|
|
31
|
+
|
|
32
|
+
defaults:
|
|
33
|
+
- scope:
|
|
34
|
+
path: ""
|
|
35
|
+
type: "pages"
|
|
36
|
+
values:
|
|
37
|
+
layout: "page"
|