Class: ActiveCanvas::AiConfiguration

Inherits:
Object
  • Object
show all
Defined in:
app/services/active_canvas/ai_configuration.rb

Class Method Summary collapse

Class Method Details

.configure_ruby_llm!Object



4
5
6
7
8
9
10
11
# File 'app/services/active_canvas/ai_configuration.rb', line 4

def configure_ruby_llm!
  RubyLLM.configure do |config|
    config.openai_api_key = Setting.ai_openai_api_key
    config.anthropic_api_key = Setting.ai_anthropic_api_key
    config.openrouter_api_key = Setting.ai_openrouter_api_key
    config.request_timeout = 180
  end
end

.configured?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
# File 'app/services/active_canvas/ai_configuration.rb', line 13

def configured?
  Setting.ai_openai_api_key.present? ||
    Setting.ai_anthropic_api_key.present? ||
    Setting.ai_openrouter_api_key.present?
end

.configured_providersObject



31
32
33
34
35
36
37
# File 'app/services/active_canvas/ai_configuration.rb', line 31

def configured_providers
  providers = []
  providers << "openai" if Setting.ai_openai_api_key.present?
  providers << "anthropic" if Setting.ai_anthropic_api_key.present?
  providers << "openrouter" if Setting.ai_openrouter_api_key.present?
  providers
end

.image_enabled?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/services/active_canvas/ai_configuration.rb', line 23

def image_enabled?
  configured? && Setting.ai_image_enabled?
end

.screenshot_enabled?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/services/active_canvas/ai_configuration.rb', line 27

def screenshot_enabled?
  configured? && Setting.ai_screenshot_enabled?
end

.text_enabled?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/services/active_canvas/ai_configuration.rb', line 19

def text_enabled?
  configured? && Setting.ai_text_enabled?
end