Skip to content

Commit

Permalink
begin work on suggesting data types
Browse files Browse the repository at this point in the history
  • Loading branch information
liberty-rising committed Jan 27, 2024
1 parent 7fcaedd commit e58d983
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
4 changes: 4 additions & 0 deletions backend/llms/system_message_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ def __init__(self):
"analytics_chat": """
You are an analytics assistant.
You will be generating SQL queries, and providing useful information for reports and analytics based on the given prompt.""",
"column_type_suggestion": """
You are a column type suggestion assistant.
You will be suggesting PostgreSQL column types based on the given prompt.
""",
"sql_code": """
You are a PostgreSQL SQL statement assistant.
Generate PostgreSQL SQL statements based on the given prompt.
Expand Down
13 changes: 12 additions & 1 deletion frontend/src/pages/upload/CreateDataProfileWindow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,18 @@ function CreateDataProfileWindow({ open, onClose, onCreate }) {
};

return (
<Dialog open={open} onClose={onClose} maxWidth="md" fullWidth>
<Dialog
open={open}
onClose={() => {
onClose();
setName(""); // Reset name
setExtractInstructions(""); // Reset extractInstructions
setSampleFiles([]); // Reset sampleFiles
setPreviewData(null); // Reset previewData
}}
maxWidth="md"
fullWidth
>
<DialogTitle>Create a Data Profile</DialogTitle>
<DialogContent>
<form onSubmit={handleSubmit}>
Expand Down
17 changes: 10 additions & 7 deletions frontend/src/pages/upload/DataPreviewAndSchemaEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ function DataPreviewAndSchemaEditor({ previewData }) {
useEffect(() => {
if (data && data.length > 0) {
const newColumnNames = Object.keys(data[0]);
const newColumnTypes = newColumnNames.map(() => "string");
let newColumnTypes;
if (columnTypes.length === 0) {
newColumnTypes = newColumnNames.map(() => "text");
} else {
newColumnTypes = columnTypes;
}
if (JSON.stringify(newColumnNames) !== JSON.stringify(columnNames)) {
setColumnNames(newColumnNames);
}
Expand Down Expand Up @@ -78,7 +83,7 @@ function DataPreviewAndSchemaEditor({ previewData }) {
handleColumnTypeChange(index, event.target.value)
}
>
<MenuItem value={"string"}>String</MenuItem>
<MenuItem value={"text"}>Text</MenuItem>
<MenuItem value={"number"}>Number</MenuItem>
<MenuItem value={"boolean"}>Boolean</MenuItem>
<MenuItem value={"date"}>Date</MenuItem>
Expand All @@ -90,11 +95,9 @@ function DataPreviewAndSchemaEditor({ previewData }) {
};

const handleColumnTypeChange = (index, newType) => {
setColumnTypes((prevColumnTypes) => {
const newColumnTypes = [...prevColumnTypes];
newColumnTypes[index] = newType;
return newColumnTypes;
});
let newColumnTypes = [...columnTypes];
newColumnTypes[index] = newType;
setColumnTypes(newColumnTypes);
};

const handleEditClick = (index) => {
Expand Down

0 comments on commit e58d983

Please sign in to comment.