Class: RerankerRuby::Configuration
- Inherits:
-
Object
- Object
- RerankerRuby::Configuration
- Defined in:
- lib/reranker_ruby/configuration.rb
Instance Attribute Summary collapse
-
#cache_store ⇒ Object
Returns the value of attribute cache_store.
-
#cache_ttl ⇒ Object
Returns the value of attribute cache_ttl.
-
#cohere_api_key ⇒ Object
Returns the value of attribute cohere_api_key.
-
#default_model ⇒ Object
Returns the value of attribute default_model.
-
#default_provider ⇒ Object
Returns the value of attribute default_provider.
-
#default_top_k ⇒ Object
Returns the value of attribute default_top_k.
-
#jina_api_key ⇒ Object
Returns the value of attribute jina_api_key.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_retries ⇒ Object
Returns the value of attribute max_retries.
-
#onnx_cache_dir ⇒ Object
Returns the value of attribute onnx_cache_dir.
-
#onnx_model ⇒ Object
Returns the value of attribute onnx_model.
-
#onnx_model_path ⇒ Object
Returns the value of attribute onnx_model_path.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#voyage_api_key ⇒ Object
Returns the value of attribute voyage_api_key.
Instance Method Summary collapse
-
#build_reranker ⇒ Object
Build a reranker instance from configuration.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/reranker_ruby/configuration.rb', line 10 def initialize @default_provider = :cohere @cohere_api_key = nil @jina_api_key = nil @voyage_api_key = nil @default_model = nil @default_top_k = 10 @cache_store = nil @cache_ttl = 3600 @logger = nil @onnx_model = nil @onnx_model_path = nil @onnx_cache_dir = nil @timeout = 30 @max_retries = 3 end |
Instance Attribute Details
#cache_store ⇒ Object
Returns the value of attribute cache_store.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def cache_store @cache_store end |
#cache_ttl ⇒ Object
Returns the value of attribute cache_ttl.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def cache_ttl @cache_ttl end |
#cohere_api_key ⇒ Object
Returns the value of attribute cohere_api_key.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def cohere_api_key @cohere_api_key end |
#default_model ⇒ Object
Returns the value of attribute default_model.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def default_model @default_model end |
#default_provider ⇒ Object
Returns the value of attribute default_provider.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def default_provider @default_provider end |
#default_top_k ⇒ Object
Returns the value of attribute default_top_k.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def default_top_k @default_top_k end |
#jina_api_key ⇒ Object
Returns the value of attribute jina_api_key.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def jina_api_key @jina_api_key end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def logger @logger end |
#max_retries ⇒ Object
Returns the value of attribute max_retries.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def max_retries @max_retries end |
#onnx_cache_dir ⇒ Object
Returns the value of attribute onnx_cache_dir.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def onnx_cache_dir @onnx_cache_dir end |
#onnx_model ⇒ Object
Returns the value of attribute onnx_model.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def onnx_model @onnx_model end |
#onnx_model_path ⇒ Object
Returns the value of attribute onnx_model_path.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def onnx_model_path @onnx_model_path end |
#timeout ⇒ Object
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def timeout @timeout end |
#voyage_api_key ⇒ Object
Returns the value of attribute voyage_api_key.
5 6 7 |
# File 'lib/reranker_ruby/configuration.rb', line 5 def voyage_api_key @voyage_api_key end |
Instance Method Details
#build_reranker ⇒ Object
Build a reranker instance from configuration
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/reranker_ruby/configuration.rb', line 28 def build_reranker cache = build_cache case default_provider when :cohere raise Error, "cohere_api_key is required" unless cohere_api_key opts = { api_key: cohere_api_key, cache: cache } opts[:model] = default_model if default_model Cohere.new(**opts) when :jina raise Error, "jina_api_key is required" unless jina_api_key opts = { api_key: jina_api_key, cache: cache } opts[:model] = default_model if default_model Jina.new(**opts) when :voyage raise Error, "voyage_api_key is required" unless voyage_api_key opts = { api_key: voyage_api_key, cache: cache, timeout: timeout, max_retries: max_retries } opts[:model] = default_model if default_model Voyage.new(**opts) when :onnx opts = { cache: cache } opts[:model] = onnx_model if onnx_model opts[:model_path] = onnx_model_path if onnx_model_path opts[:cache_dir] = onnx_cache_dir if onnx_cache_dir Onnx.new(**opts) else raise Error, "Unknown provider: #{default_provider}" end end |