bx_builder_chain 0.1.1 → 0.1.2

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: de6d9468ceb20458a750bc55fae3ac0d10e6c0d26a36461d4a24b2c25e0c20c4
4
- data.tar.gz: 0caa475c638e32ba81c8757cf988fc3955e75a71b884b3bf3be73c3ecfa4607c
3
+ metadata.gz: fce719d547006f3558e46770fd93fcb40ae18b9192cd822c39e6f799492b17f8
4
+ data.tar.gz: 55646bf7a27c50ed76b936e8e4b2620e6f99590c73102d204586d7c471068717
5
5
  SHA512:
6
- metadata.gz: 316099f684a647f01ce0267ea11be809eed444738846294af9886a546ceca23d39aa26fc3003294b496c96aa1815b3df90c0d41470091e8140478d3ad75e7899
7
- data.tar.gz: 9e62733d326e2ee41af83e27f3a3ae3162b8bf510aed98c93d1f8447cfba178e5203e180db11a711ed742327a2722ec47e302aff1762abd97b53158f0b9c0a8b
6
+ metadata.gz: 21a59e389d2764994ce4e145a1286c4d8d0c1221b2130db8c6b0eb9f9effbdf8783c5eade25fd1e80e34409dcb0df0fbc5e07364177164379bb099eb34d4b803
7
+ data.tar.gz: 642dc5a052c79000eff8601695696f18fbfc7346a0f5d72032377985061e65faaf61865c3b7ef306dcdd3b7e07b03444dfdd0d7dbceba849018415828a2e93b2
data/Gemfile.lock CHANGED
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bx_builder_chain (0.1.0)
4
+ bx_builder_chain (0.1.1)
5
5
  baran (= 0.1.7)
6
- docx
7
- dotenv
8
- nokogiri
9
- pdf-reader
10
- pg
11
- roo
12
- ruby-openai
6
+ docx (~> 0.8.0)
7
+ dotenv (~> 2.8)
8
+ nokogiri (~> 1.8)
9
+ pdf-reader (~> 2.11.0)
10
+ pg (~> 1.5.3)
11
+ roo (~> 2.8.3)
12
+ ruby-openai (~> 5.1.0)
13
13
  sequel (~> 5.71)
14
14
  zeitwerk (= 2.6.11)
15
15
 
@@ -85,7 +85,7 @@ GEM
85
85
  unicode-display_width (>= 2.4.0, < 3.0)
86
86
  rubocop-ast (1.29.0)
87
87
  parser (>= 3.2.1.0)
88
- ruby-openai (5.0.0)
88
+ ruby-openai (5.1.0)
89
89
  faraday (>= 1)
90
90
  faraday-multipart (>= 1)
91
91
  ruby-progressbar (1.13.0)
@@ -1,21 +1,27 @@
1
- # Inside your gem (e.g., in `lib/bx_builder_chain/vectorsearch/configuration.rb`)
1
+ # In your Configuration class (e.g., `lib/bx_builder_chain/vectorsearch/configuration.rb`)
2
2
 
3
3
  module BxBuilderChain
4
- class Configuration
5
- attr_accessor :pg_url, :openai_api_key, :public_namespace, :threshold, :default_prompt_template
6
-
7
- def initialize
8
- @pg_url = ENV['DB_URL']
9
- @openai_api_key = ENV['OPENAI_API_KEY']
10
- @public_namespace = 'public'
11
- @threshold = 0.25
12
- @default_prompt_template = "Context information is below
4
+ class Configuration
5
+ attr_accessor :pg_url, :openai_api_key, :public_namespace, :threshold,
6
+ :default_prompt_template, :database_host, :database_port, :database_name,
7
+ :database_user, :database_password
8
+
9
+ def initialize
10
+ @pg_url = ENV['DB_URL'] || nil
11
+ @openai_api_key = ENV['OPENAI_API_KEY']
12
+ @public_namespace = 'public'
13
+ @threshold = 0.25
14
+ @default_prompt_template = "Context information is below
13
15
  --------------------
14
16
  %{context}
15
17
  --------------------
16
18
  Given the context information and not prior knowledge
17
19
  answer the question: %{question}"
18
- end
20
+ @database_host = ENV['DB_HOSTNAME']
21
+ @database_port = ENV['DB_PORT']
22
+ @database_name = ENV['DB_NAME']
23
+ @database_user = ENV['DB_USER']
24
+ @database_password = ENV['DB_PASSWORD']
19
25
  end
20
26
  end
21
-
27
+ end
@@ -23,11 +23,10 @@ module BxBuilderChain::Vectorsearch
23
23
  # @param llm [Object] The LLM client to use
24
24
  # @param namespace [String] The namespace to use for the index when inserting/querying
25
25
  def initialize(llm:, namespaces: [BxBuilderChain.configuration.public_namespace] || ['public'])
26
-
27
26
  depends_on "sequel"
28
27
  require "sequel"
29
-
30
- @db = Sequel.connect(BxBuilderChain.configuration.pg_url)
28
+
29
+ @db = create_sequel_connection
31
30
  @table_name = "bx_builder_chain_embeddings"
32
31
  @namespace_column = "namespace"
33
32
  set_namespaces(namespaces)
@@ -224,5 +223,22 @@ module BxBuilderChain::Vectorsearch
224
223
  namespaces = [namespaces] unless namespaces.is_a?(Array)
225
224
  @namespaces = namespaces.push(BxBuilderChain.configuration.public_namespace).uniq
226
225
  end
226
+
227
+ def create_sequel_connection
228
+ config = BxBuilderChain.configuration
229
+
230
+ if config.pg_url
231
+ Sequel.connect(config.pg_url)
232
+ else
233
+ Sequel.connect(
234
+ adapter: 'postgres',
235
+ host: config.database_host,
236
+ database: config.database_name,
237
+ user: config.database_user,
238
+ password: config.database_password,
239
+ port: config.database_port
240
+ )
241
+ end
242
+ end
227
243
  end
228
244
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BxBuilderChain
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -1,6 +1,16 @@
1
1
  BxBuilderChain.configure do |config|
2
- config.pg_url = "your_database_url" # eg 'postgres://postgres:password@localhost:5432/my_db'
3
- config.openai_api_key = "your_openai_api_key" # eg ENV['OPENAI_API_KEY']
2
+ config.openai_api_key = ENV['OPENAI_API_KEY']
3
+
4
+ # for db use this
5
+ config.pg_url = ENV['DB_URL'] || nil # eg 'postgres://postgres:password@localhost:5432/my_db'
6
+
7
+ # or this - pg_url with take preference
8
+ config.database_host = ENV['DB_HOSTNAME'] || 'localhost'
9
+ config.database_name = ENV['DB_NAME']
10
+ config.database_user = ENV['DB_USER']
11
+ config.database_password = ENV['DB_PASSWORD']
12
+ config.database_port = ENV['DB_PORT'] || '5432' # Defaulting to 5432 if not set
13
+
4
14
  config.public_namespace = "public"
5
15
  config.threshold = 0.25
6
16
  config.default_prompt_template = "Context information is below
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bx_builder_chain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Ketelle