Skip to content
Merged
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
32 changes: 32 additions & 0 deletions backend/src/ai-core/tools/database-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,38 @@ export function createDatabaseTools(isMongoDB: boolean): AIToolDefinition[] {
return tools;
}

export function createDashboardGenerationTools(): AIToolDefinition[] {
return [
{
name: 'getTablesList',
description:
'Returns the list of all tables and views available in the database. Use this to discover what tables exist before requesting their structure.',
parameters: {
type: 'object',
properties: {},
required: [],
additionalProperties: false,
},
},
{
name: 'getTableStructure',
description:
'Returns the structure of the specified table including column names, data types, and nullability. Use this to inspect tables before generating dashboard panels.',
parameters: {
type: 'object',
properties: {
tableName: {
type: 'string',
description: 'The name of the table to get the structure for.',
},
},
required: ['tableName'],
additionalProperties: false,
},
},
];
}

export function createTableAnalysisTools(): AIToolDefinition[] {
return [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export class GenerateTableDashboardWithAiDs {
connectionId: string;
masterPassword: string;
userId: string;
table_name: string;
max_panels?: number;
dashboard_name?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,19 @@ export class DashboardWidgetController {
@ApiOperation({
summary: 'Generate a full table dashboard using AI',
description:
'Analyzes a table structure and auto-generates multiple panel configurations for a dashboard using AI',
'AI autonomously discovers database tables, analyzes their structure, and auto-generates multiple panel configurations for a dashboard',
})
@ApiResponse({
status: 201,
description: 'Dashboard with panels generated by AI and saved to database.',
})
@ApiBody({ type: GenerateTableDashboardWithAiDto })
@ApiParam({ name: 'connectionId', required: true })
@ApiQuery({ name: 'tableName', required: true, description: 'The table name to generate the dashboard for' })
@UseGuards(ConnectionEditGuard)
@Timeout(TimeoutDefaults.AI)
@Post('/dashboard/generate-table-dashboard/:connectionId')
async generateTableDashboardWithAi(
@SlugUuid('connectionId') connectionId: string,
Comment on lines 207 to 208

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking API change. The endpoint previously required a tableName query parameter and now it doesn't. Any existing API clients that call this endpoint with the tableName parameter will need to be updated. Consider documenting this breaking change in release notes or providing backward compatibility if needed.

Copilot uses AI. Check for mistakes.
@Query('tableName') tableName: string,
@MasterPassword() masterPwd: string,
@UserId() userId: string,
@Body() generateDto: GenerateTableDashboardWithAiDto,
Expand All @@ -216,10 +214,9 @@ export class DashboardWidgetController {
connectionId,
masterPassword: masterPwd,
userId,
table_name: tableName,
max_panels: generateDto.max_panels,
dashboard_name: generateDto.dashboard_name,
};
return await this.generateTableDashboardWithAiUseCase.execute(inputData, InTransactionEnum.ON);
return await this.generateTableDashboardWithAiUseCase.execute(inputData, InTransactionEnum.OFF);

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transaction mode has been changed from ON to OFF. This means that if an error occurs during dashboard generation after the dashboard entity is saved, the database could be left in an inconsistent state with a partially created dashboard. Consider whether this change is intentional and if proper cleanup logic exists for error cases.

Suggested change
return await this.generateTableDashboardWithAiUseCase.execute(inputData, InTransactionEnum.OFF);
return await this.generateTableDashboardWithAiUseCase.execute(inputData, InTransactionEnum.ON);

Copilot uses AI. Check for mistakes.
}
}
Loading
Loading