pinecone 0.0.0 → 0.1.0
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/lib/pinecone.rb +17 -49
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c4641b066c5db948312f69332a370dd4e7d3f73505f84ebcbaf0e31706a8d93
|
4
|
+
data.tar.gz: 98f401fb73d77984f92dc833f1e8d99d10cd3fe208983cf5f0adb48eb998a11f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5afd17e4ec5e36c78f83ad75833654bab6b049d6196fac37fd87a082154c15badfb26687b7acfed9b67b1c6f4a6033244fef7c17fdd0bb086fbe90f50cd4afcd
|
7
|
+
data.tar.gz: 62674b0d1b9d4aea529eaff9d2156f1dcaaec9bf97f04ad7200345bf82369364173732d6ae631fe5782d55e3dc873dc0691d8ef1debf3eacd5c8cd84a7a37e38
|
data/lib/pinecone.rb
CHANGED
@@ -1,19 +1,20 @@
|
|
1
|
-
require
|
1
|
+
require "httparty"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# pinecone.query(Vector Array)
|
3
|
+
require "pinecone/client"
|
4
|
+
require "pinecone/index"
|
5
|
+
require "pinecone/vector"
|
6
|
+
require "pinecone/version"
|
8
7
|
|
9
|
-
|
8
|
+
module Pinecone
|
10
9
|
class ConfigurationError < StandardError; end
|
10
|
+
class IndexNotFoundError < StandardError; end
|
11
11
|
class Configuration
|
12
|
-
attr_writer :api_key, :base_uri
|
12
|
+
attr_writer :api_key, :base_uri, :environment
|
13
13
|
|
14
14
|
def initialize
|
15
|
-
@api_key
|
16
|
-
@
|
15
|
+
@api_key = nil
|
16
|
+
@environment = nil
|
17
|
+
@base_uri = nil
|
17
18
|
end
|
18
19
|
|
19
20
|
def api_key
|
@@ -27,9 +28,13 @@ class Pinecone
|
|
27
28
|
|
28
29
|
raise ConfigurationError, "Pinecone domain not set"
|
29
30
|
end
|
30
|
-
end
|
31
31
|
|
32
|
-
|
32
|
+
def environment
|
33
|
+
return @environment if @environment
|
34
|
+
|
35
|
+
raise ConfigurationError, "Pinecone environment not set"
|
36
|
+
end
|
37
|
+
end
|
33
38
|
|
34
39
|
class << self
|
35
40
|
attr_writer :configuration
|
@@ -42,43 +47,6 @@ class Pinecone
|
|
42
47
|
def self.configure
|
43
48
|
yield(configuration)
|
44
49
|
end
|
45
|
-
|
46
|
-
def initialize
|
47
|
-
self.class.base_uri Pinecone.configuration.base_uri
|
48
|
-
@headers = {
|
49
|
-
"Content-Type" => "application/json",
|
50
|
-
"Accept" => "application/json",
|
51
|
-
"Api-Key" => Pinecone.configuration.api_key,
|
52
|
-
}
|
53
|
-
end
|
54
|
-
|
55
|
-
# # Post Upsert
|
56
|
-
# # The Upsert operation inserts or updates vectors in a namespace.
|
57
|
-
# https://index_name-project_id.svc.environment.pinecone.io/vectors/upsert
|
58
|
-
def upsert(body)
|
59
|
-
payload = options.merge(body: body.to_json)
|
60
|
-
self.class.post('/vectors/upsert', payload)
|
61
|
-
end
|
62
|
-
|
63
|
-
# # POST Query
|
64
|
-
# https://index_name-project_id.svc.environment.pinecone.io/query
|
65
|
-
# vector is an array of floats
|
66
|
-
def query(vector)
|
67
|
-
defaults = {
|
68
|
-
"includeValues": false,
|
69
|
-
"includeMetadata": true,
|
70
|
-
"topK": 5,
|
71
|
-
"vector": vector
|
72
|
-
}.to_json
|
73
|
-
payload = options.merge(body: defaults)
|
74
|
-
self.class.post('/query', payload)
|
75
|
-
end
|
76
|
-
|
77
|
-
def options
|
78
|
-
{
|
79
|
-
headers: @headers,
|
80
|
-
}
|
81
|
-
end
|
82
50
|
end
|
83
51
|
|
84
52
|
# Vector Operations
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pinecone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.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: 2023-02-
|
11
|
+
date: 2023-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: Ruby client library which includes index and vector operations to upload
|
14
|
+
embeddings into Pinecone and do similarity searches on them.
|
14
15
|
email: scott@extrayarn.com
|
15
16
|
executables: []
|
16
17
|
extensions: []
|