pinecone 0.0.0 → 0.1.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pinecone.rb +17 -49
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9de142f1852fd8049b7a1c35466e51b45564a3a3a9dcfb102c9347407f53e1e9
4
- data.tar.gz: 4cce7e39f6b2c16885059341f19ff5bafcd5745b76660131d4a35d380cd22cb9
3
+ metadata.gz: 0b99d69de7f1fb2cf2afbe928b8e48fd0d10c641e33515e4cdde22180d7d9d8b
4
+ data.tar.gz: f7688c5c74abbfedf560db22ae9f20980c2080e3b414639f99251676c8a3f323
5
5
  SHA512:
6
- metadata.gz: 19aac1527777be26bfec6e35f056b50029d1656bdc24f71912c8dfe5d9de5d19b0298c9a58767dacab39f6df4dd33ac736f1223151b309681850723122271a72
7
- data.tar.gz: 26d1506aa12318845f02b2a60fcf2d10113b53459356ffc2239ede9b8ed53a1a6fcdd6c46ed10652ed674e8ab96d217e49f0c30c51c74602d297dcae12fe4bf4
6
+ metadata.gz: bf5375603748aa96e744ba92110a5a3b4548f3d58c9388a1e76c4847e16c1fe3e069755df5dc8d87a7bcd1e2e8369589b5b3e37c2389251324489bd2e58b1a03
7
+ data.tar.gz: 88bc2b14f05e5e80380ebae0824667e4e9a0a4a35c482359e00bf58f9db2e623f00bacfd6b5123aaf738938dc48900379c2e615d6cc549904684c3d6e9bdec98
data/lib/pinecone.rb CHANGED
@@ -1,19 +1,20 @@
1
- require 'httparty'
1
+ require "httparty"
2
2
 
3
- # Usage
4
- #
5
- # pinecone = Pinecone.new
6
- # pinecone.upsert(Vector Hash)
7
- # pinecone.query(Vector Array)
3
+ require "pinecone/client"
4
+ require "pinecone/index"
5
+ require "pinecone/vector"
6
+ require "pinecone/version"
8
7
 
9
- class Pinecone
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 = nil
16
- @base_uri = nil
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
- include HTTParty
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.0.0
4
+ version: 0.1.1
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-03 00:00:00.000000000 Z
11
+ date: 2023-03-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Enables ruby access to upsert and query vectors in Pinecone
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: []