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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b17e749b07052d08df706ff8f60ca5a40c2bdb752a19662c15ebab0745cf813
4
- data.tar.gz: f0789949de4ceab10e7a195798aa0ebc6d77dd9c32f049cab27ff82f13c182fc
3
+ metadata.gz: 1df7356e27643581b1acd0417647d0e83cb53d3268357b083c13188f96ee0377
4
+ data.tar.gz: 561f46ebf941d8f8652787b2034038bbab21303080f5a6f281463f9f1a2669aa
5
5
  SHA512:
6
- metadata.gz: f41a0fddf6cd3376e4d4869b9695732db64bfcab2a0e487210927d0fa9e78d6ae3ab6e893c653afd9cbdba0e5bded804216e3b385a0882f1853eba518c2bc8b4
7
- data.tar.gz: 314e5ae920fa3c02f1d46899c0bd9508fd6c5dee228e675d3a7f9d0fc742f10c2d43e24032a0a5a227ad32d7f1bb36e53b4221f228840b7357143c0708106bd1
6
+ metadata.gz: fa0470d86d105b2f33e16d0d5a5376cb5e09641ec825faddd9d9cc5b39426b15fcc0d382b3586625e26032d4a48593179f706e7e9276918fa666f5739c35a6c6
7
+ data.tar.gz: a06fddd61f295a1ba89c55180487ed89f9142fce8161f41c5aa5861190611c93303b581e971cfaae45f877060c2ab72b12e147eddc7d49329d2038fd7e1cb3bf
@@ -18,6 +18,10 @@ module Pinecone
18
18
  Pinecone::Index.new.delete(index_name)
19
19
  end
20
20
 
21
+ def configure_index(index_name, body)
22
+ Pinecone::Index.new.configure(index_name, body)
23
+ end
24
+
21
25
  def list_collections
22
26
  Pinecone::Collection.new.list
23
27
  end
@@ -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,
@@ -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
- ids_query_string = ids.map { |id| "ids=#{id}" }.join('&')
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(namespace: "", vector:, top_k: 10, include_values: false, include_metadata: true)
38
- inputs = {
39
- "namespace": namespace,
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,
@@ -1,3 +1,3 @@
1
1
  module Pinecone
2
- VERSION = "0.1.3".freeze
2
+ VERSION = "0.1.5".freeze
3
3
  end
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.3
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-25 00:00:00.000000000 Z
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