Class: RailsAIPromptable::Configuration
- Inherits:
-
Object
- Object
- RailsAIPromptable::Configuration
- Defined in:
- lib/rails_ai_promptable/configuration.rb
Instance Attribute Summary collapse
-
#anthropic_api_key ⇒ Object
Returns the value of attribute anthropic_api_key.
-
#anthropic_base_url ⇒ Object
Returns the value of attribute anthropic_base_url.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#azure_api_key ⇒ Object
Returns the value of attribute azure_api_key.
-
#azure_api_version ⇒ Object
Returns the value of attribute azure_api_version.
-
#azure_base_url ⇒ Object
Returns the value of attribute azure_base_url.
-
#azure_deployment_name ⇒ Object
Returns the value of attribute azure_deployment_name.
-
#cohere_api_key ⇒ Object
Returns the value of attribute cohere_api_key.
-
#cohere_base_url ⇒ Object
Returns the value of attribute cohere_base_url.
-
#default_model ⇒ Object
Returns the value of attribute default_model.
-
#gemini_api_key ⇒ Object
Returns the value of attribute gemini_api_key.
-
#gemini_base_url ⇒ Object
Returns the value of attribute gemini_base_url.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#mistral_api_key ⇒ Object
Returns the value of attribute mistral_api_key.
-
#mistral_base_url ⇒ Object
Returns the value of attribute mistral_base_url.
-
#openai_base_url ⇒ Object
Returns the value of attribute openai_base_url.
-
#openrouter_api_key ⇒ Object
Returns the value of attribute openrouter_api_key.
-
#openrouter_app_name ⇒ Object
Returns the value of attribute openrouter_app_name.
-
#openrouter_base_url ⇒ Object
Returns the value of attribute openrouter_base_url.
-
#openrouter_site_url ⇒ Object
Returns the value of attribute openrouter_site_url.
-
#provider ⇒ Object
Returns the value of attribute provider.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#model_for_provider ⇒ Object
Helper method to get the appropriate default model for the current provider.
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 |
# File 'lib/rails_ai_promptable/configuration.rb', line 21 def initialize @provider = :openai @api_key = ENV.fetch("OPENAI_API_KEY", nil) @default_model = "gpt-4o-mini" @timeout = 30 @logger = Logger.new($stdout) # OpenAI settings @openai_base_url = "https://api.openai.com/v1" # Anthropic settings @anthropic_api_key = ENV.fetch("ANTHROPIC_API_KEY", nil) @anthropic_base_url = "https://api.anthropic.com/v1" # Gemini settings @gemini_api_key = ENV.fetch("GEMINI_API_KEY", nil) @gemini_base_url = "https://generativelanguage.googleapis.com/v1beta" # Cohere settings @cohere_api_key = ENV.fetch("COHERE_API_KEY", nil) @cohere_base_url = "https://api.cohere.ai/v1" # Azure OpenAI settings @azure_api_key = ENV.fetch("AZURE_OPENAI_API_KEY", nil) @azure_base_url = ENV.fetch("AZURE_OPENAI_BASE_URL", nil) @azure_api_version = "2024-02-15-preview" @azure_deployment_name = ENV.fetch("AZURE_OPENAI_DEPLOYMENT_NAME", nil) # Mistral AI settings @mistral_api_key = ENV.fetch("MISTRAL_API_KEY", nil) @mistral_base_url = "https://api.mistral.ai/v1" # OpenRouter settings @openrouter_api_key = ENV.fetch("OPENROUTER_API_KEY", nil) @openrouter_base_url = "https://openrouter.ai/api/v1" @openrouter_app_name = ENV.fetch("OPENROUTER_APP_NAME", nil) @openrouter_site_url = ENV.fetch("OPENROUTER_SITE_URL", nil) end |
Instance Attribute Details
#anthropic_api_key ⇒ Object
Returns the value of attribute anthropic_api_key.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def anthropic_api_key @anthropic_api_key end |
#anthropic_base_url ⇒ Object
Returns the value of attribute anthropic_base_url.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def anthropic_base_url @anthropic_base_url end |
#api_key ⇒ Object
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def api_key @api_key end |
#azure_api_key ⇒ Object
Returns the value of attribute azure_api_key.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def azure_api_key @azure_api_key end |
#azure_api_version ⇒ Object
Returns the value of attribute azure_api_version.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def azure_api_version @azure_api_version end |
#azure_base_url ⇒ Object
Returns the value of attribute azure_base_url.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def azure_base_url @azure_base_url end |
#azure_deployment_name ⇒ Object
Returns the value of attribute azure_deployment_name.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def azure_deployment_name @azure_deployment_name end |
#cohere_api_key ⇒ Object
Returns the value of attribute cohere_api_key.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def cohere_api_key @cohere_api_key end |
#cohere_base_url ⇒ Object
Returns the value of attribute cohere_base_url.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def cohere_base_url @cohere_base_url end |
#default_model ⇒ Object
Returns the value of attribute default_model.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def default_model @default_model end |
#gemini_api_key ⇒ Object
Returns the value of attribute gemini_api_key.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def gemini_api_key @gemini_api_key end |
#gemini_base_url ⇒ Object
Returns the value of attribute gemini_base_url.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def gemini_base_url @gemini_base_url end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def logger @logger end |
#mistral_api_key ⇒ Object
Returns the value of attribute mistral_api_key.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def mistral_api_key @mistral_api_key end |
#mistral_base_url ⇒ Object
Returns the value of attribute mistral_base_url.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def mistral_base_url @mistral_base_url end |
#openai_base_url ⇒ Object
Returns the value of attribute openai_base_url.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def openai_base_url @openai_base_url end |
#openrouter_api_key ⇒ Object
Returns the value of attribute openrouter_api_key.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def openrouter_api_key @openrouter_api_key end |
#openrouter_app_name ⇒ Object
Returns the value of attribute openrouter_app_name.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def openrouter_app_name @openrouter_app_name end |
#openrouter_base_url ⇒ Object
Returns the value of attribute openrouter_base_url.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def openrouter_base_url @openrouter_base_url end |
#openrouter_site_url ⇒ Object
Returns the value of attribute openrouter_site_url.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def openrouter_site_url @openrouter_site_url end |
#provider ⇒ Object
Returns the value of attribute provider.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def provider @provider end |
#timeout ⇒ Object
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/rails_ai_promptable/configuration.rb', line 5 def timeout @timeout end |
Instance Method Details
#model_for_provider ⇒ Object
Helper method to get the appropriate default model for the current provider
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rails_ai_promptable/configuration.rb', line 61 def model_for_provider case provider.to_sym when :openai "gpt-4o-mini" when :anthropic "claude-3-5-sonnet-20241022" when :gemini "gemini-pro" when :cohere "command" when :azure_openai azure_deployment_name || "gpt-4" when :mistral "mistral-small-latest" when :openrouter "openai/gpt-3.5-turbo" else default_model end end |