pgvector 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +12 -0
- data/lib/pgvector/version.rb +1 -1
- data/lib/sequel/plugins/pgvector.rb +8 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7485ea4be0d5be0177a972db911c696daf3438a661ddac61b08f4e8b2da3ac51
|
4
|
+
data.tar.gz: 2532ef79f5db88aecb681d9455e38f3e5fc1d30bde015d0a1e9daaa9fe82635e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be40e4c3e16dd904a200115794a8ffaa850b40c5055330bd873ec7a707164a53b29d22040defbb4dd8a9cff597d4e1ad5c659d37a580ccc201ce30a9eb17fef9
|
7
|
+
data.tar.gz: f5d36289b043d987920911ab08d85d7d1066039f84dcc2a24436701c06b246adcb8fd3c32e3f76f3e1604001403574c14818f91a64357ce4ebd675458e57184c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -29,6 +29,12 @@ Or check out some examples:
|
|
29
29
|
|
30
30
|
## pg
|
31
31
|
|
32
|
+
Enable the extension
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
conn.exec("CREATE EXTENSION IF NOT EXISTS vector")
|
36
|
+
```
|
37
|
+
|
32
38
|
Register the vector type with your connection
|
33
39
|
|
34
40
|
```ruby
|
@@ -52,6 +58,12 @@ conn.exec_params("SELECT * FROM items ORDER BY embedding <-> $1 LIMIT 5", [embed
|
|
52
58
|
|
53
59
|
## Sequel
|
54
60
|
|
61
|
+
Enable the extension
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
DB.run("CREATE EXTENSION IF NOT EXISTS vector")
|
65
|
+
```
|
66
|
+
|
55
67
|
Create a table
|
56
68
|
|
57
69
|
```ruby
|
data/lib/pgvector/version.rb
CHANGED
@@ -8,12 +8,10 @@ module Sequel
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
module
|
12
|
-
attr_accessor :vector_columns
|
13
|
-
|
11
|
+
module DatasetMethods
|
14
12
|
def nearest_neighbors(column, value, distance:)
|
15
13
|
value = ::Pgvector.encode(value) unless value.is_a?(String)
|
16
|
-
quoted_column =
|
14
|
+
quoted_column = quote_identifier(column)
|
17
15
|
distance = distance.to_s
|
18
16
|
|
19
17
|
operator =
|
@@ -41,6 +39,12 @@ module Sequel
|
|
41
39
|
.exclude(column => nil)
|
42
40
|
.order(Sequel.lit(order, value))
|
43
41
|
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module ClassMethods
|
45
|
+
attr_accessor :vector_columns
|
46
|
+
|
47
|
+
Sequel::Plugins.def_dataset_methods(self, :nearest_neighbors)
|
44
48
|
|
45
49
|
Plugins.inherited_instance_variables(self, :@vector_columns => :dup)
|
46
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgvector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: andrew@ankane.org
|