Class: RubyLlmMesh::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm_mesh/configuration.rb,
sig/ruby_llm_mesh.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_keyString?

Returns the value of attribute anthropic_api_key.

Returns:

  • (String, nil)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def anthropic_api_key
  @anthropic_api_key
end

#anthropic_base_urlString

Returns the value of attribute anthropic_base_url.

Returns:

  • (String)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def anthropic_base_url
  @anthropic_base_url
end

#anthropic_modelString

Returns the value of attribute anthropic_model.

Returns:

  • (String)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def anthropic_model
  @anthropic_model
end

#auto_boot_meshBoolean

Returns the value of attribute auto_boot_mesh.

Returns:

  • (Boolean)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def auto_boot_mesh
  @auto_boot_mesh
end

#budget_enabledObject

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_tokensObject

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_usdObject

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_pricesObject

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_thresholdInteger

Returns the value of attribute circuit_failure_threshold.

Returns:

  • (Integer)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def circuit_failure_threshold
  @circuit_failure_threshold
end

#circuit_reset_timeoutInteger

Returns the value of attribute circuit_reset_timeout.

Returns:

  • (Integer)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def circuit_reset_timeout
  @circuit_reset_timeout
end

#default_providersArray[Symbol]

Returns the value of attribute default_providers.

Returns:

  • (Array[Symbol])


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def default_providers
  @default_providers
end

#fallbackBoolean

Returns the value of attribute fallback.

Returns:

  • (Boolean)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def fallback
  @fallback
end

#fallback_providersArray[Symbol]

Returns the value of attribute fallback_providers.

Returns:

  • (Array[Symbol])


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def fallback_providers
  @fallback_providers
end

#local_node_base_urlString

Returns the value of attribute local_node_base_url.

Returns:

  • (String)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def local_node_base_url
  @local_node_base_url
end

#local_node_modelString

Returns the value of attribute local_node_model.

Returns:

  • (String)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def local_node_model
  @local_node_model
end

#loggerObject

Returns the value of attribute logger.

Returns:

  • (Object)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def logger
  @logger
end

#max_retriesInteger

Returns the value of attribute max_retries.

Returns:

  • (Integer)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def max_retries
  @max_retries
end

#mesh_portInteger

Returns the value of attribute mesh_port.

Returns:

  • (Integer)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def mesh_port
  @mesh_port
end

#openai_api_keyString?

Returns the value of attribute openai_api_key.

Returns:

  • (String, nil)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def openai_api_key
  @openai_api_key
end

#openai_base_urlString

Returns the value of attribute openai_base_url.

Returns:

  • (String)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def openai_base_url
  @openai_base_url
end

#openai_modelString

Returns the value of attribute openai_model.

Returns:

  • (String)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def openai_model
  @openai_model
end

#peer_discovery_enabledBoolean

Returns the value of attribute peer_discovery_enabled.

Returns:

  • (Boolean)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def peer_discovery_enabled
  @peer_discovery_enabled
end

#peer_health_intervalObject

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_pathObject

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_timeoutObject

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_urlsArray[String]

Returns the value of attribute peer_urls.

Returns:

  • (Array[String])


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def peer_urls
  @peer_urls
end

#redis_urlObject

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_backoffFloat

Returns the value of attribute retry_backoff.

Returns:

  • (Float)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def retry_backoff
  @retry_backoff
end

#semantic_cache_backendObject

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_dimensionsObject

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_enabledBoolean

Returns the value of attribute semantic_cache_enabled.

Returns:

  • (Boolean)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def semantic_cache_enabled
  @semantic_cache_enabled
end

#semantic_cache_thresholdObject

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_ttlObject

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

#timeoutInteger

Returns the value of attribute timeout.

Returns:

  • (Integer)


5
6
7
# File 'lib/ruby_llm_mesh/configuration.rb', line 5

def timeout
  @timeout
end