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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +17 -0
- data/lib/pinecone/index.rb +7 -1
- data/lib/pinecone/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94a8d0986de77f82632dfd0d579e9b97f2bf7021e568f892c7cc16860047627b
|
4
|
+
data.tar.gz: aeb5cad4f8e4d2db064b8e0c545954f785470b0722a162f9e20cf7484f771143
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ae89d24205bd3fd6b4dfbd6db5441fe0e4cc865db14f4645c6ba9af8cb19b0e0b3bb3eb7668524cdd3021a2355b619fdd7341648be3dad6ec2bf6bea1099c9b
|
7
|
+
data.tar.gz: 619783997bc2a1f170c1af1dea37d063434f7cb67adfd120c79218eefda695c1dd473877eeb64c4f324df86aebc0048207278722b9fc99a9347b6506e0a0a1ac
|
data/CHANGELOG.md
CHANGED
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.
|
data/lib/pinecone/index.rb
CHANGED
@@ -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
|
data/lib/pinecone/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2023-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|