Demo warning in /chat UI (#466)

* Add demo warning to /chat

* Missed two files!

* Function calling works now, update message
This commit is contained in:
Juan José Mata
2025-12-19 16:30:21 +01:00
committed by GitHub
parent d37e719315
commit 94e87a8b85
7 changed files with 62 additions and 19 deletions

View File

@@ -9,6 +9,8 @@ class ApplicationController < ActionController::Base
before_action :set_default_chat
before_action :set_active_storage_url_options
helper_method :demo_config, :demo_host_match?, :show_demo_warning?
private
def detect_os
user_agent = request.user_agent
@@ -35,4 +37,20 @@ class ApplicationController < ActionController::Base
port: request.optional_port
}
end
def demo_config
Rails.application.config_for(:demo)
rescue RuntimeError, Errno::ENOENT, Psych::SyntaxError
nil
end
def demo_host_match?(demo = demo_config)
return false unless demo.is_a?(Hash) && demo["hosts"].present?
demo["hosts"].include?(request.host)
end
def show_demo_warning?
demo_host_match?
end
end