pinecone 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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: 6c4641b066c5db948312f69332a370dd4e7d3f73505f84ebcbaf0e31706a8d93
4
+ data.tar.gz: 98f401fb73d77984f92dc833f1e8d99d10cd3fe208983cf5f0adb48eb998a11f
5
5
  SHA512:
6
- metadata.gz: 19aac1527777be26bfec6e35f056b50029d1656bdc24f71912c8dfe5d9de5d19b0298c9a58767dacab39f6df4dd33ac736f1223151b309681850723122271a72
7
- data.tar.gz: 26d1506aa12318845f02b2a60fcf2d10113b53459356ffc2239ede9b8ed53a1a6fcdd6c46ed10652ed674e8ab96d217e49f0c30c51c74602d297dcae12fe4bf4
6
+ metadata.gz: 5afd17e4ec5e36c78f83ad75833654bab6b049d6196fac37fd87a082154c15badfb26687b7acfed9b67b1c6f4a6033244fef7c17fdd0bb086fbe90f50cd4afcd
7
+ data.tar.gz: 62674b0d1b9d4aea529eaff9d2156f1dcaaec9bf97f04ad7200345bf82369364173732d6ae631fe5782d55e3dc873dc0691d8ef1debf3eacd5c8cd84a7a37e38
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.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-03 00:00:00.000000000 Z
11
+ date: 2023-02-24 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: []