Class: RubyLLM::Agents::Configuration
- Inherits:
-
Object
- Object
- RubyLLM::Agents::Configuration
- Defined in:
- lib/ruby_llm/agents/core/configuration.rb
Overview
Global configuration for RubyLLM::Agents
Provides centralized settings for agent behavior, dashboard authentication, caching, and observability thresholds.
Constant Summary collapse
- FORWARDED_RUBY_LLM_ATTRIBUTES =
API key and provider attributes forwarded to RubyLLM. These let users configure everything in one place through RubyLLM::Agents.configure instead of a separate RubyLLM.configure block.
%i[ openai_api_key anthropic_api_key gemini_api_key deepseek_api_key openrouter_api_key bedrock_api_key bedrock_secret_key bedrock_session_token bedrock_region mistral_api_key perplexity_api_key xai_api_key gpustack_api_key inception_api_key openai_api_base openai_organization_id openai_project_id gemini_api_base gpustack_api_base ollama_api_base bedrock_api_base mistral_api_base perplexity_api_base vertexai_api_base vertexai_project_id vertexai_location xai_api_base request_timeout max_retries faraday_adapter deprecation_behavior tool_concurrency ].freeze
- SENSITIVE_ATTRIBUTES =
Attribute names that contain sensitive values (API keys, passwords)
( FORWARDED_RUBY_LLM_ATTRIBUTES.select { |a| a.to_s.match?(/api_key|secret_key|session_token/) } + %i[basic_auth_password elevenlabs_api_key] ).freeze
Instance Attribute Summary collapse
-
#anomaly_cost_threshold ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#anomaly_duration_threshold ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#async_logging ⇒ Object
Attributes without validation (simple accessors).
-
#basic_auth_password ⇒ Object
Attributes without validation (simple accessors).
-
#basic_auth_username ⇒ Object
Attributes without validation (simple accessors).
-
#budgets ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#cache_store ⇒ ActiveSupport::Cache::Store
Returns the configured cache store, falling back to Rails.cache.
-
#dashboard_auth ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#dashboard_parent_controller ⇒ Object
Attributes without validation (simple accessors).
-
#default_analysis_type ⇒ Object
Attributes without validation (simple accessors).
-
#default_analyzer_max_tags ⇒ Object
Attributes without validation (simple accessors).
-
#default_analyzer_model ⇒ Object
Attributes without validation (simple accessors).
-
#default_background_output_format ⇒ Object
Attributes without validation (simple accessors).
-
#default_background_remover_model ⇒ Object
Attributes without validation (simple accessors).
-
#default_editor_model ⇒ Object
Attributes without validation (simple accessors).
-
#default_embedding_batch_size ⇒ Object
Attributes with custom setters (validation) — only readers here.
-
#default_embedding_dimensions ⇒ Object
Attributes with custom setters (validation) — only readers here.
-
#default_embedding_model ⇒ Object
Attributes without validation (simple accessors).
-
#default_fallback_models ⇒ Object
Attributes without validation (simple accessors).
-
#default_image_cost ⇒ Object
Attributes without validation (simple accessors).
-
#default_image_model ⇒ Object
Attributes without validation (simple accessors).
-
#default_image_quality ⇒ Object
Attributes without validation (simple accessors).
-
#default_image_size ⇒ Object
Attributes without validation (simple accessors).
-
#default_image_style ⇒ Object
Attributes without validation (simple accessors).
-
#default_model ⇒ Object
Attributes without validation (simple accessors).
-
#default_retries ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#default_retryable_patterns ⇒ Object
Attributes without validation (simple accessors).
-
#default_streaming ⇒ Object
Attributes without validation (simple accessors).
-
#default_temperature ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#default_thinking ⇒ Object
Attributes without validation (simple accessors).
-
#default_timeout ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#default_tool_timeout ⇒ Object
Attributes without validation (simple accessors).
-
#default_tools ⇒ Object
Attributes without validation (simple accessors).
-
#default_total_timeout ⇒ Object
Attributes without validation (simple accessors).
-
#default_transcription_cost ⇒ Object
Attributes without validation (simple accessors).
-
#default_transcription_model ⇒ Object
Attributes without validation (simple accessors).
-
#default_transform_strength ⇒ Object
Attributes without validation (simple accessors).
-
#default_transformer_model ⇒ Object
Attributes without validation (simple accessors).
-
#default_tts_cost ⇒ Object
Attributes without validation (simple accessors).
-
#default_tts_model ⇒ Object
Attributes without validation (simple accessors).
-
#default_tts_provider ⇒ Object
Attributes without validation (simple accessors).
-
#default_tts_voice ⇒ Object
Attributes without validation (simple accessors).
-
#default_upscaler_model ⇒ Object
Attributes without validation (simple accessors).
-
#default_variation_strength ⇒ Object
Attributes without validation (simple accessors).
-
#default_variator_model ⇒ Object
Attributes without validation (simple accessors).
-
#elevenlabs_api_base ⇒ Object
Attributes without validation (simple accessors).
-
#elevenlabs_api_key ⇒ Object
Attributes without validation (simple accessors).
-
#elevenlabs_base_cost_per_1k ⇒ Object
Attributes without validation (simple accessors).
-
#elevenlabs_models_cache_ttl ⇒ Object
Attributes without validation (simple accessors).
-
#hard_purge_after ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#helicone_pricing_enabled ⇒ Object
Attributes without validation (simple accessors).
-
#helicone_pricing_url ⇒ Object
Attributes without validation (simple accessors).
-
#image_model_aliases ⇒ Object
Attributes without validation (simple accessors).
-
#image_model_pricing ⇒ Object
Attributes without validation (simple accessors).
-
#job_retry_attempts ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#knowledge_path ⇒ Object
Attributes without validation (simple accessors).
-
#litellm_pricing_cache_ttl ⇒ Object
Attributes without validation (simple accessors).
-
#litellm_pricing_url ⇒ Object
Attributes without validation (simple accessors).
-
#llmpricing_enabled ⇒ Object
Attributes without validation (simple accessors).
-
#llmpricing_url ⇒ Object
Attributes without validation (simple accessors).
-
#max_image_prompt_length ⇒ Object
Attributes without validation (simple accessors).
-
#messages_summary_max_length ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#middleware_stack ⇒ Object
readonly
Attributes with custom setters (validation) — only readers here.
-
#multi_tenancy_enabled ⇒ Object
Attributes without validation (simple accessors).
-
#on_alert ⇒ Object
Attributes without validation (simple accessors).
-
#openrouter_pricing_enabled ⇒ Object
Attributes without validation (simple accessors).
-
#openrouter_pricing_url ⇒ Object
Attributes without validation (simple accessors).
-
#per_page ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#persist_audio_data ⇒ Object
Attributes without validation (simple accessors).
-
#persist_messages_summary ⇒ Object
Attributes without validation (simple accessors).
-
#persist_prompts ⇒ Object
Attributes without validation (simple accessors).
-
#persist_responses ⇒ Object
Attributes without validation (simple accessors).
-
#portkey_pricing_enabled ⇒ Object
Attributes without validation (simple accessors).
-
#portkey_pricing_url ⇒ Object
Attributes without validation (simple accessors).
-
#pricing_cache_ttl ⇒ Object
Attributes without validation (simple accessors).
-
#recent_executions_limit ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#retention_period ⇒ ActiveSupport::Duration?
deprecated
Deprecated.
Use #hard_purge_after instead.
-
#root_directory ⇒ Object
Attributes without validation (simple accessors).
-
#root_namespace ⇒ Object
Attributes without validation (simple accessors).
-
#soft_purge_after ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#tenant_config_resolver ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#tenant_resolver ⇒ Object
Attributes with validation (readers only, custom setters below).
-
#tool_result_max_length ⇒ Object
Attributes without validation (simple accessors).
-
#track_audio ⇒ Object
Attributes without validation (simple accessors).
-
#track_cache_hits ⇒ Object
Attributes without validation (simple accessors).
-
#track_embeddings ⇒ Object
Attributes without validation (simple accessors).
-
#track_executions ⇒ Object
Attributes without validation (simple accessors).
-
#track_image_generation ⇒ Object
Attributes without validation (simple accessors).
-
#track_speech ⇒ Object
Attributes without validation (simple accessors).
-
#track_transcriptions ⇒ Object
Attributes without validation (simple accessors).
-
#transcription_model_pricing ⇒ Object
Attributes without validation (simple accessors).
-
#tts_model_pricing ⇒ Object
Attributes without validation (simple accessors).
Instance Method Summary collapse
-
#all_autoload_paths ⇒ Array<String>
Returns all autoload paths for LLM components.
-
#all_retryable_patterns ⇒ Array<String>
Returns all retryable patterns as a flat array.
-
#async_available? ⇒ Boolean
Returns whether the async gem is available.
-
#async_context? ⇒ Boolean
Returns whether we’re currently inside an async context.
-
#budget_enforcement ⇒ Symbol
Returns the budget enforcement mode.
-
#budgets_enabled? ⇒ Boolean
Returns whether budgets are configured and enforcement is enabled.
-
#clear_middleware! ⇒ self
Removes all custom middleware.
-
#current_tenant_id ⇒ String?
Returns the current tenant ID from the resolver.
-
#initialize ⇒ Configuration
constructor
private
Initializes configuration with default values.
-
#inspect ⇒ String
Returns a concise string representation for debugging.
-
#multi_tenancy_enabled? ⇒ Boolean
Returns whether multi-tenancy is enabled.
-
#namespace_for(category = nil) ⇒ String?
Returns the full namespace for a given category.
-
#path_for(category, type = nil) ⇒ String
Returns the full path under app/ for a given category and type.
-
#to_h(include_sensitive: false) ⇒ Hash
Returns all configuration as a hash grouped by category.
-
#use_middleware(middleware_class, before: nil, after: nil) ⇒ self
Registers a custom middleware class for all agents.
Constructor Details
#initialize ⇒ Configuration
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes configuration with default values
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 677 def initialize @default_model = "gemini-2.0-flash" @default_temperature = 0.0 @default_timeout = 60 @cache_store = nil @async_logging = true @soft_purge_after = 30.days @hard_purge_after = 365.days @anomaly_cost_threshold = 5.00 @anomaly_duration_threshold = 10_000 @dashboard_auth = ->(_controller) { true } @dashboard_parent_controller = "ActionController::Base" @basic_auth_username = nil @basic_auth_password = nil @per_page = 25 @recent_executions_limit = 10 @job_retry_attempts = 3 # Reliability defaults (all disabled by default for backward compatibility) @default_retries = {max: 0, backoff: :exponential, base: 0.4, max_delay: 3.0, on: []} @default_fallback_models = [] @default_total_timeout = nil @default_retryable_patterns = { rate_limiting: ["rate limit", "rate_limit", "too many requests", "429", "quota"], server_errors: ["500", "502", "503", "504", "service unavailable", "internal server error", "bad gateway", "gateway timeout"], capacity: ["overloaded", "capacity"] } # Streaming, tools, and thinking defaults @default_streaming = false @default_tools = [] @default_tool_timeout = nil @default_thinking = nil # Governance defaults @budgets = nil @on_alert = nil @persist_prompts = true @persist_responses = true # Multi-tenancy defaults (disabled for backward compatibility) @multi_tenancy_enabled = false @tenant_resolver = -> {} @tenant_config_resolver = nil # Messages summary defaults @persist_messages_summary = true @messages_summary_max_length = 500 # Embedding defaults @default_embedding_model = "text-embedding-3-small" @default_embedding_dimensions = nil @default_embedding_batch_size = 100 @track_embeddings = true # Transcription defaults @default_transcription_model = "whisper-1" @track_transcriptions = true @transcription_model_pricing = {} @default_transcription_cost = nil # nil = no default, will trigger warning # Multi-source pricing defaults @pricing_cache_ttl = nil # nil = use DataStore default (24h) @portkey_pricing_enabled = true @portkey_pricing_url = nil # nil = use default @openrouter_pricing_enabled = true @openrouter_pricing_url = nil @helicone_pricing_enabled = true @helicone_pricing_url = nil @llmpricing_enabled = true @llmpricing_url = nil # TTS/Speech defaults @default_tts_provider = :openai @default_tts_model = "tts-1" @default_tts_voice = "nova" @track_speech = true # ElevenLabs defaults @elevenlabs_api_key = nil @elevenlabs_api_base = "https://api.elevenlabs.io" # TTS pricing defaults @tts_model_pricing = {} @default_tts_cost = nil # Execution/conversation agent tracking @track_executions = true @track_audio = true @track_cache_hits = true # Image Generation defaults @default_image_model = "gpt-image-1" @default_image_size = "1024x1024" @default_image_quality = "standard" @default_image_style = "vivid" @max_image_prompt_length = 4000 @track_image_generation = true @image_model_aliases = { fast: "flux-schnell", quality: "gpt-image-1", cheap: "sdxl" } # Image Pricing defaults @litellm_pricing_url = nil # Use default from Pricing module @litellm_pricing_cache_ttl = nil # Use default (24 hours) @default_image_cost = nil # User-configurable fallback cost per image @image_model_pricing = {} # User-defined pricing overrides # Phase 2: Image Variation, Editing, Transformation, Upscaling defaults @default_variator_model = nil # Falls back to default_image_model @default_editor_model = nil # Falls back to default_image_model @default_transformer_model = "sdxl" # SDXL is good for transformations @default_upscaler_model = "real-esrgan" # Real-ESRGAN for upscaling @default_variation_strength = 0.5 # How different variations should be @default_transform_strength = 0.75 # How much to transform # Phase 3: Image Analysis and Background Removal defaults @default_analyzer_model = "gpt-4o" # Vision model for analysis @default_analysis_type = :detailed # Default analysis type @default_analyzer_max_tags = 10 # Max tags to extract @default_background_remover_model = "rembg" # Default remover model @default_background_output_format = :png # Output format for transparency # Directory structure defaults @root_directory = "agents" # Root directory under app/ @root_namespace = nil # No namespace (top-level classes) # Custom middleware stack @middleware_stack = [] # Tool tracking defaults @tool_result_max_length = 10_000 # Audio data persistence (disabled by default — base64 audio can be large) @persist_audio_data = false # ElevenLabs dynamic pricing: base cost per 1K characters # Set to your plan's overage rate (e.g., 0.30 for Pro) to enable API-based pricing @elevenlabs_base_cost_per_1k = nil # ElevenLabs models cache TTL in seconds (6 hours) @elevenlabs_models_cache_ttl = 21_600 # Knowledge defaults @knowledge_path = "app/agents/knowledge" end |
Instance Attribute Details
#anomaly_cost_threshold ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 74
|
#anomaly_duration_threshold ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 79
|
#async_logging ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 48
|
#basic_auth_password ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 100
|
#basic_auth_username ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 95
|
#budgets ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 175
|
#cache_store ⇒ ActiveSupport::Cache::Store
Returns the configured cache store, falling back to Rails.cache
831 832 833 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 831 def cache_store @cache_store || Rails.cache end |
#dashboard_auth ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 83
|
#dashboard_parent_controller ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 90
|
#default_analysis_type ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_analysis_type @default_analysis_type end |
#default_analyzer_max_tags ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def @default_analyzer_max_tags end |
#default_analyzer_model ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_analyzer_model @default_analyzer_model end |
#default_background_output_format ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_background_output_format @default_background_output_format end |
#default_background_remover_model ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_background_remover_model @default_background_remover_model end |
#default_editor_model ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_editor_model @default_editor_model end |
#default_embedding_batch_size ⇒ Object
Attributes with custom setters (validation) — only readers here
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 272
|
#default_embedding_dimensions ⇒ Object
Attributes with custom setters (validation) — only readers here
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 264
|
#default_embedding_model ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 257
|
#default_fallback_models ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 139
|
#default_image_cost ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_image_cost @default_image_cost end |
#default_image_model ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_image_model @default_image_model end |
#default_image_quality ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_image_quality @default_image_quality end |
#default_image_size ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_image_size @default_image_size end |
#default_image_style ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_image_style @default_image_style end |
#default_model ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 32
|
#default_retries ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 121
|
#default_retryable_patterns ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 128
|
#default_streaming ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 149
|
#default_temperature ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 39
|
#default_thinking ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 165
|
#default_timeout ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 44
|
#default_tool_timeout ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_tool_timeout @default_tool_timeout end |
#default_tools ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 157
|
#default_total_timeout ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 144
|
#default_transcription_cost ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_transcription_cost @default_transcription_cost end |
#default_transcription_model ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 286
|
#default_transform_strength ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_transform_strength @default_transform_strength end |
#default_transformer_model ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_transformer_model @default_transformer_model end |
#default_tts_cost ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_tts_cost @default_tts_cost end |
#default_tts_model ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 307
|
#default_tts_provider ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 300
|
#default_tts_voice ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 314
|
#default_upscaler_model ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_upscaler_model @default_upscaler_model end |
#default_variation_strength ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_variation_strength @default_variation_strength end |
#default_variator_model ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def default_variator_model @default_variator_model end |
#elevenlabs_api_base ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def elevenlabs_api_base @elevenlabs_api_base end |
#elevenlabs_api_key ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def elevenlabs_api_key @elevenlabs_api_key end |
#elevenlabs_base_cost_per_1k ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def elevenlabs_base_cost_per_1k @elevenlabs_base_cost_per_1k end |
#elevenlabs_models_cache_ttl ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def elevenlabs_models_cache_ttl @elevenlabs_models_cache_ttl end |
#hard_purge_after ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 62
|
#helicone_pricing_enabled ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def helicone_pricing_enabled @helicone_pricing_enabled end |
#helicone_pricing_url ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def helicone_pricing_url @helicone_pricing_url end |
#image_model_aliases ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def image_model_aliases @image_model_aliases end |
#image_model_pricing ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def image_model_pricing @image_model_pricing end |
#job_retry_attempts ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 112
|
#knowledge_path ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def knowledge_path @knowledge_path end |
#litellm_pricing_cache_ttl ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def litellm_pricing_cache_ttl @litellm_pricing_cache_ttl end |
#litellm_pricing_url ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def litellm_pricing_url @litellm_pricing_url end |
#llmpricing_enabled ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def llmpricing_enabled @llmpricing_enabled end |
#llmpricing_url ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def llmpricing_url @llmpricing_url end |
#max_image_prompt_length ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def max_image_prompt_length @max_image_prompt_length end |
#messages_summary_max_length ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 252
|
#middleware_stack ⇒ Object (readonly)
Attributes with custom setters (validation) — only readers here
401 402 403 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 401 def middleware_stack @middleware_stack end |
#multi_tenancy_enabled ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 211
|
#on_alert ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 187
|
#openrouter_pricing_enabled ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def openrouter_pricing_enabled @openrouter_pricing_enabled end |
#openrouter_pricing_url ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def openrouter_pricing_url @openrouter_pricing_url end |
#per_page ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 104
|
#persist_audio_data ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def persist_audio_data @persist_audio_data end |
#persist_messages_summary ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 246
|
#persist_prompts ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 201
|
#persist_responses ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 206
|
#portkey_pricing_enabled ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def portkey_pricing_enabled @portkey_pricing_enabled end |
#portkey_pricing_url ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def portkey_pricing_url @portkey_pricing_url end |
#pricing_cache_ttl ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def pricing_cache_ttl @pricing_cache_ttl end |
#recent_executions_limit ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 108
|
#retention_period ⇒ ActiveSupport::Duration?
Use #hard_purge_after instead.
Deprecated alias for hard_purge_after.
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 68
|
#root_directory ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 328
|
#root_namespace ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 335
|
#soft_purge_after ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 53
|
#tenant_config_resolver ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 228
|
#tenant_resolver ⇒ Object
Attributes with validation (readers only, custom setters below)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 218
|
#tool_result_max_length ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 345
|
#track_audio ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def track_audio @track_audio end |
#track_cache_hits ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def track_cache_hits @track_cache_hits end |
#track_embeddings ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 279
|
#track_executions ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def track_executions @track_executions end |
#track_image_generation ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def track_image_generation @track_image_generation end |
#track_speech ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 321
|
#track_transcriptions ⇒ Object
Attributes without validation (simple accessors)
|
|
# File 'lib/ruby_llm/agents/core/configuration.rb', line 293
|
#transcription_model_pricing ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def transcription_model_pricing @transcription_model_pricing end |
#tts_model_pricing ⇒ Object
Attributes without validation (simple accessors)
405 406 407 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 405 def tts_model_pricing @tts_model_pricing end |
Instance Method Details
#all_autoload_paths ⇒ Array<String>
Returns all autoload paths for LLM components
1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 1109 def all_autoload_paths root = root_directory || "agents" base = "app/#{root}" [ base, "#{base}/images", "#{base}/audio", "#{base}/embedders", "#{base}/tools" ] end |
#all_retryable_patterns ⇒ Array<String>
Returns all retryable patterns as a flat array
852 853 854 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 852 def all_retryable_patterns default_retryable_patterns.values.flatten.uniq end |
#async_available? ⇒ Boolean
Returns whether the async gem is available
906 907 908 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 906 def async_available? defined?(::Async) && defined?(::Async::Semaphore) end |
#async_context? ⇒ Boolean
Returns whether we’re currently inside an async context
913 914 915 916 917 918 919 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 913 def async_context? return false unless async_available? defined?(::Async::Task) && ::Async::Task.current? rescue false end |
#budget_enforcement ⇒ Symbol
Returns the budget enforcement mode
845 846 847 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 845 def budget_enforcement budgets&.dig(:enforcement) || :none end |
#budgets_enabled? ⇒ Boolean
Returns whether budgets are configured and enforcement is enabled
838 839 840 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 838 def budgets_enabled? budgets.is_a?(Hash) && budgets[:enforcement] && budgets[:enforcement] != :none end |
#clear_middleware! ⇒ self
Removes all custom middleware
872 873 874 875 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 872 def clear_middleware! @middleware_stack = [] self end |
#current_tenant_id ⇒ String?
Returns the current tenant ID from the resolver
887 888 889 890 891 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 887 def current_tenant_id return nil unless multi_tenancy_enabled? tenant_resolver&.call end |
#inspect ⇒ String
Returns a concise string representation for debugging
896 897 898 899 900 901 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 896 def inspect "#<#{self.class} model=#{default_model.inspect} temperature=#{default_temperature} " \ "timeout=#{default_timeout} streaming=#{default_streaming} " \ "multi_tenancy=#{multi_tenancy_enabled} async_logging=#{async_logging} " \ "track_executions=#{track_executions}>" end |
#multi_tenancy_enabled? ⇒ Boolean
Returns whether multi-tenancy is enabled
880 881 882 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 880 def multi_tenancy_enabled? @multi_tenancy_enabled == true end |
#namespace_for(category = nil) ⇒ String?
Returns the full namespace for a given category
931 932 933 934 935 936 937 938 939 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 931 def namespace_for(category = nil) category_namespace = category&.to_s&.camelize if root_namespace.present? category_namespace ? "#{root_namespace}::#{category_namespace}" : root_namespace else category_namespace end end |
#path_for(category, type = nil) ⇒ String
Returns the full path under app/ for a given category and type
952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 952 def path_for(category, type = nil) root = root_directory || "agents" base = "app/#{root}" category_path = case category when :images then "images" when :audio then "audio" when :embedders then "embedders" when :text then "text" when :image then "image" end if category_path && type "#{base}/#{category_path}/#{type}" elsif category_path "#{base}/#{category_path}" elsif type "#{base}/#{type}" else base end end |
#to_h(include_sensitive: false) ⇒ Hash
Returns all configuration as a hash grouped by category
Useful for debugging in the Rails console. Sensitive values (API keys, passwords) are hidden by default.
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 991 def to_h(include_sensitive: false) { model: { default_model: default_model, default_temperature: default_temperature, default_timeout: default_timeout, default_streaming: default_streaming, default_thinking: default_thinking }, reliability: { default_retries: default_retries, default_fallback_models: default_fallback_models, default_total_timeout: default_total_timeout, default_retryable_patterns: default_retryable_patterns }, governance: { budgets: budgets, on_alert: on_alert&.class&.name, persist_prompts: persist_prompts, persist_responses: persist_responses, persist_messages_summary: , messages_summary_max_length: }, multi_tenancy: { enabled: multi_tenancy_enabled, tenant_resolver: tenant_resolver&.class&.name, tenant_config_resolver: tenant_config_resolver&.class&.name }, dashboard: { per_page: per_page, recent_executions_limit: recent_executions_limit, dashboard_parent_controller: dashboard_parent_controller, basic_auth_username: basic_auth_username, dashboard_auth: dashboard_auth&.class&.name }, logging: { async_logging: async_logging, soft_purge_after: soft_purge_after, hard_purge_after: hard_purge_after, job_retry_attempts: job_retry_attempts, track_executions: track_executions, track_cache_hits: track_cache_hits, track_audio: track_audio }, anomaly: { anomaly_cost_threshold: anomaly_cost_threshold, anomaly_duration_threshold: anomaly_duration_threshold }, tools: { default_tools: default_tools, tool_result_max_length: tool_result_max_length }, embedding: { default_embedding_model: , default_embedding_dimensions: , default_embedding_batch_size: , track_embeddings: }, transcription: { default_transcription_model: default_transcription_model, track_transcriptions: track_transcriptions, transcription_model_pricing: transcription_model_pricing, default_transcription_cost: default_transcription_cost }, speech: { default_tts_provider: default_tts_provider, default_tts_model: default_tts_model, default_tts_voice: default_tts_voice, track_speech: track_speech, tts_model_pricing: tts_model_pricing, default_tts_cost: default_tts_cost, persist_audio_data: persist_audio_data, elevenlabs_api_base: elevenlabs_api_base, elevenlabs_base_cost_per_1k: elevenlabs_base_cost_per_1k, elevenlabs_models_cache_ttl: elevenlabs_models_cache_ttl }, image: { default_image_model: default_image_model, default_image_size: default_image_size, default_image_quality: default_image_quality, default_image_style: default_image_style, max_image_prompt_length: max_image_prompt_length, track_image_generation: track_image_generation, image_model_aliases: image_model_aliases, default_image_cost: default_image_cost, image_model_pricing: image_model_pricing, default_variator_model: default_variator_model, default_editor_model: default_editor_model, default_transformer_model: default_transformer_model, default_upscaler_model: default_upscaler_model, default_variation_strength: default_variation_strength, default_transform_strength: default_transform_strength, default_analyzer_model: default_analyzer_model, default_analysis_type: default_analysis_type, default_analyzer_max_tags: , default_background_remover_model: default_background_remover_model, default_background_output_format: default_background_output_format }, pricing: { pricing_cache_ttl: pricing_cache_ttl, portkey_pricing_enabled: portkey_pricing_enabled, openrouter_pricing_enabled: openrouter_pricing_enabled, helicone_pricing_enabled: helicone_pricing_enabled, llmpricing_enabled: llmpricing_enabled, litellm_pricing_url: litellm_pricing_url, litellm_pricing_cache_ttl: litellm_pricing_cache_ttl }, directory: { root_directory: root_directory, root_namespace: root_namespace }, api_keys: include_sensitive ? sensitive_api_keys : "(hidden, pass include_sensitive: true)" } end |
#use_middleware(middleware_class, before: nil, after: nil) ⇒ self
Registers a custom middleware class for all agents
863 864 865 866 867 |
# File 'lib/ruby_llm/agents/core/configuration.rb', line 863 def use_middleware(middleware_class, before: nil, after: nil) validate_middleware_class!(middleware_class) @middleware_stack << {klass: middleware_class, before: before, after: after} self end |