diff options
Diffstat (limited to 'src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx')
-rw-r--r-- | src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx index b576aee82..6f3647133 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx @@ -568,13 +568,17 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { let prompt: string = `(${origCount}) ${inputText}`; + console.log('prompt is: ', prompt) + this._GPTLoading = true; try { const res = await gptAPICall(prompt, GPTCallType.TEMPLATE); if (res) { + console.log('res is: ', res) const assignments: { [templateTitle: string]: { [fieldID: string]: string } } = JSON.parse(res); + console.log('assignments: ', assignments) const brokenDownAssignments: [Template, { [fieldID: number]: Col }][] = []; Object.entries(assignments).forEach(([tempTitle, assignment]) => { @@ -583,7 +587,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { const toObj = Object.entries(assignment).reduce( (a, [fieldID, colTitle]) => { const col = this.getColByTitle(colTitle); - if (!this._userCreatedFields.includes(col)){ // do the following for any fields not added by the user; will change in the future, for now only GPT content works with user-added fields + if (!this._userCreatedFields.includes(col)){ // do the following for any fields not added by the user; will change in the future, for now only GPT content works with user-added field const field = template.getFieldByID(Number(fieldID)); field.setContent(col.defaultContent ?? '', col.type === TemplateFieldType.VISUAL ? ViewType.IMG : ViewType.TEXT); field.setTitle(col.title); @@ -594,7 +598,9 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { }, {} as { [field: number]: Col } ); + console.log('all assignments: ', toObj) brokenDownAssignments.push([template, toObj]); + console.log('brokendownassignments: ', brokenDownAssignments) }); return brokenDownAssignments; @@ -612,13 +618,15 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> { const cols = this.fieldsInfos; const templates = this.templateManager.getValidTemplates(cols); + console.log(templates) + const assignments: [Template, { [field: number]: Col }][] = await this.assignColsToFields(templates, cols); const renderedTemplatePromises: Promise<Template | undefined>[] = assignments.map(([template, assignments]) => this.applyGPTContentToTemplate(template, assignments)); const renderedTemplates: (Template | undefined)[] = await Promise.all(renderedTemplatePromises); - templates.forEach(template => template.mainField.updateRenderedDoc()) + templates.forEach(template => template.mainField.initRenderedDoc()) setTimeout(() => { this.setSuggestedTemplates(templates); |