Fixed an issue where AI features are visible in the UI even when LLM_ENABLED is set to False.

This commit is contained in:
Dave Page
2026-03-16 12:35:16 +05:30
committed by GitHub
parent 0bc4edbab5
commit 23bd3359c1
6 changed files with 27 additions and 8 deletions
+1
View File
@@ -32,6 +32,7 @@ Bug fixes
| `Issue #9729 <https://github.com/pgadmin-org/pgadmin4/issues/9729>`_ - Fixed an issue where some LLM models would not use database tools in the AI assistant, instead returning text descriptions of tool calls.
| `Issue #9279 <https://github.com/pgadmin-org/pgadmin4/issues/9279>`_ - Fixed an issue where OAuth2 authentication fails with 'object has no attribute' if OAUTH2_AUTO_CREATE_USER is False.
| `Issue #9392 <https://github.com/pgadmin-org/pgadmin4/issues/9392>`_ - Ensure that the Geometry Viewer refreshes when re-running queries or switching geometry columns, preventing stale data from being displayed.
| `Issue #9709 <https://github.com/pgadmin-org/pgadmin4/issues/9709>`_ - Fixed an issue where AI features (AI Assistant tab, AI Reports menus, and AI Preferences) were visible in the UI even when LLM_ENABLED is set to False.
| `Issue #9719 <https://github.com/pgadmin-org/pgadmin4/issues/9719>`_ - Fixed an issue where AI Reports fail with OpenAI models that do not support the temperature parameter.
| `Issue #9721 <https://github.com/pgadmin-org/pgadmin4/issues/9721>`_ - Fixed an issue where permissions page is not completely accessible on full scroll.
| `Issue #9732 <https://github.com/pgadmin-org/pgadmin4/issues/9732>`_ - Improve the AI Assistant user prompt to be more descriptive of the actual functionality.
+1
View File
@@ -538,6 +538,7 @@ def utils():
"Administrator") else restricted_shared_storage_list,
enable_server_passexec_cmd=config.ENABLE_SERVER_PASS_EXEC_CMD,
max_server_tags_allowed=config.MAX_SERVER_TAGS_ALLOWED,
llm_enabled=config.LLM_ENABLED,
), 200)
response.headers['Content-Type'] = MIMETYPE_APP_JS
response.headers['Cache-Control'] = NO_CACHE_CONTROL
@@ -72,6 +72,9 @@ define('pgadmin.browser.utils',
/* Enable server password exec command */
pgAdmin['enable_server_passexec_cmd'] = '{{enable_server_passexec_cmd}}';
/* LLM/AI features enabled */
pgAdmin['llm_enabled'] = '{{llm_enabled}}' == 'True';
// Define list of nodes on which Query tool option doesn't appears
let unsupported_nodes = pgAdmin.unsupported_nodes = [
'server_group', 'server', 'coll-tablespace', 'tablespace',
+4
View File
@@ -45,6 +45,10 @@ class LLMModule(PgAdminModule):
"""
Register preferences for LLM providers.
"""
# Don't register AI preferences if LLM is disabled at system level
if not getattr(config, 'LLM_ENABLED', False):
return
self.preference = Preferences('ai', gettext('AI'))
# Default Provider Setting
+14 -4
View File
@@ -10,6 +10,7 @@
import AIReport from './AIReport';
import { AllPermissionTypes, BROWSER_PANELS } from '../../../browser/static/js/constants';
import getApiInstance from '../../../static/js/api_instance';
import MainMenuFactory from '../../../browser/static/js/MainMenuFactory';
import url_for from 'sources/url_for';
// AI Reports Module
@@ -36,9 +37,14 @@ define([
this.initialized = true;
// Check LLM status
// Check LLM status and only register menus if enabled
this.checkLLMStatus();
return this;
},
// Register AI Reports menus
registerMenus: function() {
// Register AI Reports menu category
pgBrowser.add_menu_category({
name: 'ai_tools',
@@ -158,11 +164,9 @@ define([
}
pgBrowser.add_menus(menus);
return this;
},
// Check if LLM is configured
// Check if LLM is configured, register menus only if system-enabled
checkLLMStatus: function() {
const api = getApiInstance();
api.get(url_for('llm.status'))
@@ -172,6 +176,12 @@ define([
this.llmSystemEnabled = res.data.data?.system_enabled || false;
}
this.llmStatusChecked = true;
// Only register menus if LLM is enabled at system level
if (this.llmSystemEnabled) {
this.registerMenus();
MainMenuFactory.createMainMenus();
}
})
.catch(() => {
this.llmEnabled = false;
@@ -233,7 +233,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
tabs: [
LayoutDocker.getPanel({id: PANELS.QUERY, title: gettext('Query'), content: <Query onTextSelect={(text) => setSelectedText(text)} setQtStatePartial={setQtStatePartial}/>}),
LayoutDocker.getPanel({id: PANELS.HISTORY, title: gettext('Query History'), content: <QueryHistory />}),
LayoutDocker.getPanel({id: PANELS.AI_ASSISTANT, title: gettext('AI Assistant'), content: <NLQChatPanel />}),
...(pgAdmin.llm_enabled ? [LayoutDocker.getPanel({id: PANELS.AI_ASSISTANT, title: gettext('AI Assistant'), content: <NLQChatPanel />})] : []),
],
},
{
@@ -442,7 +442,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
eventBus.current.registerListener(QUERY_TOOL_EVENTS.REINIT_QT_CONNECTION, initializeQueryTool);
eventBus.current.registerListener(QUERY_TOOL_EVENTS.FOCUS_PANEL, (qtPanelId)=>{
docker.current.focus(qtPanelId);
docker.current?.focus(qtPanelId);
});
eventBus.current.registerListener(QUERY_TOOL_EVENTS.SET_CONNECTION_STATUS, (status)=>{
@@ -464,9 +464,9 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
if(qtPanelId == currentTabId) {
setQtStatePartial({is_visible: true});
if(docker.current.isTabVisible(PANELS.QUERY)) {
if(docker.current?.isTabVisible(PANELS.QUERY)) {
docker.current.focus(PANELS.QUERY);
} else if(docker.current.isTabVisible(PANELS.HISTORY)) {
} else if(docker.current?.isTabVisible(PANELS.HISTORY)) {
docker.current.focus(PANELS.HISTORY);
}