Some checks failed
Frontend Lint & Test / test (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / security-scan (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
The OpenAI Custom Server request targets the per-account OpenAI integration
(/app/accounts/{id}/settings/integrations/openai), not the instance-level
Captain config. The CAPTAIN_OPEN_AI_PROVIDER provider-switch added in 46fe70398
was out of the intended scope and is new behavior that did not previously exist,
so it is removed. This restores the original Captain behavior (CAPTAIN_OPEN_AI_ENDPOINT
remains usable as before, no provider gating). The correct implementation goes in
config/integration/apps.yml for the per-account openai integration.
52 lines
1.1 KiB
Ruby
52 lines
1.1 KiB
Ruby
require 'ruby_llm'
|
|
|
|
module Llm::Config
|
|
DEFAULT_MODEL = 'gpt-4.1-mini'.freeze
|
|
|
|
class << self
|
|
def initialized?
|
|
@initialized ||= false
|
|
end
|
|
|
|
def initialize!
|
|
return if @initialized
|
|
|
|
configure_ruby_llm
|
|
@initialized = true
|
|
end
|
|
|
|
def reset!
|
|
@initialized = false
|
|
end
|
|
|
|
def with_api_key(api_key, api_base: nil)
|
|
initialize!
|
|
context = RubyLLM.context do |config|
|
|
config.openai_api_key = api_key
|
|
config.openai_api_base = api_base
|
|
end
|
|
|
|
yield context
|
|
end
|
|
|
|
private
|
|
|
|
def configure_ruby_llm
|
|
RubyLLM.configure do |config|
|
|
config.openai_api_key = system_api_key if system_api_key.present?
|
|
config.openai_api_base = openai_endpoint.chomp('/') if openai_endpoint.present?
|
|
config.model_registry_file = Rails.root.join('config/llm_models.json').to_s
|
|
config.logger = Rails.logger
|
|
end
|
|
end
|
|
|
|
def system_api_key
|
|
InstallationConfig.find_by(name: 'CAPTAIN_OPEN_AI_API_KEY')&.value
|
|
end
|
|
|
|
def openai_endpoint
|
|
InstallationConfig.find_by(name: 'CAPTAIN_OPEN_AI_ENDPOINT')&.value
|
|
end
|
|
end
|
|
end
|