From a49e002ae23e5f12adc9aeec39f098210abe0d55 Mon Sep 17 00:00:00 2001 From: tkubica-edu Date: Tue, 9 Jul 2024 16:17:31 +0200 Subject: [PATCH] fix: add back public prompt requests + add logs for error cases --- .../wlo-search/template/template.component.ts | 58 +++++++++++-------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/src/app/wlo-search/template/template.component.ts b/src/app/wlo-search/template/template.component.ts index e385f24c..070f96bb 100644 --- a/src/app/wlo-search/template/template.component.ts +++ b/src/app/wlo-search/template/template.component.ts @@ -203,29 +203,41 @@ export class TemplateComponent implements OnInit { /** calls the Z-API to invoke ChatGPT */ private generateFromPrompt() { - // TODO: Implement job widgets - this.jobsWidgetReady = true; - // this.aiTextPromptsService - // .publicPrompt({ - // widgetNodeId: 'c937cabf-5ffd-47f0-a5e8-ef0ed370baf0', - // contextNodeId: this.topicCollectionID(), - // }) - // .subscribe((result: any) => { - // const response = result.responses[0]; - // console.log('RESPONSE: ', response); - // this.generatedHeader.set(response); - // }); - // this.aiTextPromptsService - // .publicPrompt({ - // widgetNodeId: 'a625a9d6-383d-4835-84f2-a8e2792ea13f', - // contextNodeId: this.topicCollectionID(), - // }) - // .subscribe((result: any) => { - // const response = result.responses[0]; - // console.log('RESPONSE 2: ', response); - // this.generatedJobText.set(response); - // this.jobsWidgetReady = true; - // }); + this.aiTextPromptsService + .publicPrompt({ + widgetNodeId: 'c937cabf-5ffd-47f0-a5e8-ef0ed370baf0', + contextNodeId: this.topicCollectionID(), + body: {}, + }) + .subscribe( + (result: any) => { + const response = result.responses[0]; + console.log('RESPONSE: ', response); + this.generatedHeader.set(response); + }, + (error: any) => { + console.log('An error occurred: ', error); + this.jobsWidgetReady = true; + }, + ); + this.aiTextPromptsService + .publicPrompt({ + widgetNodeId: 'a625a9d6-383d-4835-84f2-a8e2792ea13f', + contextNodeId: this.topicCollectionID(), + body: {}, + }) + .subscribe( + (result: any) => { + const response = result.responses[0]; + console.log('RESPONSE 2: ', response); + this.generatedJobText.set(response); + this.jobsWidgetReady = true; + }, + (error: any) => { + console.log('An error occurred: ', error); + this.jobsWidgetReady = true; + }, + ); } // https://stackoverflow.com/a/16348977