pinecone 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pinecone/client.rb +4 -0
- data/lib/pinecone/index.rb +5 -0
- data/lib/pinecone/vector.rb +32 -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: 1df7356e27643581b1acd0417647d0e83cb53d3268357b083c13188f96ee0377
|
4
|
+
data.tar.gz: 561f46ebf941d8f8652787b2034038bbab21303080f5a6f281463f9f1a2669aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa0470d86d105b2f33e16d0d5a5376cb5e09641ec825faddd9d9cc5b39426b15fcc0d382b3586625e26032d4a48593179f706e7e9276918fa666f5739c35a6c6
|
7
|
+
data.tar.gz: a06fddd61f295a1ba89c55180487ed89f9142fce8161f41c5aa5861190611c93303b581e971cfaae45f877060c2ab72b12e147eddc7d49329d2038fd7e1cb3bf
|
data/lib/pinecone/client.rb
CHANGED
data/lib/pinecone/index.rb
CHANGED
@@ -28,6 +28,11 @@ module Pinecone
|
|
28
28
|
self.class.delete("/databases/#{index_name}", options)
|
29
29
|
end
|
30
30
|
|
31
|
+
def configure(index_name, body)
|
32
|
+
payload = options.merge(body: body.to_json)
|
33
|
+
self.class.patch("/databases/#{index_name}", payload)
|
34
|
+
end
|
35
|
+
|
31
36
|
def options
|
32
37
|
{
|
33
38
|
headers: @headers,
|
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,35 @@ 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
|
+
def describe_index_stats(filter: {})
|
59
|
+
payload = if filter.empty?
|
60
|
+
options
|
61
|
+
else
|
62
|
+
options.merge(body: {filter: filter}.to_json)
|
63
|
+
end
|
64
|
+
self.class.post('/describe_index_stats', payload)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
49
68
|
def options
|
50
69
|
{
|
51
70
|
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.5
|
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: 1.9.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.9.0
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: dotenv
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|