From e58d983a49f365061977b36fec45f4082f45b35d Mon Sep 17 00:00:00 2001 From: liberty-rising Date: Sat, 27 Jan 2024 13:04:33 +0100 Subject: [PATCH] begin work on suggesting data types --- backend/llms/system_message_manager.py | 4 ++++ .../pages/upload/CreateDataProfileWindow.jsx | 13 ++++++++++++- .../pages/upload/DataPreviewAndSchemaEditor.jsx | 17 ++++++++++------- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/backend/llms/system_message_manager.py b/backend/llms/system_message_manager.py index e1793dc..5904570 100644 --- a/backend/llms/system_message_manager.py +++ b/backend/llms/system_message_manager.py @@ -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. diff --git a/frontend/src/pages/upload/CreateDataProfileWindow.jsx b/frontend/src/pages/upload/CreateDataProfileWindow.jsx index 3ed25ee..0f3a21e 100644 --- a/frontend/src/pages/upload/CreateDataProfileWindow.jsx +++ b/frontend/src/pages/upload/CreateDataProfileWindow.jsx @@ -55,7 +55,18 @@ function CreateDataProfileWindow({ open, onClose, onCreate }) { }; return ( - + { + onClose(); + setName(""); // Reset name + setExtractInstructions(""); // Reset extractInstructions + setSampleFiles([]); // Reset sampleFiles + setPreviewData(null); // Reset previewData + }} + maxWidth="md" + fullWidth + > Create a Data Profile
diff --git a/frontend/src/pages/upload/DataPreviewAndSchemaEditor.jsx b/frontend/src/pages/upload/DataPreviewAndSchemaEditor.jsx index 4146b15..82b72c4 100644 --- a/frontend/src/pages/upload/DataPreviewAndSchemaEditor.jsx +++ b/frontend/src/pages/upload/DataPreviewAndSchemaEditor.jsx @@ -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); } @@ -78,7 +83,7 @@ function DataPreviewAndSchemaEditor({ previewData }) { handleColumnTypeChange(index, event.target.value) } > - String + Text Number Boolean Date @@ -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) => {