pinecone 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pinecone/vector.rb +23 -13
- data/lib/pinecone/version.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ba29ca8e87743d1fb9641ecdd722ac1c18cc55f06d0314dd688d0474da48257
|
4
|
+
data.tar.gz: 29660db1e94027e9701999487c022f8b7ff281881e4166db05d972e55d054630
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad82b573c181757f03ea1df9f7f3343561d50899e884177ea6924941c361dce337e32288a66c2f47828fe39ac7ca14753550e005c7ae7c47448f31aa4c684da0
|
7
|
+
data.tar.gz: beee5be5eff743e68e65d8df4ea51b4f9dceeec1f761ff08506b8357787f0dc1c65e68da0ca369ed51ae6ea3ed838fd9134d567b5223b4cf6e44cc071a79a0f5
|
data/lib/pinecone/vector.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require "pinecone/vector/query"
|
2
|
+
require "pinecone/vector/filter"
|
3
|
+
require "pinecone/vector/sparse_vector"
|
4
|
+
|
1
5
|
module Pinecone
|
2
6
|
class Vector
|
3
7
|
include HTTParty
|
@@ -22,10 +26,8 @@ module Pinecone
|
|
22
26
|
self.class.post('/vectors/delete', payload)
|
23
27
|
end
|
24
28
|
|
25
|
-
# This requires manually building the query string to unbundle ids
|
26
29
|
def fetch(namespace: "", ids: [])
|
27
|
-
|
28
|
-
query_string = "namespace=#{namespace}&#{ids_query_string}"
|
30
|
+
query_string = URI.encode_www_form({ namespace: namespace, ids: ids})
|
29
31
|
self.class.get("/vectors/fetch?#{query_string}", options)
|
30
32
|
end
|
31
33
|
|
@@ -34,18 +36,26 @@ module Pinecone
|
|
34
36
|
self.class.post('/vectors/upsert', payload)
|
35
37
|
end
|
36
38
|
|
37
|
-
def query(
|
38
|
-
|
39
|
-
|
40
|
-
"includeValues": include_values,
|
41
|
-
"includeMetadata": include_metadata,
|
42
|
-
"topK": top_k,
|
43
|
-
"vector": vector,
|
44
|
-
}.to_json
|
45
|
-
payload = options.merge(body: inputs)
|
39
|
+
def query(query)
|
40
|
+
object = query.is_a?(Pinecone::Vector::Query) ? query : Pinecone::Vector::Query.new(query)
|
41
|
+
payload = options.merge(body: object.to_json)
|
46
42
|
self.class.post('/query', payload)
|
47
43
|
end
|
48
|
-
|
44
|
+
|
45
|
+
def update(id:, values: [], sparse_values: {indices: [], values: []}, set_metadata: {}, namespace: "")
|
46
|
+
inputs = {
|
47
|
+
"id": id
|
48
|
+
}
|
49
|
+
inputs["values"] = values unless values.empty?
|
50
|
+
inputs["sparseValues"] = sparse_values unless sparse_values[:indices].empty? || sparse_values[:values].empty?
|
51
|
+
inputs["setMetadata"] = set_metadata unless set_metadata.empty?
|
52
|
+
inputs["namespace"] = namespace unless namespace.empty?
|
53
|
+
|
54
|
+
payload = options.merge(body: inputs.to_json)
|
55
|
+
self.class.post('/vectors/update', payload)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
49
59
|
def options
|
50
60
|
{
|
51
61
|
headers: @headers,
|
data/lib/pinecone/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pinecone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Carleton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.21.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dry-struct
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.5.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.5.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dry-validation
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: dotenv
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|