ruby-pinecone 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 447e688337c17e18023d086c8804315bc1a099de3340c07671d65aae4cddebac
4
+ data.tar.gz: 29d79c0ff8231503de054078444f25261887a23ce6c8e84ac946192e164ee3f7
5
+ SHA512:
6
+ metadata.gz: a02a1a45d1091741e4cd390ff701b850e2a0b4bb391f156228890a69e265390838a7a572a4a8223404a6deee8d6d7ccac73715bd6d44c650e411029add55741b
7
+ data.tar.gz: be810f94389decfd4548edd56ba81cbd390821c7d8ace6a510a41ad053a96c83dfb444637289cc3146997284d1bd5132898d3783553952c3029b21d2cb1a977d
@@ -0,0 +1,13 @@
1
+ version: 2.1
2
+ jobs:
3
+ build:
4
+ docker:
5
+ - image: ruby:3.0.2
6
+ steps:
7
+ - checkout
8
+ - run:
9
+ name: Run the default task
10
+ command: |
11
+ gem install bundler -v 2.2.22
12
+ bundle install
13
+ bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.1] - 2023-03-08
4
+
5
+ - Initial release
6
+
7
+
8
+ ## [0.1.0] - 2023-02-17
9
+
10
+ - Initial work
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hirst.mat@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in ruby-pinecone.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ruby-pinecone (0.1.1)
5
+ httparty (>= 0.18.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ diff-lcs (1.5.0)
12
+ httparty (0.21.0)
13
+ mini_mime (>= 1.0.0)
14
+ multi_xml (>= 0.5.2)
15
+ json (2.6.3)
16
+ mini_mime (1.1.2)
17
+ multi_xml (0.6.0)
18
+ parallel (1.22.1)
19
+ parser (3.2.1.0)
20
+ ast (~> 2.4.1)
21
+ rainbow (3.1.1)
22
+ rake (13.0.6)
23
+ regexp_parser (2.7.0)
24
+ rexml (3.2.5)
25
+ rspec (3.12.0)
26
+ rspec-core (~> 3.12.0)
27
+ rspec-expectations (~> 3.12.0)
28
+ rspec-mocks (~> 3.12.0)
29
+ rspec-core (3.12.1)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-expectations (3.12.2)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.12.0)
34
+ rspec-mocks (3.12.3)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.12.0)
37
+ rspec-support (3.12.0)
38
+ rubocop (1.45.1)
39
+ json (~> 2.3)
40
+ parallel (~> 1.10)
41
+ parser (>= 3.2.0.0)
42
+ rainbow (>= 2.2.2, < 4.0)
43
+ regexp_parser (>= 1.8, < 3.0)
44
+ rexml (>= 3.2.5, < 4.0)
45
+ rubocop-ast (>= 1.24.1, < 2.0)
46
+ ruby-progressbar (~> 1.7)
47
+ unicode-display_width (>= 2.4.0, < 3.0)
48
+ rubocop-ast (1.26.0)
49
+ parser (>= 3.2.1.0)
50
+ ruby-progressbar (1.11.0)
51
+ unicode-display_width (2.4.2)
52
+
53
+ PLATFORMS
54
+ arm64-darwin-21
55
+
56
+ DEPENDENCIES
57
+ rake (~> 13.0)
58
+ rspec (~> 3.0)
59
+ rubocop (~> 1.7)
60
+ ruby-pinecone!
61
+
62
+ BUNDLED WITH
63
+ 2.2.22
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Matthew Hirst
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # Ruby Pinecone
2
+
3
+ Ruby library to make interacting with the Pinecone Vector Database API easier.
4
+ Format and workings inspired by https://github.com/alexrudall/ruby-openai
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'ruby-pinecone'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle install
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install ruby-pinecone
21
+
22
+ ## Usage
23
+
24
+ ### Quickstart
25
+
26
+ For a quick test you can pass your token directly to a new client:
27
+
28
+ ```ruby
29
+ client = Pinecone::Client.new(api_key: "access_token_goes_here", environment: "us-east1-gcp")
30
+ ```
31
+
32
+ ### With Config
33
+
34
+ For a more robust setup, you can configure the gem with your API keys, for example in a pinecone.rb initializer. Never hardcode secrets into your codebase - instead use something like dotenv to pass the keys safely into your environments.
35
+
36
+ ```ruby
37
+ Pinecone.configuration.api_key = ENV.fetch('PINECONE_API_KEY')
38
+ Pinecone.configuration.environment = ENV.fetch('PINECONE_ENVIRONMENT')
39
+ ```
40
+ Then you can create a client like this:
41
+
42
+ ```ruby
43
+ client = Pinecone::Client.new
44
+ ```
45
+
46
+ ### Indexes
47
+
48
+ #### View Indexes
49
+ ```ruby
50
+ client = Pinecone::Client.new
51
+
52
+ # Load all indexes
53
+ indexes = client.indexes.list
54
+
55
+ # Load specific index
56
+ index = client.indexes['my-index']
57
+
58
+ index.describe
59
+ # => {"database"=>{"name"=>"my-index", "metric"=>"cosine"...}}
60
+
61
+ index.describe_index_stats
62
+ #=> {"namespaces"=>{}, "dimension"=>1536, "indexFullness"=>0, "totalVectorCount"=>0}
63
+ ```
64
+
65
+ #### Create Index
66
+ ```ruby
67
+ index = client.indexes.create(name: 'my-new-index', params: {dimension: 1536})
68
+ ```
69
+
70
+ #### Delete Index
71
+ ```ruby
72
+ index = client.indexes['my-index']
73
+ index.delete
74
+ ```
75
+
76
+ ### Update an Index
77
+ ```ruby
78
+ index = client.indexes['my-index']
79
+ index.configure(params: {pod_type: 's1.x2'})
80
+ ```
81
+
82
+ #### Manage Vectors
83
+
84
+ ##### Upsert
85
+ ```ruby
86
+ client = Pinecone::Client.new
87
+ index = client.indexes['my-index']
88
+
89
+ body = {
90
+ vectors: [
91
+ {
92
+ id: 'id-1',
93
+ values: [0.1, 0.1, 0.1, 0.1, 0.1],
94
+ metadata: {genre: 'comedy', year: 2020}
95
+ },
96
+ {
97
+ id: 'id-2',
98
+ values: [0.2, 0.2, 0.2, 0.2, 0.2],
99
+ metadata: {genre: 'drama'}
100
+ },
101
+ ]
102
+ }
103
+
104
+ index.vectors.upsert(body)
105
+ ```
106
+
107
+ ##### Delete
108
+ ```ruby
109
+ client = Pinecone::Client.new
110
+ index = client.indexes['my-index']
111
+ index.vectors.delete(ids: ['id-1', 'id-2'])
112
+ ```
113
+
114
+ ## Development
115
+
116
+ 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.
117
+
118
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
119
+
120
+ ## Contributing
121
+
122
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruby-pinecone. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/ruby-pinecone/blob/main/CODE_OF_CONDUCT.md).
123
+
124
+ ## License
125
+
126
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
127
+
128
+ ## Code of Conduct
129
+
130
+ Everyone interacting in the Ruby Pinecone project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ruby-pinecone/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "pinecone"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,71 @@
1
+ module Pinecone
2
+ class Client
3
+ def initialize(api_key: nil, environment: nil)
4
+ Pinecone.configuration.api_key = api_key if api_key
5
+ Pinecone.configuration.environment = environment if environment
6
+ end
7
+
8
+ # # Vectors API
9
+ #
10
+ def indexes
11
+ Pinecone::Index
12
+ end
13
+
14
+ # # HTTP Helpers
15
+ #
16
+ def self.get(path:, prefix: '')
17
+ HTTParty.get(
18
+ uri(path: path, prefix: prefix),
19
+ headers: headers
20
+ )
21
+ end
22
+
23
+ def self.json_post(path:, prefix: '', parameters:)
24
+ HTTParty.post(
25
+ uri(path: path, prefix: prefix),
26
+ headers: headers,
27
+ body: parameters&.to_json
28
+ )
29
+ end
30
+
31
+ def self.json_patch(path:, prefix: '', parameters:)
32
+ HTTParty.patch(
33
+ uri(path: path, prefix: prefix),
34
+ headers: headers,
35
+ body: parameters&.to_json
36
+ )
37
+ end
38
+
39
+ def self.multipart_post(path:, prefix: '', parameters: nil)
40
+ HTTParty.post(
41
+ uri(path: path, prefix: prefix),
42
+ headers: headers.merge({ "Content-Type" => "multipart/form-data" }),
43
+ body: parameters
44
+ )
45
+ end
46
+
47
+ def self.delete(path:, prefix: '')
48
+ HTTParty.delete(
49
+ uri(path: path, prefix: prefix),
50
+ headers: headers
51
+ )
52
+ end
53
+
54
+ def self.project_name
55
+ Thread.current[:project_name] ||= Pinecone::Client.get(prefix: 'controller', path: '/actions/whoami')['project_name']
56
+ end
57
+
58
+ private_class_method def self.uri(path:, prefix: '')
59
+ base = [prefix, Pinecone.configuration.environment].compact.join('.')
60
+ "https://#{base}.pinecone.io" + path
61
+ end
62
+
63
+ private_class_method def self.headers
64
+ {
65
+ "Content-Type" => "application/json",
66
+ "Accept" => "application/json",
67
+ "Api-Key" => Pinecone.configuration.api_key
68
+ }
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,86 @@
1
+ module Pinecone
2
+ class Index
3
+ attr_accessor :name
4
+ def initialize(name:)
5
+ self.name = name
6
+ end
7
+
8
+ def self.[](name)
9
+ self.new(name: name)
10
+ end
11
+
12
+ def prefix
13
+ "#{name}-#{Pinecone::Client.project_name}.svc"
14
+ end
15
+
16
+ # # Vectors API
17
+ #
18
+ def vectors
19
+ @vectors ||= Pinecone::Vectors.new(index: self)
20
+ end
21
+
22
+ # # Get Index
23
+ # # Lists all databases
24
+ # https://docs.pinecone.io/docs/manage-indexes#getting-information-on-your-indexes
25
+ def self.list
26
+ indexes = Pinecone::Client.get(prefix: 'controller', path: "/databases")
27
+ indexes.map{|i| self.new(name: i) }
28
+ end
29
+
30
+ # # POST Create
31
+ # # Creates an index
32
+ # https://docs.pinecone.io/docs/manage-indexes#creating-an-index
33
+ def self.create(name:, params: {})
34
+ defaults = {
35
+ name: name,
36
+ dimension: 128
37
+ }
38
+ body = defaults.merge(params.deep_symbolize_keys)
39
+ Pinecone::Client.json_post(prefix: 'controller', path: "/databases", parameters: body)
40
+ self.new(name: name)
41
+ end
42
+
43
+ # # POST Query
44
+ # # Provide a vector and retrieve the top-k most similar vectors for each query
45
+ # https://docs.pinecone.io/docs/query-data#sending-a-query
46
+ def query(vector, options: {})
47
+ defaults = {
48
+ "includeValues": false,
49
+ "includeMetadata": true,
50
+ "topK": 5,
51
+ "vector": vector
52
+ }
53
+ body = defaults.merge(options)
54
+ Pinecone::Client.json_post(prefix: prefix, path: '/query', parameters: body)
55
+ end
56
+
57
+ # # Get Show
58
+ # # Show database info
59
+ # https://docs.pinecone.io/docs/manage-indexes#getting-information-on-your-indexes
60
+ def describe
61
+ Pinecone::Client.get(prefix: 'controller', path: "/databases/#{name}")
62
+ end
63
+
64
+ # # Get Show
65
+ # # Show database info
66
+ # https://docs.pinecone.io/docs/manage-indexes#getting-information-on-your-indexes
67
+ def describe_index_stats
68
+ Pinecone::Client.get(prefix: prefix, path: '/describe_index_stats')
69
+ end
70
+
71
+ # # PATCH Configure
72
+ # # Creates an index
73
+ # https://docs.pinecone.io/docs/manage-indexes#creating-an-index
74
+ def configure(params:)
75
+ Pinecone::Client.json_patch(prefix: 'controller', path: "/databases/#{name}", parameters: params)
76
+ end
77
+
78
+ # # DELETE
79
+ # # Creates an index
80
+ # https://docs.pinecone.io/docs/manage-indexes#deleting-an-index
81
+ def delete
82
+ Pinecone::Client.delete(prefix: 'controller', path: "/databases/#{name}")
83
+ end
84
+
85
+ end
86
+ end
@@ -0,0 +1,25 @@
1
+ module Pinecone
2
+ class Vectors
3
+ attr_accessor :index
4
+ def initialize(index:)
5
+ self.index = index
6
+ end
7
+
8
+ # # POST Upsert
9
+ # # Inserts or updates vectors in an index.
10
+ # https://docs.pinecone.io/docs/insert-data#inserting-the-vectors
11
+ def upsert(body)
12
+ Pinecone::Client.json_post(prefix: index.prefix, path: "/vectors/upsert", parameters: body)
13
+ end
14
+
15
+ # https://docs.pinecone.io/docs/manage-data#fetching-vectors
16
+ def fetch(ids:)
17
+ Pinecone::Client.get(prefix: index.prefix, path: "/vectors/fetch?ids=#{ids.join(',')}")
18
+ end
19
+
20
+ # https://docs.pinecone.io/docs/manage-data#delete-vectors-by-id
21
+ def delete(ids:)
22
+ Pinecone::Client.delete(prefix: index.prefix, path: "/vectors/delete?ids=#{ids.join(',')}")
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pinecone
4
+ VERSION = "0.1.1"
5
+ end
data/lib/pinecone.rb ADDED
@@ -0,0 +1,46 @@
1
+ require "httparty"
2
+
3
+ require_relative "pinecone/client"
4
+ require_relative "pinecone/index"
5
+ require_relative "pinecone/vectors"
6
+ require_relative "pinecone/version"
7
+
8
+ module Pinecone
9
+ class Error < StandardError; end
10
+ class ConfigurationError < Error; end
11
+
12
+ class Configuration
13
+ attr_writer :api_key, :environment
14
+
15
+ def initialize
16
+ @api_key = nil
17
+ @environment = nil
18
+ end
19
+
20
+ def api_key
21
+ return @api_key if @api_key
22
+
23
+ error_text = "Pinecone API Key missing! See https://github.com/hornet-network/ruby-pinecone#usage"
24
+ raise ConfigurationError, error_text
25
+ end
26
+
27
+ def environment
28
+ return @environment if @environment
29
+
30
+ error_text = "Pinecone environment missing! See https://github.com/hornet-network/ruby-pinecone#usage"
31
+ raise ConfigurationError, error_text
32
+ end
33
+ end
34
+
35
+ class << self
36
+ attr_writer :configuration
37
+ end
38
+
39
+ def self.configuration
40
+ Thread.current[:configuration] ||= Pinecone::Configuration.new
41
+ end
42
+
43
+ def self.configure
44
+ yield(configuration)
45
+ end
46
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/pinecone/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "ruby-pinecone"
7
+ spec.version = Pinecone::VERSION
8
+ spec.authors = ["Matthew Hirst"]
9
+ spec.email = ["hirst.mat@gmail.com"]
10
+
11
+ spec.summary = "Ruby library for interacting with the pineone vector database"
12
+ spec.description = "Ruby library for interacting with the pineone vector database"
13
+ spec.homepage = "https://github.com/hornet-network/ruby-pinecone"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.4.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/hornet-network/ruby-pinecone"
19
+ spec.metadata["changelog_uri"] = "https://github.com/hornet-network/ruby-pinecone/blob/main/CHANGELOG.md"
20
+ spec.metadata["rubygems_mfa_required"] = "true"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ # Uncomment to register a new dependency of your gem
32
+ spec.add_dependency "httparty", ">= 0.18.1"
33
+
34
+ # For more information and examples about making a new gem, checkout our
35
+ # guide at: https://bundler.io/guides/creating_gem.html
36
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-pinecone
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Hirst
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-03-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.18.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.18.1
27
+ description: Ruby library for interacting with the pineone vector database
28
+ email:
29
+ - hirst.mat@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".circleci/config.yml"
35
+ - ".gitignore"
36
+ - ".rspec"
37
+ - ".rubocop.yml"
38
+ - CHANGELOG.md
39
+ - CODE_OF_CONDUCT.md
40
+ - Gemfile
41
+ - Gemfile.lock
42
+ - LICENSE.txt
43
+ - README.md
44
+ - Rakefile
45
+ - bin/console
46
+ - bin/setup
47
+ - lib/pinecone.rb
48
+ - lib/pinecone/client.rb
49
+ - lib/pinecone/index.rb
50
+ - lib/pinecone/vectors.rb
51
+ - lib/pinecone/version.rb
52
+ - ruby-pinecone.gemspec
53
+ homepage: https://github.com/hornet-network/ruby-pinecone
54
+ licenses:
55
+ - MIT
56
+ metadata:
57
+ homepage_uri: https://github.com/hornet-network/ruby-pinecone
58
+ source_code_uri: https://github.com/hornet-network/ruby-pinecone
59
+ changelog_uri: https://github.com/hornet-network/ruby-pinecone/blob/main/CHANGELOG.md
60
+ rubygems_mfa_required: 'true'
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 2.4.0
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubygems_version: 3.2.22
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Ruby library for interacting with the pineone vector database
80
+ test_files: []