ruby-pinecone 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 447e688337c17e18023d086c8804315bc1a099de3340c07671d65aae4cddebac
4
- data.tar.gz: 29d79c0ff8231503de054078444f25261887a23ce6c8e84ac946192e164ee3f7
3
+ metadata.gz: 94a8d0986de77f82632dfd0d579e9b97f2bf7021e568f892c7cc16860047627b
4
+ data.tar.gz: aeb5cad4f8e4d2db064b8e0c545954f785470b0722a162f9e20cf7484f771143
5
5
  SHA512:
6
- metadata.gz: a02a1a45d1091741e4cd390ff701b850e2a0b4bb391f156228890a69e265390838a7a572a4a8223404a6deee8d6d7ccac73715bd6d44c650e411029add55741b
7
- data.tar.gz: be810f94389decfd4548edd56ba81cbd390821c7d8ace6a510a41ad053a96c83dfb444637289cc3146997284d1bd5132898d3783553952c3029b21d2cb1a977d
6
+ metadata.gz: 9ae89d24205bd3fd6b4dfbd6db5441fe0e4cc865db14f4645c6ba9af8cb19b0e0b3bb3eb7668524cdd3021a2355b619fdd7341648be3dad6ec2bf6bea1099c9b
7
+ data.tar.gz: 619783997bc2a1f170c1af1dea37d063434f7cb67adfd120c79218eefda695c1dd473877eeb64c4f324df86aebc0048207278722b9fc99a9347b6506e0a0a1ac
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.2] - 2023-03-10
4
+
5
+ - Index#Query to return parsed body
6
+ - Add QueryError
7
+ - Document Index#query
8
+
3
9
  ## [0.1.1] - 2023-03-08
4
10
 
5
11
  - Initial release
data/README.md CHANGED
@@ -111,6 +111,23 @@ index = client.indexes['my-index']
111
111
  index.vectors.delete(ids: ['id-1', 'id-2'])
112
112
  ```
113
113
 
114
+ #### Query
115
+ ```ruby
116
+ client = Pinecone::Client.new
117
+ index = client.indexes['my-index']
118
+
119
+ options = {
120
+ "includeValues": false,
121
+ "includeMetadata": true,
122
+ "topK": 10,
123
+ }
124
+ index.query([1.0, 1.0], options: options)
125
+ # => {"results"=>[], "matches"=>[{"id"=>"id-1", "score"=>1, "values"=>[], "metadata"=>{"type"=>"Thing"}}, {"id"=>"id-2", "score"=>0.89825207, "values"=>[], "metadata"=>{"type"=>"Thing"}}], "namespace"=>""}
126
+
127
+ index.query(nil, options: options)
128
+ # => raise QueryError (Query failed with 400 - {"code"=>3, "message"=>"No query provided", "details"=>[]})
129
+ ```
130
+
114
131
  ## Development
115
132
 
116
133
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,5 +1,7 @@
1
1
  module Pinecone
2
2
  class Index
3
+ class QueryError < StandardError; end
4
+
3
5
  attr_accessor :name
4
6
  def initialize(name:)
5
7
  self.name = name
@@ -51,7 +53,11 @@ module Pinecone
51
53
  "vector": vector
52
54
  }
53
55
  body = defaults.merge(options)
54
- Pinecone::Client.json_post(prefix: prefix, path: '/query', parameters: body)
56
+ result = Pinecone::Client.json_post(prefix: prefix, path: '/query', parameters: body)
57
+ if !result.success?
58
+ raise QueryError.new("Query failed with #{result.response.code} - #{result.parsed_response.to_s}")
59
+ end
60
+ result.parsed_response
55
61
  end
56
62
 
57
63
  # # Get Show
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pinecone
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-pinecone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Hirst
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-08 00:00:00.000000000 Z
11
+ date: 2023-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty