boxcars 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/boxcars/boxcar/embeddings/similarity_search.rb +8 -2
- data/lib/boxcars/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65cac44b2b1953ea30b364d82f4bd727ab205097bc1debc94c49fefe37086f30
|
4
|
+
data.tar.gz: 959bc9669057e00a877878321f6458f0e486449a47870abab88564865f7beabe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a918cc81c4a8db8249ba0efc223fcdef5cf7be25bba7b3f998c90a6b1ff28fa4bd57d1d5a34bcd977e169f8c04bff196d7258c15b50c31526c3b9da953fe7f33
|
7
|
+
data.tar.gz: f0c78cb12026b9c7abcf927799c79e3520a0ccd518e6fdbb50cd4da5c3ef6fe2758e5032c03da1c5299d209874b0163d730a1774f583c530f69ff38291e90723
|
data/Gemfile.lock
CHANGED
@@ -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?
|
data/lib/boxcars/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2023-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: debug
|