Skip to content

Commit f0603aa

Browse files
author
Hina Shah
committed
ENH: Adding the AI summary to the table itself
1 parent 109719f commit f0603aa

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

src/pages/answer/resultsTable/AttributesTable.jsx

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import React, {
99
import Button from '@material-ui/core/Button';
1010
import { blue } from '@material-ui/core/colors';
1111
import resultsUtils from '~/utils/results';
12-
import Popover from '~/components/Popover';
1312
import GPTContext from '~/context/gpt';
1413

1514
const headerStyles = { fontWeight: 'bold', backgroundColor: '#eee' };
@@ -43,8 +42,6 @@ const PublicationLinkCell = ({ value, aiJSON }) => {
4342

4443
const { enabled } = useContext(GPTContext);
4544
const [aiSummaryData, setAISummaryData] = useState('');
46-
const [popoverOpen, setPopoverOpen] = useState(false);
47-
const [popoverPosition, setPopoverPosition] = useState({ x: 0, y: 0 });
4845

4946
const GPTSummaryButton = withStyles((theme) => ({
5047
root: {
@@ -61,6 +58,7 @@ const PublicationLinkCell = ({ value, aiJSON }) => {
6158
const publicationsArr = resultsUtils.getPublications(inJSON.edge);
6259
const sentenceRes = resultsUtils.getSentences(inJSON.edge);
6360
// setAnchorEl(spanRef.current);
61+
console.log(publicationsArr);
6462
const toSendData = {
6563
edge: {
6664
nodes: inJSON.nodes,
@@ -80,6 +78,7 @@ const PublicationLinkCell = ({ value, aiJSON }) => {
8078
},
8179
},
8280
};
81+
console.log(JSON.stringify(toSendData, null, 2));
8382
const options = {
8483
method: 'POST',
8584
headers: {
@@ -96,14 +95,12 @@ const PublicationLinkCell = ({ value, aiJSON }) => {
9695
return response.json(); // Parse the JSON in the response ? Or is it a text?
9796
})
9897
.then((data) => {
98+
console.log(data);
9999
setAISummaryData(data);
100-
setPopoverOpen('aiSummary');
101-
setPopoverPosition({ x: event.clientX, y: event.clientY });
100+
inJSON.edge.aisummary = data;
102101
})
103102
.catch((error) => {
104103
setAISummaryData('Error getting response from KG-Summarizer:: ', error);
105-
setPopoverOpen('aiSummary');
106-
setPopoverPosition({ x: event.clientX, y: event.clientY });
107104
});
108105
}
109106

@@ -153,18 +150,14 @@ const PublicationLinkCell = ({ value, aiJSON }) => {
153150
Get AI Summary
154151
</GPTSummaryButton>
155152
)}
156-
<Popover
157-
open={popoverOpen === 'aiSummary'}
158-
onClose={() => setPopoverOpen(null)}
159-
anchorPosition={{ top: popoverPosition.y, left: popoverPosition.x }}
160-
above
161-
>
162-
<p style={{
163-
margin: '20px', padding: '10px', fontStyle: 'italic', backgroundColor: '#f0f0f0',
164-
}}
165-
> {aiSummaryData}
166-
</p>
167-
</Popover>
153+
{enabled && (aiSummaryData.length > 0) &&
154+
(
155+
<p style={{
156+
margin: '20px', padding: '20px', fontStyle: 'italic', backgroundColor: '#f0f0f0',
157+
}}
158+
> {aiSummaryData}
159+
</p>
160+
)}
168161
</TableCell>
169162
);
170163
};

0 commit comments

Comments
 (0)