boxcars 0.2.8 → 0.2.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69b70e1d02b1ec206438eaaf857a0495fe35ab01e64a265656fe21230675306f
4
- data.tar.gz: 8681b9625a0684f1091eea7a4626964929b271370068c90b82dabeee4253d803
3
+ metadata.gz: 65cac44b2b1953ea30b364d82f4bd727ab205097bc1debc94c49fefe37086f30
4
+ data.tar.gz: 959bc9669057e00a877878321f6458f0e486449a47870abab88564865f7beabe
5
5
  SHA512:
6
- metadata.gz: eb5c0c00f8fcdbbd6d8a1999d7544fc584c701fdf9a8a9c271fff6d9795f75ef9cab058fee2c6829808a764c892cc3e2f4e4a8717155d34d6514b46d744e632c
7
- data.tar.gz: b8fb4ad34d7b93d47388f037d1d93e9e7245303740bc04d58d21942112ff97315e5dd31fdba77e275b52ddba85ca1055b897646ae1e606daee485583d50c52a6
6
+ metadata.gz: a918cc81c4a8db8249ba0efc223fcdef5cf7be25bba7b3f998c90a6b1ff28fa4bd57d1d5a34bcd977e169f8c04bff196d7258c15b50c31526c3b9da953fe7f33
7
+ data.tar.gz: f0c78cb12026b9c7abcf927799c79e3520a0ccd518e6fdbb50cd4da5c3ef6fe2758e5032c03da1c5299d209874b0163d730a1774f583c530f69ff38291e90723
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- boxcars (0.2.8)
4
+ boxcars (0.2.9)
5
5
  google_search_results (~> 2.2)
6
6
  gpt4all (~> 0.0.4)
7
7
  ruby-openai (~> 3.0)
@@ -5,11 +5,11 @@ require 'hnswlib'
5
5
  module Boxcars
6
6
  module Embeddings
7
7
  class SimilaritySearch
8
- def initialize(embeddings:, vector_store:, openai_connection:)
8
+ def initialize(embeddings:, vector_store:, openai_connection: nil, openai_access_token: nil)
9
9
  @embeddings = embeddings
10
10
  @vector_store = vector_store
11
11
  @similarity_search_instance = create_similarity_search_instance
12
- @openai_connection = openai_connection
12
+ @openai_connection = openai_connection || default_connection(openai_access_token: openai_access_token)
13
13
  end
14
14
 
15
15
  def call(query:)
@@ -22,6 +22,12 @@ module Boxcars
22
22
 
23
23
  attr_reader :embeddings, :vector_store, :openai_connection
24
24
 
25
+ def default_connection(openai_access_token: nil)
26
+ access_token = Boxcars.configuration.openai_access_token(openai_access_token: openai_access_token)
27
+ organization_id = Boxcars.configuration.organization_id
28
+ ::OpenAI::Client.new(access_token: access_token, organization_id: organization_id)
29
+ end
30
+
25
31
  def validate_query(query)
26
32
  raise_error 'query must be a string' unless query.is_a?(String)
27
33
  raise_error 'query must not be empty' if query.empty?
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Boxcars
4
4
  # The current version of the gem.
5
- VERSION = "0.2.8"
5
+ VERSION = "0.2.9"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxcars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Sullivan
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-04-19 00:00:00.000000000 Z
12
+ date: 2023-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: debug