pinecone 1.0.1 → 1.1.0

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: ab3d946459844e4448d5d9ef3ec0856db62ce97c4e1201013ba33c046cc9d200
4
- data.tar.gz: 419f33cf6d1c4876eb882b9109356bfc25f5d74fff52244f2b962c691d162301
3
+ metadata.gz: c9e5f89bdb821f056dde85c82168420d575599d116508b083fb987ea7b3b60da
4
+ data.tar.gz: b4d1da67d606505ca251db63cc63a9077d363e92425ddfeb4ea55263af30aac6
5
5
  SHA512:
6
- metadata.gz: e552468414c4b38a77694e40b8cfd2782d0b48609b138e4e2559333b6ec1b31eef71274eb09db5bd15821a5e3419cfceb95bbdd67f5550066cebad14531e4fa3
7
- data.tar.gz: fe81f10ec021bd54e9d5243e67446e69423d0e0845cfaa3f72cd06ab1a3c381136728b2eed9423fcb9305c9c8973101cef6588568ad7575c0be6dc40528e86f8
6
+ metadata.gz: c429ec85b521a797a73597a6cba93b77e4892e84176064079367605c8436b15709aa03fd7ab563240c96bc8406c6b805c3d43bb7cc7f91c8c7ad1b016724acfe
7
+ data.tar.gz: 749c157e0650086c2365023cf8a9626ef04fd4bce9b5eac886de5007480c64318aa0c3312ea1795713ca08475c5e2f5396130aaabe2bb84d5d853d52969c12d1
@@ -57,7 +57,7 @@ module Pinecone
57
57
  def self.new(input)
58
58
  validation = FilterContract.new.call(input)
59
59
  if validation.success?
60
- super(input)
60
+ super
61
61
  else
62
62
  raise ArgumentError.new(validation.errors.to_h.inspect)
63
63
  end
@@ -44,7 +44,7 @@ module Pinecone
44
44
  def self.new(input)
45
45
  validation = QueryContract.new.call(input)
46
46
  if validation.success?
47
- super(input)
47
+ super
48
48
  else
49
49
  raise ArgumentError.new(validation.errors.to_h.inspect)
50
50
  end
@@ -30,7 +30,7 @@ module Pinecone
30
30
  def self.new(input)
31
31
  validation = SparseVectorContract.new.call(input)
32
32
  if validation.success?
33
- super(input)
33
+ super
34
34
  else
35
35
  raise ArgumentError.new(validation.errors.to_h.inspect)
36
36
  end
@@ -26,7 +26,6 @@ module Pinecone
26
26
  deleteAll: delete_all,
27
27
  filter: filter
28
28
  }
29
-
30
29
  inputs.delete(:filter) if delete_all || ids.any?
31
30
  payload = options.merge(body: inputs.to_json)
32
31
  self.class.post("#{@base_uri}/vectors/delete", payload)
@@ -37,6 +36,58 @@ module Pinecone
37
36
  self.class.get("#{@base_uri}/vectors/fetch?#{query_string}", options)
38
37
  end
39
38
 
39
+ def list(prefix: nil, limit: nil, namespace: nil, &block)
40
+ all_ids = []
41
+ pagination_token = nil
42
+ total_fetched = 0
43
+
44
+ loop do
45
+ current_limit = limit.nil? ? 100 : [limit - total_fetched, 100].min
46
+
47
+ response = list_paginated(
48
+ prefix: prefix,
49
+ limit: current_limit,
50
+ pagination_token: pagination_token,
51
+ namespace: namespace
52
+ )
53
+
54
+ break unless response.success?
55
+
56
+ results = response.parsed_response
57
+ ids = results["vectors"]&.map { |v| v["id"] } || []
58
+
59
+ if block
60
+ yield ids
61
+ else
62
+ all_ids.concat(ids)
63
+ end
64
+
65
+ total_fetched += ids.length
66
+ pagination_token = results.dig("pagination", "next")
67
+
68
+ break if ids.empty?
69
+ break if limit && total_fetched >= limit
70
+ break if pagination_token.nil? || pagination_token.empty?
71
+ end
72
+
73
+ if block
74
+ nil
75
+ else
76
+ limit ? all_ids.first(limit) : all_ids
77
+ end
78
+ end
79
+
80
+ def list_paginated(prefix: nil, limit: nil, pagination_token: nil, namespace: nil)
81
+ query_params = {}
82
+ query_params["prefix"] = prefix if prefix
83
+ query_params["limit"] = limit if limit
84
+ query_params["paginationToken"] = pagination_token if pagination_token
85
+ query_params["namespace"] = namespace if namespace
86
+
87
+ query_string = URI.encode_www_form(query_params)
88
+ self.class.get("#{@base_uri}/vectors/list?#{query_string}", options)
89
+ end
90
+
40
91
  def upsert(body)
41
92
  payload = options.merge(body: body.to_json)
42
93
  self.class.post("#{@base_uri}/vectors/upsert", payload)
@@ -1,3 +1,3 @@
1
1
  module Pinecone
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.1.0".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: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Carleton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-29 00:00:00.000000000 Z
11
+ date: 2024-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.21.0
19
+ version: 0.22.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.21.0
26
+ version: 0.22.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dry-struct
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -82,14 +82,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: '0'
85
+ version: '3'
86
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []
92
- rubygems_version: 3.4.19
92
+ rubygems_version: 3.5.15
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: Ruby client library for Pinecone Vector DB