Skip to content

Commit aaf4d67

Browse files
committed
refactor: remove unused table analysis and settings functions
1 parent 25d2f8f commit aaf4d67

5 files changed

Lines changed: 0 additions & 120 deletions

File tree

backend/src/ai-core/tools/database-tools.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -95,27 +95,3 @@ export function createDashboardGenerationTools(): AIToolDefinition[] {
9595
},
9696
];
9797
}
98-
99-
export function createTableAnalysisTools(): AIToolDefinition[] {
100-
return [
101-
{
102-
name: 'analyzeTableSchema',
103-
description: 'Analyzes a table schema and returns recommendations for display settings and widgets.',
104-
parameters: {
105-
type: 'object',
106-
properties: {
107-
tableName: {
108-
type: 'string',
109-
description: 'The name of the table to analyze.',
110-
},
111-
columns: {
112-
type: 'array',
113-
description: 'Array of column definitions with name, type, and constraints.',
114-
},
115-
},
116-
required: ['tableName', 'columns'],
117-
additionalProperties: false,
118-
},
119-
},
120-
];
121-
}

backend/src/ai-core/tools/prompts.ts

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -37,63 +37,6 @@ IMPORTANT:
3737
Remember that all responses should be clear and user-friendly, explaining technical details when necessary.`;
3838
}
3939

40-
export function createTableSettingsSystemPrompt(widgetTypes: string[]): string {
41-
return `You are a database administration assistant. Analyze the following database tables and generate optimal settings for displaying and managing them in a web admin panel.
42-
43-
For each table, provide:
44-
1. display_name: A human-readable name for the table
45-
2. search_fields: Columns that should be searchable (text fields like name, email, title)
46-
3. readonly_fields: Columns that should not be editable (like auto_increment, timestamps)
47-
4. columns_view: All columns in preferred display order
48-
5. widgets: For each column, suggest the best widget type from: ${widgetTypes.join(', ')}
49-
50-
Available widget types and when to use them:
51-
- Password: for password fields
52-
- Boolean: for boolean/bit columns
53-
- Date: for date columns
54-
- Time: for time-only columns
55-
- DateTime: for datetime/timestamp columns
56-
- JSON: for JSON/JSONB columns
57-
- Textarea: for long text fields (description, content, etc.)
58-
- String: for short text fields (name, title, etc.)
59-
- Readonly: for auto-generated fields
60-
- Number: for numeric columns
61-
- Select: for columns with limited options
62-
- UUID: for UUID columns
63-
- Enum: for enum columns
64-
- Foreign_key: for foreign key columns
65-
- File: for file path columns
66-
- Image: for image URL columns
67-
- URL: for URL columns
68-
- Code: for code snippets
69-
- Phone: for phone number columns
70-
- Country: for country columns
71-
- Color: for color columns (hex values)
72-
- Range: for range values
73-
- Timezone: for timezone columns
74-
75-
Respond ONLY with valid JSON in this exact format (no markdown, no explanations):
76-
{
77-
"tables": [
78-
{
79-
"table_name": "table_name",
80-
"display_name": "Human Readable Name",
81-
"search_fields": ["name", "email"],
82-
"readonly_fields": ["id", "created_at"],
83-
"columns_view": ["id", "name", "email", "created_at"],
84-
"widgets": [
85-
{
86-
"field_name": "column_name",
87-
"widget_type": "String",
88-
"name": "Column Display Name",
89-
"description": "Description of what this column contains"
90-
}
91-
]
92-
}
93-
]
94-
}`;
95-
}
96-
9740
export function convertDbTypeToReadableString(dataType: ConnectionTypesEnum): string {
9841
switch (dataType) {
9942
case ConnectionTypesEnum.postgres:

backend/src/ai-core/tools/query-validators.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -67,36 +67,6 @@ export function wrapQueryWithLimit(query: string, databaseType: ConnectionTypesE
6767
}
6868
}
6969

70-
export function sanitizeJsonString(jsonStr: string): string {
71-
try {
72-
JSON.parse(jsonStr);
73-
return jsonStr;
74-
} catch (_e) {
75-
const startBrace = jsonStr.indexOf('{');
76-
if (startBrace === -1) {
77-
return '{}';
78-
}
79-
80-
const endBrace = jsonStr.lastIndexOf('}');
81-
if (endBrace === -1 || endBrace <= startBrace) {
82-
return '{}';
83-
}
84-
85-
let possibleJson = jsonStr.substring(startBrace, endBrace + 1);
86-
87-
possibleJson = possibleJson.replace(/,\s*}/g, '}');
88-
possibleJson = possibleJson.replace(/,\s*]/g, ']');
89-
90-
try {
91-
JSON.parse(possibleJson);
92-
return possibleJson;
93-
} catch (_parseErr) {
94-
console.error('Could not sanitize JSON, returning empty object');
95-
return '{}';
96-
}
97-
}
98-
}
99-
10070
export function cleanAIJsonResponse(response: string): string {
10171
let cleanedResponse = response.trim();
10272
if (cleanedResponse.startsWith('```json')) {

backend/src/ai-core/utils/message-builder.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,4 @@ export class MessageBuilder {
6464
}
6565
}
6666

67-
export function createSimpleMessages(systemPrompt: string, userMessage: string): BaseMessage[] {
68-
return new MessageBuilder().system(systemPrompt).human(userMessage).build();
69-
}
70-
7167
export { HumanMessage, SystemMessage, AIMessage, ToolMessage, BaseMessage };

backend/src/helpers/app/get-requeired-env-variable.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,3 @@ export function getRequiredEnvVariable(variableName: string): string {
66
}
77
return variableValue;
88
}
9-
10-
export function getOptionalEnvVariable(variableName: string): string | undefined {
11-
// eslint-disable-next-line security/detect-object-injection
12-
return process.env[variableName];
13-
}

0 commit comments

Comments
 (0)