Skip to content

Commit 9f3d8dc

Browse files
committed
Merge remote changes and remove test.db from tracking
2 parents 2f6ec3f + eeb6d1f commit 9f3d8dc

6 files changed

Lines changed: 1040 additions & 88 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ ENV/
3434
env.bak/
3535
venv.bak/
3636

37+
# Database files
38+
*.db
39+
*.sqlite
40+
*.sqlite3
41+
3742
# IDE
3843
.vscode/
3944
.idea/

backend/services/langchain_service.py

Lines changed: 5 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from models.response_schemas import QueryResult
1414
from services.duckdb_service import duckdb_service
1515
from services.embeddings_service import get_embeddings_service
16+
from services.suggestions_service import get_suggestions_service
1617
from services.project_service import get_project_service
1718
from services.storage_service import storage_service
1819

@@ -1073,96 +1074,12 @@ def _create_error_result(self, question: str, error_message: str) -> QueryResult
10731074
def generate_suggestions(
10741075
self, project_id: str, user_id: str
10751076
) -> List[Dict[str, Any]]:
1076-
"""Generate query suggestions based on project data."""
1077+
"""Generate query suggestions using the dedicated suggestions service."""
10771078
try:
1078-
# Use mock project data for now
1079-
project = {
1080-
"columns_metadata": [
1081-
{"name": "sales_amount", "type": "number"},
1082-
{"name": "category", "type": "string"},
1083-
{"name": "date", "type": "date"},
1084-
]
1085-
}
1086-
1087-
# Generate suggestions based on column types
1088-
suggestions = []
1089-
metadata = project.get("columns_metadata", [])
1090-
1091-
# Find numeric columns for aggregation suggestions
1092-
numeric_cols = [
1093-
col["name"]
1094-
for col in metadata
1095-
if col.get("type") in ["number", "integer", "float"]
1096-
]
1097-
categorical_cols = [
1098-
col["name"] for col in metadata if col.get("type") == "string"
1099-
]
1100-
date_cols = [
1101-
col["name"]
1102-
for col in metadata
1103-
if col.get("type") in ["date", "datetime"]
1104-
]
1105-
1106-
if numeric_cols:
1107-
suggestions.append(
1108-
{
1109-
"id": f"sug_sum_{numeric_cols[0]}",
1110-
"text": f"Show me the total {numeric_cols[0]}",
1111-
"category": "analysis",
1112-
"complexity": "beginner",
1113-
}
1114-
)
1115-
1116-
if categorical_cols:
1117-
suggestions.append(
1118-
{
1119-
"id": f"sug_group_{categorical_cols[0]}",
1120-
"text": f"Break down {numeric_cols[0]} by {categorical_cols[0]}",
1121-
"category": "analysis",
1122-
"complexity": "intermediate",
1123-
}
1124-
)
1125-
1126-
suggestions.append(
1127-
{
1128-
"id": f"sug_chart_{categorical_cols[0]}",
1129-
"text": f"Create a bar chart of {numeric_cols[0]} by {categorical_cols[0]}",
1130-
"category": "visualization",
1131-
"complexity": "intermediate",
1132-
}
1133-
)
1134-
1135-
if date_cols and numeric_cols:
1136-
suggestions.append(
1137-
{
1138-
"id": f"sug_trend_{date_cols[0]}",
1139-
"text": f"Show {numeric_cols[0]} trend over {date_cols[0]}",
1140-
"category": "visualization",
1141-
"complexity": "intermediate",
1142-
}
1143-
)
1144-
1145-
# Add general suggestions
1146-
suggestions.extend(
1147-
[
1148-
{
1149-
"id": "sug_overview",
1150-
"text": "Give me an overview of this dataset",
1151-
"category": "summary",
1152-
"complexity": "beginner",
1153-
},
1154-
{
1155-
"id": "sug_top_values",
1156-
"text": "Show me the top 10 rows",
1157-
"category": "analysis",
1158-
"complexity": "beginner",
1159-
},
1160-
]
1161-
)
1162-
1163-
return suggestions[:5] # Return top 5 suggestions
1164-
1079+
suggestions_service = get_suggestions_service()
1080+
return suggestions_service.generate_suggestions(project_id, user_id)
11651081
except Exception as e:
1082+
logger.error(f"Error generating suggestions via service: {str(e)}")
11661083
return []
11671084

11681085
def _ensure_project_embeddings(self, project_id: str, user_id: str):

0 commit comments

Comments
 (0)