Class: HTM::Configuration
- Inherits:
-
Object
- Object
- HTM::Configuration
- Defined in:
- lib/htm/configuration.rb
Overview
HTM Configuration
Applications using HTM should configure LLM access by providing two methods:
-
embedding_generator - Converts text to vector embeddings
-
tag_extractor - Extracts hierarchical tags from text
-
logger - Logger instance for HTM operations
Instance Attribute Summary collapse
-
#connection_timeout ⇒ Object
Returns the value of attribute connection_timeout.
-
#embedding_dimensions ⇒ Object
Returns the value of attribute embedding_dimensions.
-
#embedding_generator ⇒ Object
Returns the value of attribute embedding_generator.
-
#embedding_model ⇒ Object
Returns the value of attribute embedding_model.
-
#embedding_provider ⇒ Object
Returns the value of attribute embedding_provider.
-
#embedding_timeout ⇒ Object
Returns the value of attribute embedding_timeout.
-
#job_backend ⇒ Object
Returns the value of attribute job_backend.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#ollama_url ⇒ Object
Returns the value of attribute ollama_url.
-
#tag_extractor ⇒ Object
Returns the value of attribute tag_extractor.
-
#tag_model ⇒ Object
Returns the value of attribute tag_model.
-
#tag_provider ⇒ Object
Returns the value of attribute tag_provider.
-
#tag_timeout ⇒ Object
Returns the value of attribute tag_timeout.
-
#token_counter ⇒ Object
Returns the value of attribute token_counter.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#reset_to_defaults ⇒ Object
Reset to default RubyLLM-based implementations.
-
#validate! ⇒ Object
Validate configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/htm/configuration.rb', line 45 def initialize # Default configuration @embedding_provider = :ollama @embedding_model = 'nomic-embed-text' @embedding_dimensions = 768 @tag_provider = :ollama @tag_model = 'llama3' @ollama_url = ENV['OLLAMA_URL'] || 'http://localhost:11434' # Timeout settings (in seconds) - apply to all LLM providers @embedding_timeout = 120 # 2 minutes for embedding generation @tag_timeout = 180 # 3 minutes for tag generation (LLM inference) @connection_timeout = 30 # 30 seconds for initial connection # Default logger (STDOUT with INFO level) @logger = default_logger # Auto-detect job backend based on environment @job_backend = detect_job_backend # Set default implementations reset_to_defaults end |
Instance Attribute Details
#connection_timeout ⇒ Object
Returns the value of attribute connection_timeout.
41 42 43 |
# File 'lib/htm/configuration.rb', line 41 def connection_timeout @connection_timeout end |
#embedding_dimensions ⇒ Object
Returns the value of attribute embedding_dimensions.
38 39 40 |
# File 'lib/htm/configuration.rb', line 38 def @embedding_dimensions end |
#embedding_generator ⇒ Object
Returns the value of attribute embedding_generator.
37 38 39 |
# File 'lib/htm/configuration.rb', line 37 def @embedding_generator end |
#embedding_model ⇒ Object
Returns the value of attribute embedding_model.
38 39 40 |
# File 'lib/htm/configuration.rb', line 38 def @embedding_model end |
#embedding_provider ⇒ Object
Returns the value of attribute embedding_provider.
38 39 40 |
# File 'lib/htm/configuration.rb', line 38 def @embedding_provider end |
#embedding_timeout ⇒ Object
Returns the value of attribute embedding_timeout.
41 42 43 |
# File 'lib/htm/configuration.rb', line 41 def @embedding_timeout end |
#job_backend ⇒ Object
Returns the value of attribute job_backend.
43 44 45 |
# File 'lib/htm/configuration.rb', line 43 def job_backend @job_backend end |
#logger ⇒ Object
Returns the value of attribute logger.
42 43 44 |
# File 'lib/htm/configuration.rb', line 42 def logger @logger end |
#ollama_url ⇒ Object
Returns the value of attribute ollama_url.
40 41 42 |
# File 'lib/htm/configuration.rb', line 40 def ollama_url @ollama_url end |
#tag_extractor ⇒ Object
Returns the value of attribute tag_extractor.
37 38 39 |
# File 'lib/htm/configuration.rb', line 37 def tag_extractor @tag_extractor end |
#tag_model ⇒ Object
Returns the value of attribute tag_model.
39 40 41 |
# File 'lib/htm/configuration.rb', line 39 def tag_model @tag_model end |
#tag_provider ⇒ Object
Returns the value of attribute tag_provider.
39 40 41 |
# File 'lib/htm/configuration.rb', line 39 def tag_provider @tag_provider end |
#tag_timeout ⇒ Object
Returns the value of attribute tag_timeout.
41 42 43 |
# File 'lib/htm/configuration.rb', line 41 def tag_timeout @tag_timeout end |
#token_counter ⇒ Object
Returns the value of attribute token_counter.
37 38 39 |
# File 'lib/htm/configuration.rb', line 37 def token_counter @token_counter end |
Instance Method Details
#reset_to_defaults ⇒ Object
Reset to default RubyLLM-based implementations
72 73 74 75 76 |
# File 'lib/htm/configuration.rb', line 72 def reset_to_defaults @embedding_generator = @tag_extractor = default_tag_extractor @token_counter = default_token_counter end |
#validate! ⇒ Object
Validate configuration
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/htm/configuration.rb', line 79 def validate! unless @embedding_generator.respond_to?(:call) raise HTM::ValidationError, "embedding_generator must be callable (proc, lambda, or object responding to :call)" end unless @tag_extractor.respond_to?(:call) raise HTM::ValidationError, "tag_extractor must be callable (proc, lambda, or object responding to :call)" end unless @token_counter.respond_to?(:call) raise HTM::ValidationError, "token_counter must be callable (proc, lambda, or object responding to :call)" end unless @logger.respond_to?(:info) && @logger.respond_to?(:warn) && @logger.respond_to?(:error) raise HTM::ValidationError, "logger must respond to :info, :warn, and :error" end unless [:active_job, :sidekiq, :inline, :thread].include?(@job_backend) raise HTM::ValidationError, "job_backend must be one of: :active_job, :sidekiq, :inline, :thread (got #{@job_backend.inspect})" end end |