diff options
Diffstat (limited to 'src/client/views/nodes/DataVizBox/DataVizBox.tsx')
-rw-r--r-- | src/client/views/nodes/DataVizBox/DataVizBox.tsx | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/src/client/views/nodes/DataVizBox/DataVizBox.tsx b/src/client/views/nodes/DataVizBox/DataVizBox.tsx index e8235ce1a..d9a7d5e3a 100644 --- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx +++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx @@ -175,6 +175,15 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { } } + @action setColumnTitle = (colTitle: string, newTitle: string) => { + const colInfo = this.colsInfo.get(colTitle); + if (colInfo) { + colInfo.title = newTitle; + } else { + this.colsInfo.set(colTitle, {title: newTitle, desc: '', type: TemplateFieldType.UNSET, size: TemplateFieldSize.MEDIUM}) + } + } + @action setColumnDesc = (colTitle: string, desc: string) => { const colInfo = this.colsInfo.get(colTitle); if (colInfo) { @@ -580,33 +589,33 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { const prompt = this.getColSummary(); + console.log(prompt) + const cols = Array.from(Object.keys(this.records[0])).filter(header => header !== '' && header !== undefined); cols.forEach(col => { if (!this.colsInfo.get(col)) this.colsInfo.set(col, {title: col, desc: '', size: TemplateFieldSize.MEDIUM, type: TemplateFieldType.UNSET}); }); try { - const res = await gptAPICall(prompt, GPTCallType.VIZSUM); - - if (res) { + const [res1, res2] = await Promise.all([ + gptAPICall(prompt, GPTCallType.VIZSUM), + gptAPICall('Info:' + prompt, GPTCallType.VIZSUM2) + ]); + + if (res1) { + console.log(res1); this.GPTSummary = new ObservableMap(); - const descs: {[col: string]: string} = JSON.parse(res); + const descs: { [col: string]: string } = JSON.parse(res1); for (const [key, val] of Object.entries(descs)) { - this.GPTSummary.set(key, {desc: val}); + this.GPTSummary.set(key, { desc: val }); if (!this.colsInfo.get(key)?.desc) this.setColumnDesc(key, val); } } - } catch (err) { - console.error(err); - } - - try { - const res = await gptAPICall('Info:' + prompt, GPTCallType.VIZSUM2); - - if (res) { + + if (res2) { !this.GPTSummary && (this.GPTSummary = new ObservableMap()); - const info: {[col: string]: {type: TemplateFieldType, size: TemplateFieldSize}} = JSON.parse(res); - console.log(info) + const info: { [col: string]: { type: TemplateFieldType, size: TemplateFieldSize } } = JSON.parse(res2); + console.log(info); for (const [key, val] of Object.entries(info)) { const colSummary = this.GPTSummary.get(key); if (colSummary) { @@ -616,11 +625,11 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { this.setColumnSize(key, val.size); } } - } } catch (err) { console.error(err); - } + } + } getPossibleTemplates = (): Doc[] => { |