Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/en_US/release_notes_9_14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ Bug fixes

| `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 #9721 <https://github.com/pgadmin-org/pgadmin4/issues/9721>`_ - Fixed an issue where permissions page is not completely accessible on full scroll.
1 change: 1 addition & 0 deletions web/pgadmin/browser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions web/pgadmin/browser/templates/browser/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions web/pgadmin/llm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def register_preferences(self):
"""
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
Expand Down
18 changes: 14 additions & 4 deletions web/pgadmin/llm/static/js/ai_tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand Down Expand Up @@ -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'))
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 />})] : []),
],
},
{
Expand Down Expand Up @@ -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)=>{
Expand All @@ -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);
}

Expand Down
Loading