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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b17e749b07052d08df706ff8f60ca5a40c2bdb752a19662c15ebab0745cf813
4
- data.tar.gz: f0789949de4ceab10e7a195798aa0ebc6d77dd9c32f049cab27ff82f13c182fc
3
+ metadata.gz: 6ba29ca8e87743d1fb9641ecdd722ac1c18cc55f06d0314dd688d0474da48257
4
+ data.tar.gz: 29660db1e94027e9701999487c022f8b7ff281881e4166db05d972e55d054630
5
5
  SHA512:
6
- metadata.gz: f41a0fddf6cd3376e4d4869b9695732db64bfcab2a0e487210927d0fa9e78d6ae3ab6e893c653afd9cbdba0e5bded804216e3b385a0882f1853eba518c2bc8b4
7
- data.tar.gz: 314e5ae920fa3c02f1d46899c0bd9508fd6c5dee228e675d3a7f9d0fc742f10c2d43e24032a0a5a227ad32d7f1bb36e53b4221f228840b7357143c0708106bd1
6
+ metadata.gz: ad82b573c181757f03ea1df9f7f3343561d50899e884177ea6924941c361dce337e32288a66c2f47828fe39ac7ca14753550e005c7ae7c47448f31aa4c684da0
7
+ data.tar.gz: beee5be5eff743e68e65d8df4ea51b4f9dceeec1f761ff08506b8357787f0dc1c65e68da0ca369ed51ae6ea3ed838fd9134d567b5223b4cf6e44cc071a79a0f5
@@ -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,26 @@ 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
+
49
59
  def options
50
60
  {
51
61
  headers: @headers,
@@ -1,3 +1,3 @@
1
1
  module Pinecone
2
- VERSION = "0.1.3".freeze
2
+ VERSION = "0.1.4".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.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-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: '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