Skip to content

Commit 7a4e168

Browse files
author
Hina Shah
committed
CLEANUP and STYLE
1 parent f8a6772 commit 7a4e168

File tree

2 files changed

+9
-85
lines changed

2 files changed

+9
-85
lines changed

src/pages/answer/resultsTable/AttributesTable.jsx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ const PublicationLinkCell = ({ value, aiJSON }) => {
4646
const [popoverOpen, setPopoverOpen] = useState(false);
4747
const [popoverPosition, setPopoverPosition] = useState({ x: 0, y: 0 });
4848

49-
// const [anchorEl, setAnchorEl] = useState(null);
50-
// const spanRef = useRef();
51-
5249
const GPTSummaryButton = withStyles((theme) => ({
5350
root: {
5451
marginLeft: 'auto',
@@ -64,8 +61,6 @@ const PublicationLinkCell = ({ value, aiJSON }) => {
6461
const publicationsArr = resultsUtils.getPublications(inJSON.edge);
6562
const sentenceRes = resultsUtils.getSentences(inJSON.edge);
6663
// setAnchorEl(spanRef.current);
67-
console.log('FROM GPT SUMMARY FUNC, publications: ', publicationsArr);
68-
console.log('FROM GPT SUMMARY FUNC, sentence: ', sentenceRes);
6964
const toSendData = {
7065
edge: {
7166
nodes: inJSON.nodes,
@@ -85,8 +80,6 @@ const PublicationLinkCell = ({ value, aiJSON }) => {
8580
},
8681
},
8782
};
88-
console.log('CLICKED FROM GPU SUMMARY FUNC');
89-
console.log(JSON.stringify(toSendData, null, 2));
9083
const options = {
9184
method: 'POST',
9285
headers: {
@@ -96,34 +89,24 @@ const PublicationLinkCell = ({ value, aiJSON }) => {
9689
};
9790
const kgsummarizerurl = 'https://kg-summarizer.apps.renci.org/summarize/edge';
9891
await fetch(kgsummarizerurl, options)
99-
.then(response => {
92+
.then((response) => {
10093
if (!response.ok) {
10194
throw new Error('Network response was not ok');
10295
}
10396
return response.json(); // Parse the JSON in the response ? Or is it a text?
10497
})
105-
.then(data => {
106-
console.log('KG SUMMARIZER Success:', data);
98+
.then((data) => {
10799
setAISummaryData(data);
108100
setPopoverOpen('aiSummary');
109101
setPopoverPosition({ x: event.clientX, y: event.clientY });
110-
console.log(event.target);
111102
})
112-
.catch(error => {
113-
setAISummaryData('Error getting response from KG-Summarizer');
103+
.catch((error) => {
104+
setAISummaryData('Error getting response from KG-Summarizer:: ', error);
114105
setPopoverOpen('aiSummary');
115106
setPopoverPosition({ x: event.clientX, y: event.clientY });
116-
console.error('KG SUMMARIZER Error:', error);
117107
});
118108
}
119109

120-
// function handlePopoverClose() {
121-
// setAnchorEl(null);
122-
// setPopoverOpen(null);
123-
// }
124-
// const open = Boolean(anchorEl);
125-
// const id = open ? "simple-popover" : undefined;
126-
127110
return (
128111
<TableCell>
129112
<ul style={{ padding: 0, margin: 0, listStyleType: 'none' }}>
@@ -166,7 +149,6 @@ const PublicationLinkCell = ({ value, aiJSON }) => {
166149
onGPTSummary(event, aiJSON);
167150
}}
168151
variant="outlined"
169-
// aria-describedby={id}
170152
>
171153
Get AI Summary
172154
</GPTSummaryButton>
@@ -177,7 +159,11 @@ const PublicationLinkCell = ({ value, aiJSON }) => {
177159
anchorPosition={{ top: popoverPosition.y, left: popoverPosition.x }}
178160
above
179161
>
180-
<div> {aiSummaryData} </div>
162+
<p style={{
163+
margin: '20px', padding: '10px', fontStyle: 'italic', backgroundColor: '#f0f0f0',
164+
}}
165+
> {aiSummaryData}
166+
</p>
181167
</Popover>
182168
</TableCell>
183169
);

src/pages/answer/useAnswerStore.js

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ export default function useAnswerStore() {
123123
Object.values(analysis.edge_bindings).forEach((edgeBindings) => {
124124
edgeBindings.forEach((binding) => {
125125
const kgEdge = message.knowledge_graph.edges[binding.id];
126-
//DEL console.log('--- TRYING TO WRITE STUFF FOR EDGE ID: ', binding.id);
127-
//DEL console.log(JSON.stringify(kgEdge, null, 2));
128126
edgesJSON[binding.id] = kgEdge || 'Unknown';
129127
if (kgEdge) {
130128
const graphEdge = {
@@ -144,73 +142,13 @@ export default function useAnswerStore() {
144142
const objectNode = message.knowledge_graph.nodes[kgEdge.object];
145143
const edgeKey = `${subjectNode.name || kgEdge.subject} ${stringUtils.displayPredicate(kgEdge.predicate)} ${objectNode.name || kgEdge.object}`;
146144
publications[edgeKey] = resultsUtils.getPublications(kgEdge);
147-
//DEL console.log(publications[edgeKey]);
148-
// TODO: The following block should only happen if ChatGPT mode is on.
149-
if (publications[edgeKey].length > 0) {
150-
// Create the edge json object
151-
const thisEdgeJson = {
152-
nodes: nodesJSON,
153-
edge: {
154-
subject: kgEdge.subject,
155-
object: kgEdge.object,
156-
predicate: kgEdge.predicate,
157-
publications: publications[edgeKey],
158-
sentences: resultsUtils.getSentences(kgEdge),
159-
},
160-
};
161-
// DEL console.log('Found one ore more publication!');
162-
// DEL console.log(JSON.stringify(thisEdgeJson, null, 2));
163-
// Send edge graph to kg-summarizer
164-
const kgsummarizerurl = 'https://kg-summarizer.apps.renci.org/summarize/edge';
165-
const toSendData = {
166-
edge: thisEdgeJson,
167-
parameters: {
168-
llm: {
169-
gpt_model: 'gpt-3.5-turbo',
170-
temperature: 0,
171-
system_prompt: '',
172-
},
173-
},
174-
};
175-
console.log('***** RIGHT BEFORE ITERATIVE KGSUMMARIZER');
176-
console.log(JSON.stringify(toSendData, null, 2));
177-
const options = {
178-
method: 'POST',
179-
headers: {
180-
'Content-type': 'application/json',
181-
},
182-
body: JSON.stringify(toSendData),
183-
};
184-
// TODO: Add a metadata object to the original edgeJSON as GPT Summary
185-
fetch(kgsummarizerurl, options)
186-
.then(response => {
187-
if (!response.ok) {
188-
throw new Error('Network response was not ok');
189-
}
190-
return response.json(); // Parse the JSON in the response ? Or is it a text?
191-
})
192-
.then(data => {
193-
console.log('KG SUMMARIZER Success:', data);
194-
kgEdge.GPTSummary = data;
195-
// Do something with the response data
196-
})
197-
.catch(error => {
198-
console.error('KG SUMMARIZER Error:', error);
199-
// Handle errors
200-
});
201-
}
202145
}
203146
});
204147
});
205148
});
206149
setSelectedResult({ nodes, edges });
207150
setSelectedRowId(rowId);
208151
setMetaData(publications);
209-
// TODO: If there are more than one publications, call chatgpt endpoint here?
210-
console.log('*** NODES :::');
211-
console.log(JSON.stringify(nodes, null, 2));
212-
console.log('*** EDGES :::');
213-
console.log(JSON.stringify(edgesJSON, null, 2));
214152
// store full result JSON
215153
setResultJSON({ knowledge_graph: { nodes: nodesJSON, edges: edgesJSON }, result: row });
216154
}

0 commit comments

Comments
 (0)