From 982991ca69cd7f844680949ed160e678f89050fc Mon Sep 17 00:00:00 2001
From: srichman333 <sarah_n_richman@brown.edu>
Date: Tue, 16 Apr 2024 00:44:43 -0400
Subject: correlation from gpt

---
 src/client/views/pdf/GPTPopup/GPTPopup.tsx | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'src/client/views/pdf/GPTPopup/GPTPopup.tsx')

diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.tsx b/src/client/views/pdf/GPTPopup/GPTPopup.tsx
index 29b1ca365..50835a541 100644
--- a/src/client/views/pdf/GPTPopup/GPTPopup.tsx
+++ b/src/client/views/pdf/GPTPopup/GPTPopup.tsx
@@ -15,6 +15,7 @@ import { DocUtils, Docs } from '../../../documents/Documents';
 import { ObservableReactComponent } from '../../ObservableReactComponent';
 import { AnchorMenu } from '../AnchorMenu';
 import './GPTPopup.scss';
+import { DataVizView } from '../../nodes/DataVizBox/DataVizBox';
 
 export enum GPTPopupMode {
     SUMMARY,
@@ -121,6 +122,7 @@ export class GPTPopup extends ObservableReactComponent<GPTPopupProps> {
     };
 
     public addDoc: (doc: Doc | Doc[], sidebarKey?: string | undefined) => boolean = () => false;
+    public createFilteredDoc: (axes?: any, type?: DataVizView) => boolean = () => false;
     public addToCollection: ((doc: Doc | Doc[], annotationKey?: string | undefined) => boolean) | undefined;
 
     /**
@@ -168,7 +170,11 @@ export class GPTPopup extends ObservableReactComponent<GPTPopupProps> {
         GPTPopup.Instance.setLoading(true);
         try {
             let res = await gptAPICall(this.dataJson, GPTCallType.DATA, this.dataChatPrompt);
-            GPTPopup.Instance.setText(res || 'Something went wrong.');
+            console.log(res)
+            let json = JSON.parse(res! as string);
+            const keys = Object.keys(json)
+            console.log(json[keys[0]], json[keys[1]])
+            GPTPopup.Instance.setText(json[keys[2]] || 'Something went wrong.');
         } catch (err) {
             console.error(err);
         }
@@ -192,6 +198,8 @@ export class GPTPopup extends ObservableReactComponent<GPTPopupProps> {
                 link_relationship: 'GPT Summary',
             });
         }
+
+        this.createFilteredDoc();
     };
 
     /**
-- 
cgit v1.2.3-70-g09d2

