From 54c597bb865aba15f16e0692c2f2119109d119aa Mon Sep 17 00:00:00 2001
From: srichman333 <sarah_n_richman@brown.edu>
Date: Wed, 28 Feb 2024 19:24:22 -0500
Subject: chat with ai

---
 src/client/views/nodes/DataVizBox/DataVizBox.tsx | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

(limited to 'src/client/views/nodes/DataVizBox/DataVizBox.tsx')

diff --git a/src/client/views/nodes/DataVizBox/DataVizBox.tsx b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
index 33b7dddfc..0a7fe59a5 100644
--- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx
+++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
@@ -29,7 +29,6 @@ import { PieChart } from './components/PieChart';
 import { TableBox } from './components/TableBox';
 import { Checkbox } from '@mui/material';
 import { ContextMenu } from '../../ContextMenu';
-import { GPTCallType, gptAPICall } from '../../../apis/gpt/GPT';
 
 export enum DataVizView {
     TABLE = 'table',
@@ -415,20 +414,13 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() im
 
 
     askGPT = action(async () => {
-        GPTPopup.Instance.setVisible(true);
         GPTPopup.Instance.setSidebarId('data_sidebar');
         GPTPopup.Instance.addDoc = this.sidebarAddDocument;
         GPTPopup.Instance.setMode(GPTPopupMode.DATA);
-        GPTPopup.Instance.setLoading(true);
-        try {
-            let data = DataVizBox.dataset.get(CsvCast(this.dataDoc[this.fieldKey]).url.href);
-            let input = JSON.stringify(data);
-            let res = await gptAPICall(input, GPTCallType.DATA);
-            GPTPopup.Instance.setText(res || 'Something went wrong.');
-        } catch (err) {
-            console.error(err);
-        }
-        GPTPopup.Instance.setLoading(false);
+        let data = DataVizBox.dataset.get(CsvCast(this.dataDoc[this.fieldKey]).url.href);
+        let input = JSON.stringify(data);
+        GPTPopup.Instance.setDataJson(input);
+        GPTPopup.Instance.generateDataAnalysis();
     });
 
     render() {
-- 
cgit v1.2.3-70-g09d2

