Class: Raif::Configuration
- Inherits:
-
Object
- Object
- Raif::Configuration
- Defined in:
- lib/raif/configuration.rb
Instance Attribute Summary collapse
-
#agent_types ⇒ Object
Returns the value of attribute agent_types.
-
#anthropic_api_key ⇒ Object
Returns the value of attribute anthropic_api_key.
-
#anthropic_message_batches_beta_header ⇒ Object
Returns the value of attribute anthropic_message_batches_beta_header.
-
#anthropic_models_enabled ⇒ Object
Returns the value of attribute anthropic_models_enabled.
-
#archive_enabled ⇒ Object
Returns the value of attribute archive_enabled.
-
#archive_partition_column ⇒ Object
Returns the value of attribute archive_partition_column.
-
#archive_partition_fallback ⇒ Object
Returns the value of attribute archive_partition_fallback.
-
#archive_storage ⇒ Object
Returns the value of attribute archive_storage.
-
#authorize_admin_controller_action ⇒ Object
Returns the value of attribute authorize_admin_controller_action.
-
#authorize_controller_action ⇒ Object
Returns the value of attribute authorize_controller_action.
-
#aws_bedrock_model_name_prefix ⇒ Object
Returns the value of attribute aws_bedrock_model_name_prefix.
-
#aws_bedrock_region ⇒ Object
Returns the value of attribute aws_bedrock_region.
-
#bedrock_embedding_models_enabled ⇒ Object
(also: #aws_bedrock_titan_embedding_models_enabled)
Returns the value of attribute bedrock_embedding_models_enabled.
-
#bedrock_models_enabled ⇒ Object
(also: #anthropic_bedrock_models_enabled)
Returns the value of attribute bedrock_models_enabled.
-
#conversation_entries_controller ⇒ Object
Returns the value of attribute conversation_entries_controller.
-
#conversation_entry_max_retries ⇒ Object
Returns the value of attribute conversation_entry_max_retries.
-
#conversation_llm_messages_max_length_default ⇒ Object
Returns the value of attribute conversation_llm_messages_max_length_default.
-
#conversation_system_prompt_intro ⇒ Object
Returns the value of attribute conversation_system_prompt_intro.
-
#conversation_types ⇒ Object
Returns the value of attribute conversation_types.
-
#conversations_controller ⇒ Object
Returns the value of attribute conversations_controller.
-
#current_user_method ⇒ Object
Returns the value of attribute current_user_method.
-
#default_embedding_model_key ⇒ Object
Returns the value of attribute default_embedding_model_key.
-
#default_llm_model_key ⇒ Object
Returns the value of attribute default_llm_model_key.
-
#evals_default_llm_judge_model_key ⇒ Object
Returns the value of attribute evals_default_llm_judge_model_key.
-
#evals_verbose_output ⇒ Object
Returns the value of attribute evals_verbose_output.
-
#google_api_key ⇒ Object
Returns the value of attribute google_api_key.
-
#google_embedding_models_enabled ⇒ Object
Returns the value of attribute google_embedding_models_enabled.
-
#google_models_enabled ⇒ Object
Returns the value of attribute google_models_enabled.
-
#inference_cost_event_metadata ⇒ Object
Returns the value of attribute inference_cost_event_metadata.
-
#inference_cost_events_enabled ⇒ Object
Returns the value of attribute inference_cost_events_enabled.
-
#llm_api_requests_enabled ⇒ Object
Returns the value of attribute llm_api_requests_enabled.
-
#llm_request_max_retries ⇒ Object
Returns the value of attribute llm_request_max_retries.
-
#llm_request_retriable_exceptions ⇒ Object
Returns the value of attribute llm_request_retriable_exceptions.
-
#model_completion_authorizer ⇒ Object
Returns the value of attribute model_completion_authorizer.
-
#model_completion_batch_max_age ⇒ Object
Returns the value of attribute model_completion_batch_max_age.
-
#model_completion_batch_poll_schedule ⇒ Object
Returns the value of attribute model_completion_batch_poll_schedule.
-
#model_completion_retention_period ⇒ Object
Returns the value of attribute model_completion_retention_period.
-
#model_superclass ⇒ Object
Returns the value of attribute model_superclass.
-
#open_ai_api_key ⇒ Object
Returns the value of attribute open_ai_api_key.
-
#open_ai_api_version ⇒ Object
Returns the value of attribute open_ai_api_version.
-
#open_ai_auth_header_style ⇒ Object
Returns the value of attribute open_ai_auth_header_style.
-
#open_ai_base_url ⇒ Object
Returns the value of attribute open_ai_base_url.
-
#open_ai_batch_completion_window ⇒ Object
Returns the value of attribute open_ai_batch_completion_window.
-
#open_ai_embedding_base_url ⇒ Object
Returns the value of attribute open_ai_embedding_base_url.
-
#open_ai_embedding_models_enabled ⇒ Object
Returns the value of attribute open_ai_embedding_models_enabled.
-
#open_ai_models_enabled ⇒ Object
Returns the value of attribute open_ai_models_enabled.
-
#open_router_api_key ⇒ Object
Returns the value of attribute open_router_api_key.
-
#open_router_app_name ⇒ Object
Returns the value of attribute open_router_app_name.
-
#open_router_models_enabled ⇒ Object
Returns the value of attribute open_router_models_enabled.
-
#open_router_site_url ⇒ Object
Returns the value of attribute open_router_site_url.
-
#prompt_studio_runs_enabled ⇒ Object
Returns the value of attribute prompt_studio_runs_enabled.
-
#request_open_timeout ⇒ Object
Returns the value of attribute request_open_timeout.
-
#request_read_timeout ⇒ Object
Returns the value of attribute request_read_timeout.
-
#request_write_timeout ⇒ Object
Returns the value of attribute request_write_timeout.
-
#streaming_unsupported_model_keys ⇒ Object
Returns the value of attribute streaming_unsupported_model_keys.
-
#streaming_update_chunk_size_threshold ⇒ Object
Returns the value of attribute streaming_update_chunk_size_threshold.
-
#task_creator_optional ⇒ Object
Returns the value of attribute task_creator_optional.
-
#task_system_prompt_intro ⇒ Object
Returns the value of attribute task_system_prompt_intro.
-
#user_tool_types ⇒ Object
Returns the value of attribute user_tool_types.
-
#x_ai_api_key ⇒ Object
Returns the value of attribute x_ai_api_key.
-
#x_ai_base_url ⇒ Object
Returns the value of attribute x_ai_base_url.
-
#x_ai_models_enabled ⇒ Object
Returns the value of attribute x_ai_models_enabled.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/raif/configuration.rb', line 74 def initialize @agent_types = Set.new(["Raif::Agents::NativeToolCallingAgent"]) @anthropic_api_key = default_disable_llm_api_requests? ? "placeholder-anthropic-api-key" : ENV["ANTHROPIC_API_KEY"] @anthropic_message_batches_beta_header = "message-batches-2024-09-24" @bedrock_models_enabled = false @anthropic_models_enabled = ENV["ANTHROPIC_API_KEY"].present? @authorize_admin_controller_action = ->{ false } @authorize_controller_action = ->{ false } @aws_bedrock_region = "us-east-1" @aws_bedrock_model_name_prefix = "us" # Master switch for the archive-and-cull capability. Explicit opt-in # only: with the default false (and no archive_storage adapter), # upgrading the gem never deletes anything. @archive_enabled = false # Column on the archived resource (e.g. :account_id) whose value # partitions archive objects: every object then holds records from # exactly one partition and is stored under a per-partition key # prefix, so Raif::Archive.purge_partition! can completely erase one # partition's archives. nil (the default) preserves unpartitioned # behavior. The column's value must be immutable for the record's # lifetime. Column existence is validated when the archive job or # dry_run executes, not at boot. @archive_partition_column = nil # Applies only when archive_partition_column is set: what to do with a # record whose partition value is NULL or normalizes to blank. nil # (the default) fails closed: the record is never archived, so a later # partition purge cannot miss records that lost their attribution. # Hosts with intentionally global/unowned records may explicitly set # Raif::ArchivePartition::UNGROUPED (aliased as Raif::Archive::UNGROUPED # for post-boot callers) to archive them under the reserved # "_ungrouped" storage segment, which purge_partition! never touches. @archive_partition_fallback = nil # Storage adapter instance implementing # write(key:, io:, checksum_sha256:), returning a location string and # raising on any failure. See Raif::ArchiveStorage::FileSystem for a # reference implementation; production hosts typically supply their own # (e.g. S3-backed) adapter. @archive_storage = nil @bedrock_embedding_models_enabled = false @task_system_prompt_intro = "You are a helpful assistant." @conversation_entries_controller = "Raif::ConversationEntriesController" @conversation_entry_max_retries = 2 @conversation_llm_messages_max_length_default = 50 @conversation_system_prompt_intro = "You are a helpful assistant who is collaborating with a teammate." @conversation_types = Set.new(["Raif::Conversation"]) @conversations_controller = "Raif::ConversationsController" @current_user_method = :current_user @default_embedding_model_key = "open_ai_text_embedding_3_small" @default_llm_model_key = default_disable_llm_api_requests? ? :raif_test_llm : (ENV["RAIF_DEFAULT_LLM_MODEL_KEY"].presence || "open_ai_gpt_4o") @evals_default_llm_judge_model_key = ENV["RAIF_EVALS_DEFAULT_LLM_JUDGE_MODEL_KEY"].presence @evals_verbose_output = false google_api_key = ENV["GOOGLE_AI_API_KEY"].presence || ENV["GOOGLE_API_KEY"] @google_api_key = default_disable_llm_api_requests? ? "placeholder-google-api-key" : google_api_key @google_embedding_models_enabled = false @google_models_enabled = @google_api_key.present? # Optional callable receiving a model_completion: keyword argument and # returning a hash merged into Raif::InferenceCostEvent#metadata at sync # time. The sanctioned host extension point for attaching app-specific # context (e.g. account/workflow ids) to cost events. @inference_cost_event_metadata = nil # When true, a durable Raif::InferenceCostEvent is created for each # model completion that reaches a terminal state (completed or failed). @inference_cost_events_enabled = true @llm_api_requests_enabled = !default_disable_llm_api_requests? @llm_request_max_retries = 2 @llm_request_retriable_exceptions = [ Faraday::ConnectionFailed, Faraday::TimeoutError, Faraday::ServerError, Net::ReadTimeout, Net::OpenTimeout, Raif::Errors::BlankResponseError, ] # Schedule for the self-rescheduling Raif::PollModelCompletionBatchJob. # The Nth poll waits poll_schedule[N] (clamped to the last entry once exhausted). @model_completion_batch_poll_schedule = [ 60.seconds, 2.minutes, 5.minutes, 10.minutes, 30.minutes ] # Optional lambda called with llm:/source: keyword args at the start of # Raif::Llm#chat, before the Raif::ModelCompletion is created or any # provider API call is made. Raise from it to veto the request (e.g. a # host app enforcing per-account usage limits); the exception propagates # to the caller. Return values are ignored. Does not apply to embedding # generation or batch API submissions. @model_completion_authorizer = nil # Hard ceiling for any non-terminal Raif::ModelCompletionBatch. Older # batches are expired by the hourly safety sweep # (Raif::ExpireStuckModelCompletionBatchesJob) and the polling job's # max_age_exceeded? branch: a best-effort provider-side cancel is issued # via batch.cancel! before the batch is force-failed locally, so the # workflow can advance and we stop paying for completions we won't read. # If the cancel fails (network, 5xx, etc.), the local force-fail still # happens and the provider-side batch may continue and be billed. @model_completion_batch_max_age = 26.hours # How long completed/failed Raif::ModelCompletion rows are retained # before Raif::ArchiveModelCompletionsJob archives and deletes them # (e.g. 6.months). nil (the default) disables model completion culling # even when archive_enabled is true. validate! rejects values below # 1.month: cost and budget consumers aggregate by billing period, so an # accidentally tiny retention value must never be able to eat rows out # from under an open billing window. @model_completion_retention_period = nil @model_superclass = "ApplicationRecord" @open_ai_api_key = default_disable_llm_api_requests? ? "placeholder-open-ai-api-key" : ENV["OPENAI_API_KEY"] @open_ai_api_version = nil @open_ai_batch_completion_window = "24h" @open_ai_auth_header_style = :bearer @open_ai_base_url = "https://api.openai.com/v1" @open_ai_embedding_base_url = "https://api.openai.com/v1" @open_ai_embedding_models_enabled = ENV["OPENAI_API_KEY"].present? @open_ai_models_enabled = ENV["OPENAI_API_KEY"].present? open_router_api_key = ENV["OPEN_ROUTER_API_KEY"].presence || ENV["OPENROUTER_API_KEY"] @open_router_api_key = default_disable_llm_api_requests? ? "placeholder-open-router-api-key" : open_router_api_key @open_router_models_enabled = @open_router_api_key.present? @prompt_studio_runs_enabled = Rails.env.development? @open_router_app_name = nil @open_router_site_url = nil @request_open_timeout = nil @request_read_timeout = nil @request_write_timeout = nil # Raif model keys whose streaming path is known to be unreliable. When a # caller passes a block to Raif::Llm#chat for one of these models, Raif # transparently falls back to the non-streaming path. Each entry may be # a String, Symbol, or Regexp matched against the model key. # # Default covers Bedrock gpt-oss, whose Converse streaming endpoint # delivers corrupted/truncated tool_use deltas. Set to [] to disable # the workaround. @streaming_unsupported_model_keys = [/\Abedrock_gpt_oss_/] @streaming_update_chunk_size_threshold = 25 @task_creator_optional = true @user_tool_types = [] x_ai_api_key = ENV["XAI_API_KEY"].presence || ENV["X_AI_API_KEY"] @x_ai_api_key = default_disable_llm_api_requests? ? "placeholder-x-ai-api-key" : x_ai_api_key @x_ai_base_url = "https://api.x.ai/v1" @x_ai_models_enabled = @x_ai_api_key.present? end |
Instance Attribute Details
#agent_types ⇒ Object
Returns the value of attribute agent_types.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def agent_types @agent_types end |
#anthropic_api_key ⇒ Object
Returns the value of attribute anthropic_api_key.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def anthropic_api_key @anthropic_api_key end |
#anthropic_message_batches_beta_header ⇒ Object
Returns the value of attribute anthropic_message_batches_beta_header.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def @anthropic_message_batches_beta_header end |
#anthropic_models_enabled ⇒ Object
Returns the value of attribute anthropic_models_enabled.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def anthropic_models_enabled @anthropic_models_enabled end |
#archive_enabled ⇒ Object
Returns the value of attribute archive_enabled.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def archive_enabled @archive_enabled end |
#archive_partition_column ⇒ Object
Returns the value of attribute archive_partition_column.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def archive_partition_column @archive_partition_column end |
#archive_partition_fallback ⇒ Object
Returns the value of attribute archive_partition_fallback.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def archive_partition_fallback @archive_partition_fallback end |
#archive_storage ⇒ Object
Returns the value of attribute archive_storage.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def archive_storage @archive_storage end |
#authorize_admin_controller_action ⇒ Object
Returns the value of attribute authorize_admin_controller_action.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def @authorize_admin_controller_action end |
#authorize_controller_action ⇒ Object
Returns the value of attribute authorize_controller_action.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def @authorize_controller_action end |
#aws_bedrock_model_name_prefix ⇒ Object
Returns the value of attribute aws_bedrock_model_name_prefix.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def aws_bedrock_model_name_prefix @aws_bedrock_model_name_prefix end |
#aws_bedrock_region ⇒ Object
Returns the value of attribute aws_bedrock_region.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def aws_bedrock_region @aws_bedrock_region end |
#bedrock_embedding_models_enabled ⇒ Object Also known as: aws_bedrock_titan_embedding_models_enabled
Returns the value of attribute bedrock_embedding_models_enabled.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def @bedrock_embedding_models_enabled end |
#bedrock_models_enabled ⇒ Object Also known as: anthropic_bedrock_models_enabled
Returns the value of attribute bedrock_models_enabled.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def bedrock_models_enabled @bedrock_models_enabled end |
#conversation_entries_controller ⇒ Object
Returns the value of attribute conversation_entries_controller.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def conversation_entries_controller @conversation_entries_controller end |
#conversation_entry_max_retries ⇒ Object
Returns the value of attribute conversation_entry_max_retries.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def conversation_entry_max_retries @conversation_entry_max_retries end |
#conversation_llm_messages_max_length_default ⇒ Object
Returns the value of attribute conversation_llm_messages_max_length_default.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def @conversation_llm_messages_max_length_default end |
#conversation_system_prompt_intro ⇒ Object
Returns the value of attribute conversation_system_prompt_intro.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def conversation_system_prompt_intro @conversation_system_prompt_intro end |
#conversation_types ⇒ Object
Returns the value of attribute conversation_types.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def conversation_types @conversation_types end |
#conversations_controller ⇒ Object
Returns the value of attribute conversations_controller.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def conversations_controller @conversations_controller end |
#current_user_method ⇒ Object
Returns the value of attribute current_user_method.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def current_user_method @current_user_method end |
#default_embedding_model_key ⇒ Object
Returns the value of attribute default_embedding_model_key.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def @default_embedding_model_key end |
#default_llm_model_key ⇒ Object
Returns the value of attribute default_llm_model_key.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def default_llm_model_key @default_llm_model_key end |
#evals_default_llm_judge_model_key ⇒ Object
Returns the value of attribute evals_default_llm_judge_model_key.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def evals_default_llm_judge_model_key @evals_default_llm_judge_model_key end |
#evals_verbose_output ⇒ Object
Returns the value of attribute evals_verbose_output.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def evals_verbose_output @evals_verbose_output end |
#google_api_key ⇒ Object
Returns the value of attribute google_api_key.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def google_api_key @google_api_key end |
#google_embedding_models_enabled ⇒ Object
Returns the value of attribute google_embedding_models_enabled.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def @google_embedding_models_enabled end |
#google_models_enabled ⇒ Object
Returns the value of attribute google_models_enabled.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def google_models_enabled @google_models_enabled end |
#inference_cost_event_metadata ⇒ Object
Returns the value of attribute inference_cost_event_metadata.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def @inference_cost_event_metadata end |
#inference_cost_events_enabled ⇒ Object
Returns the value of attribute inference_cost_events_enabled.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def inference_cost_events_enabled @inference_cost_events_enabled end |
#llm_api_requests_enabled ⇒ Object
Returns the value of attribute llm_api_requests_enabled.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def llm_api_requests_enabled @llm_api_requests_enabled end |
#llm_request_max_retries ⇒ Object
Returns the value of attribute llm_request_max_retries.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def llm_request_max_retries @llm_request_max_retries end |
#llm_request_retriable_exceptions ⇒ Object
Returns the value of attribute llm_request_retriable_exceptions.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def llm_request_retriable_exceptions @llm_request_retriable_exceptions end |
#model_completion_authorizer ⇒ Object
Returns the value of attribute model_completion_authorizer.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def @model_completion_authorizer end |
#model_completion_batch_max_age ⇒ Object
Returns the value of attribute model_completion_batch_max_age.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def model_completion_batch_max_age @model_completion_batch_max_age end |
#model_completion_batch_poll_schedule ⇒ Object
Returns the value of attribute model_completion_batch_poll_schedule.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def model_completion_batch_poll_schedule @model_completion_batch_poll_schedule end |
#model_completion_retention_period ⇒ Object
Returns the value of attribute model_completion_retention_period.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def model_completion_retention_period @model_completion_retention_period end |
#model_superclass ⇒ Object
Returns the value of attribute model_superclass.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def model_superclass @model_superclass end |
#open_ai_api_key ⇒ Object
Returns the value of attribute open_ai_api_key.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def open_ai_api_key @open_ai_api_key end |
#open_ai_api_version ⇒ Object
Returns the value of attribute open_ai_api_version.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def open_ai_api_version @open_ai_api_version end |
#open_ai_auth_header_style ⇒ Object
Returns the value of attribute open_ai_auth_header_style.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def open_ai_auth_header_style @open_ai_auth_header_style end |
#open_ai_base_url ⇒ Object
Returns the value of attribute open_ai_base_url.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def open_ai_base_url @open_ai_base_url end |
#open_ai_batch_completion_window ⇒ Object
Returns the value of attribute open_ai_batch_completion_window.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def open_ai_batch_completion_window @open_ai_batch_completion_window end |
#open_ai_embedding_base_url ⇒ Object
Returns the value of attribute open_ai_embedding_base_url.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def @open_ai_embedding_base_url end |
#open_ai_embedding_models_enabled ⇒ Object
Returns the value of attribute open_ai_embedding_models_enabled.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def @open_ai_embedding_models_enabled end |
#open_ai_models_enabled ⇒ Object
Returns the value of attribute open_ai_models_enabled.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def open_ai_models_enabled @open_ai_models_enabled end |
#open_router_api_key ⇒ Object
Returns the value of attribute open_router_api_key.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def open_router_api_key @open_router_api_key end |
#open_router_app_name ⇒ Object
Returns the value of attribute open_router_app_name.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def open_router_app_name @open_router_app_name end |
#open_router_models_enabled ⇒ Object
Returns the value of attribute open_router_models_enabled.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def open_router_models_enabled @open_router_models_enabled end |
#open_router_site_url ⇒ Object
Returns the value of attribute open_router_site_url.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def open_router_site_url @open_router_site_url end |
#prompt_studio_runs_enabled ⇒ Object
Returns the value of attribute prompt_studio_runs_enabled.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def prompt_studio_runs_enabled @prompt_studio_runs_enabled end |
#request_open_timeout ⇒ Object
Returns the value of attribute request_open_timeout.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def request_open_timeout @request_open_timeout end |
#request_read_timeout ⇒ Object
Returns the value of attribute request_read_timeout.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def request_read_timeout @request_read_timeout end |
#request_write_timeout ⇒ Object
Returns the value of attribute request_write_timeout.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def request_write_timeout @request_write_timeout end |
#streaming_unsupported_model_keys ⇒ Object
Returns the value of attribute streaming_unsupported_model_keys.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def streaming_unsupported_model_keys @streaming_unsupported_model_keys end |
#streaming_update_chunk_size_threshold ⇒ Object
Returns the value of attribute streaming_update_chunk_size_threshold.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def streaming_update_chunk_size_threshold @streaming_update_chunk_size_threshold end |
#task_creator_optional ⇒ Object
Returns the value of attribute task_creator_optional.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def task_creator_optional @task_creator_optional end |
#task_system_prompt_intro ⇒ Object
Returns the value of attribute task_system_prompt_intro.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def task_system_prompt_intro @task_system_prompt_intro end |
#user_tool_types ⇒ Object
Returns the value of attribute user_tool_types.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def user_tool_types @user_tool_types end |
#x_ai_api_key ⇒ Object
Returns the value of attribute x_ai_api_key.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def x_ai_api_key @x_ai_api_key end |
#x_ai_base_url ⇒ Object
Returns the value of attribute x_ai_base_url.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def x_ai_base_url @x_ai_base_url end |
#x_ai_models_enabled ⇒ Object
Returns the value of attribute x_ai_models_enabled.
5 6 7 |
# File 'lib/raif/configuration.rb', line 5 def x_ai_models_enabled @x_ai_models_enabled end |
Instance Method Details
#validate! ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/raif/configuration.rb', line 216 def validate! # Before the LLM-registry early return below: archive validation guards # a destructive path (culling), so a node with no LLM API keys (e.g. a # misconfigured cron/worker box) must still have its archive settings # validated. validate_archive_config! if Raif.llm_registry.blank? puts <<~EOS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! No LLMs are enabled in Raif. Make sure you have an API key configured for at least one LLM provider. You can do this by setting an API key in your environment variables or in config/initializers/raif.rb (e.g. ENV["OPENAI_API_KEY"], ENV["ANTHROPIC_API_KEY"], ENV["OPEN_ROUTER_API_KEY"]). See the README for more information: https://github.com/CultivateLabs/raif#setup !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! EOS return end unless Raif.available_llm_keys.include?(default_llm_model_key.to_sym) raise Raif::Errors::InvalidConfigError, "Raif.config.default_llm_model_key was set to #{default_llm_model_key}, but must be one of: #{Raif.available_llm_keys.join(", ")}" end if .present? && Raif..present? && !Raif..include?(.to_sym) raise Raif::Errors::InvalidConfigError, "Raif.config.default_embedding_model_key was set to #{}, but must be one of: #{Raif..join(", ")}" # rubocop:disable Layout/LineLength end if .respond_to?(:call) .freeze else raise Raif::Errors::InvalidConfigError, "Raif.config.authorize_controller_action must respond to :call and return a boolean" end if .respond_to?(:call) .freeze else raise Raif::Errors::InvalidConfigError, "Raif.config.authorize_admin_controller_action must respond to :call and return a boolean" end if .nil? || .respond_to?(:call) &.freeze else raise Raif::Errors::InvalidConfigError, "Raif.config.model_completion_authorizer must be nil or respond to :call" end if open_ai_models_enabled && open_ai_api_key.blank? raise Raif::Errors::InvalidConfigError, "Raif.config.open_ai_api_key is required when Raif.config.open_ai_models_enabled is true. Set it via Raif.config.open_ai_api_key or ENV[\"OPENAI_API_KEY\"]" # rubocop:disable Layout/LineLength end if open_ai_models_enabled && ![:bearer, :api_key].include?(open_ai_auth_header_style) raise Raif::Errors::InvalidConfigError, "Raif.config.open_ai_auth_header_style must be either :bearer or :api_key" end if && open_ai_api_key.blank? raise Raif::Errors::InvalidConfigError, "Raif.config.open_ai_api_key is required when Raif.config.open_ai_embedding_models_enabled is true. Set it via Raif.config.open_ai_api_key or ENV[\"OPENAI_API_KEY\"]" # rubocop:disable Layout/LineLength end if anthropic_models_enabled && anthropic_api_key.blank? raise Raif::Errors::InvalidConfigError, "Raif.config.anthropic_api_key is required when Raif.config.anthropic_models_enabled is true. Set it via Raif.config.anthropic_api_key or ENV['ANTHROPIC_API_KEY']" # rubocop:disable Layout/LineLength end if open_router_models_enabled && open_router_api_key.blank? raise Raif::Errors::InvalidConfigError, "Raif.config.open_router_api_key is required when Raif.config.open_router_models_enabled is true. Set it via Raif.config.open_router_api_key or ENV['OPEN_ROUTER_API_KEY']" # rubocop:disable Layout/LineLength end if google_models_enabled && google_api_key.blank? raise Raif::Errors::InvalidConfigError, "Raif.config.google_api_key is required when Raif.config.google_models_enabled is true. Set it via Raif.config.google_api_key or ENV['GOOGLE_API_KEY']" # rubocop:disable Layout/LineLength end if && google_api_key.blank? raise Raif::Errors::InvalidConfigError, "Raif.config.google_api_key is required when Raif.config.google_embedding_models_enabled is true. Set it via Raif.config.google_api_key or ENV['GOOGLE_API_KEY']" # rubocop:disable Layout/LineLength end if x_ai_models_enabled && x_ai_api_key.blank? raise Raif::Errors::InvalidConfigError, "Raif.config.x_ai_api_key is required when Raif.config.x_ai_models_enabled is true. Set it via Raif.config.x_ai_api_key or ENV['XAI_API_KEY']" # rubocop:disable Layout/LineLength end end |