Class: RubyLlmMesh::Configuration
- Inherits:
-
Object
- Object
- RubyLlmMesh::Configuration
- Defined in:
- lib/ruby_llm_mesh/configuration.rb,
sig/ruby_llm_mesh.rbs
Instance Attribute Summary collapse
-
#anthropic_api_key ⇒ String?
Returns the value of attribute anthropic_api_key.
-
#anthropic_base_url ⇒ String
Returns the value of attribute anthropic_base_url.
-
#anthropic_model ⇒ String
Returns the value of attribute anthropic_model.
-
#auto_boot_mesh ⇒ Boolean
Returns the value of attribute auto_boot_mesh.
-
#budget_enabled ⇒ Object
Returns the value of attribute budget_enabled.
-
#budget_max_tokens ⇒ Object
Returns the value of attribute budget_max_tokens.
-
#budget_max_usd ⇒ Object
Returns the value of attribute budget_max_usd.
-
#budget_prices ⇒ Object
Returns the value of attribute budget_prices.
-
#circuit_failure_threshold ⇒ Integer
Returns the value of attribute circuit_failure_threshold.
-
#circuit_reset_timeout ⇒ Integer
Returns the value of attribute circuit_reset_timeout.
-
#default_providers ⇒ Array[Symbol]
Returns the value of attribute default_providers.
-
#fallback ⇒ Boolean
Returns the value of attribute fallback.
-
#fallback_providers ⇒ Array[Symbol]
Returns the value of attribute fallback_providers.
-
#local_node_base_url ⇒ String
Returns the value of attribute local_node_base_url.
-
#local_node_model ⇒ String
Returns the value of attribute local_node_model.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_retries ⇒ Integer
Returns the value of attribute max_retries.
-
#mesh_port ⇒ Integer
Returns the value of attribute mesh_port.
-
#openai_api_key ⇒ String?
Returns the value of attribute openai_api_key.
-
#openai_base_url ⇒ String
Returns the value of attribute openai_base_url.
-
#openai_model ⇒ String
Returns the value of attribute openai_model.
-
#peer_discovery_enabled ⇒ Boolean
Returns the value of attribute peer_discovery_enabled.
-
#peer_health_interval ⇒ Object
Returns the value of attribute peer_health_interval.
-
#peer_health_path ⇒ Object
Returns the value of attribute peer_health_path.
-
#peer_health_timeout ⇒ Object
Returns the value of attribute peer_health_timeout.
-
#peer_urls ⇒ Array[String]
Returns the value of attribute peer_urls.
-
#redis_url ⇒ Object
Returns the value of attribute redis_url.
-
#retry_backoff ⇒ Float
Returns the value of attribute retry_backoff.
-
#semantic_cache_backend ⇒ Object
Returns the value of attribute semantic_cache_backend.
-
#semantic_cache_dimensions ⇒ Object
Returns the value of attribute semantic_cache_dimensions.
-
#semantic_cache_enabled ⇒ Boolean
Returns the value of attribute semantic_cache_enabled.
-
#semantic_cache_threshold ⇒ Object
Returns the value of attribute semantic_cache_threshold.
-
#semantic_cache_ttl ⇒ Object
Returns the value of attribute semantic_cache_ttl.
-
#timeout ⇒ Integer
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
21 22 23 24 25 26 27 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 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 21 def initialize @default_providers = %i[openai anthropic local_node] @fallback = true @timeout = 30 @max_retries = 1 @retry_backoff = Float(ENV.fetch("RUBY_LLM_MESH_RETRY_BACKOFF", "0.1")) @openai_api_key = ENV.fetch("OPENAI_API_KEY", nil) @openai_base_url = ENV.fetch("OPENAI_BASE_URL", "https://api.openai.com/v1") @openai_model = ENV.fetch("OPENAI_MODEL", "gpt-4o-mini") @anthropic_api_key = ENV.fetch("ANTHROPIC_API_KEY", nil) @anthropic_base_url = ENV.fetch("ANTHROPIC_BASE_URL", "https://api.anthropic.com") @anthropic_model = ENV.fetch("ANTHROPIC_MODEL", "claude-sonnet-4-5") @local_node_base_url = ENV.fetch("LOCAL_NODE_BASE_URL", "http://127.0.0.1:11434") @local_node_model = ENV.fetch("LOCAL_NODE_MODEL", "llama3.2") @circuit_failure_threshold = 3 @circuit_reset_timeout = 60 @logger = nil # Sovereign mesh / native core @mesh_port = Integer(ENV.fetch("RUBY_LLM_MESH_PORT", "4233")) @auto_boot_mesh = ENV.fetch("RUBY_LLM_MESH_AUTO_BOOT", "true") == "true" @fallback_providers = %i[openai anthropic local_node] # Semantic cache — opt-in @semantic_cache_enabled = ENV.fetch("RUBY_LLM_MESH_SEMANTIC_CACHE", "false") == "true" @semantic_cache_threshold = Float(ENV.fetch("RUBY_LLM_MESH_CACHE_THRESHOLD", "0.92")) @semantic_cache_ttl = Integer(ENV.fetch("RUBY_LLM_MESH_CACHE_TTL", "3600")) @semantic_cache_dimensions = 256 @redis_url = ENV.fetch("REDIS_URL", nil) @semantic_cache_backend = nil # Local peer mesh discovery / health @peer_discovery_enabled = ENV.fetch("RUBY_LLM_MESH_PEER_DISCOVERY", "false") == "true" peer_urls_env = ENV.fetch("RUBY_LLM_MESH_PEER_URLS", "") @peer_urls = peer_urls_env.empty? ? [] : peer_urls_env.split(",").map(&:strip).reject(&:empty?) @peer_health_interval = Integer(ENV.fetch("RUBY_LLM_MESH_PEER_HEALTH_INTERVAL", "30")) @peer_health_timeout = Integer(ENV.fetch("RUBY_LLM_MESH_PEER_HEALTH_TIMEOUT", "2")) @peer_health_path = ENV.fetch("RUBY_LLM_MESH_PEER_HEALTH_PATH", "/api/tags") # Token/cost budget guard — opt-in @budget_enabled = ENV.fetch("RUBY_LLM_MESH_BUDGET_ENABLED", "false") == "true" @budget_max_tokens = integer_env("RUBY_LLM_MESH_BUDGET_MAX_TOKENS") @budget_max_usd = float_env("RUBY_LLM_MESH_BUDGET_MAX_USD") @budget_prices = {} end |
Instance Attribute Details
#anthropic_api_key ⇒ String?
Returns the value of attribute anthropic_api_key.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def anthropic_api_key @anthropic_api_key end |
#anthropic_base_url ⇒ String
Returns the value of attribute anthropic_base_url.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def anthropic_base_url @anthropic_base_url end |
#anthropic_model ⇒ String
Returns the value of attribute anthropic_model.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def anthropic_model @anthropic_model end |
#auto_boot_mesh ⇒ Boolean
Returns the value of attribute auto_boot_mesh.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def auto_boot_mesh @auto_boot_mesh end |
#budget_enabled ⇒ Object
Returns the value of attribute budget_enabled.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def budget_enabled @budget_enabled end |
#budget_max_tokens ⇒ Object
Returns the value of attribute budget_max_tokens.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def budget_max_tokens @budget_max_tokens end |
#budget_max_usd ⇒ Object
Returns the value of attribute budget_max_usd.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def budget_max_usd @budget_max_usd end |
#budget_prices ⇒ Object
Returns the value of attribute budget_prices.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def budget_prices @budget_prices end |
#circuit_failure_threshold ⇒ Integer
Returns the value of attribute circuit_failure_threshold.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def circuit_failure_threshold @circuit_failure_threshold end |
#circuit_reset_timeout ⇒ Integer
Returns the value of attribute circuit_reset_timeout.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def circuit_reset_timeout @circuit_reset_timeout end |
#default_providers ⇒ Array[Symbol]
Returns the value of attribute default_providers.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def default_providers @default_providers end |
#fallback ⇒ Boolean
Returns the value of attribute fallback.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def fallback @fallback end |
#fallback_providers ⇒ Array[Symbol]
Returns the value of attribute fallback_providers.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def fallback_providers @fallback_providers end |
#local_node_base_url ⇒ String
Returns the value of attribute local_node_base_url.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def local_node_base_url @local_node_base_url end |
#local_node_model ⇒ String
Returns the value of attribute local_node_model.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def local_node_model @local_node_model end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def logger @logger end |
#max_retries ⇒ Integer
Returns the value of attribute max_retries.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def max_retries @max_retries end |
#mesh_port ⇒ Integer
Returns the value of attribute mesh_port.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def mesh_port @mesh_port end |
#openai_api_key ⇒ String?
Returns the value of attribute openai_api_key.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def openai_api_key @openai_api_key end |
#openai_base_url ⇒ String
Returns the value of attribute openai_base_url.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def openai_base_url @openai_base_url end |
#openai_model ⇒ String
Returns the value of attribute openai_model.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def openai_model @openai_model end |
#peer_discovery_enabled ⇒ Boolean
Returns the value of attribute peer_discovery_enabled.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def peer_discovery_enabled @peer_discovery_enabled end |
#peer_health_interval ⇒ Object
Returns the value of attribute peer_health_interval.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def peer_health_interval @peer_health_interval end |
#peer_health_path ⇒ Object
Returns the value of attribute peer_health_path.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def peer_health_path @peer_health_path end |
#peer_health_timeout ⇒ Object
Returns the value of attribute peer_health_timeout.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def peer_health_timeout @peer_health_timeout end |
#peer_urls ⇒ Array[String]
Returns the value of attribute peer_urls.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def peer_urls @peer_urls end |
#redis_url ⇒ Object
Returns the value of attribute redis_url.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def redis_url @redis_url end |
#retry_backoff ⇒ Float
Returns the value of attribute retry_backoff.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def retry_backoff @retry_backoff end |
#semantic_cache_backend ⇒ Object
Returns the value of attribute semantic_cache_backend.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def semantic_cache_backend @semantic_cache_backend end |
#semantic_cache_dimensions ⇒ Object
Returns the value of attribute semantic_cache_dimensions.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def semantic_cache_dimensions @semantic_cache_dimensions end |
#semantic_cache_enabled ⇒ Boolean
Returns the value of attribute semantic_cache_enabled.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def semantic_cache_enabled @semantic_cache_enabled end |
#semantic_cache_threshold ⇒ Object
Returns the value of attribute semantic_cache_threshold.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def semantic_cache_threshold @semantic_cache_threshold end |
#semantic_cache_ttl ⇒ Object
Returns the value of attribute semantic_cache_ttl.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def semantic_cache_ttl @semantic_cache_ttl end |
#timeout ⇒ Integer
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/ruby_llm_mesh/configuration.rb', line 5 def timeout @timeout end |