From b67261ea5e58403e63daf40d85bf621fe88112d8 Mon Sep 17 00:00:00 2001 From: tshuli Date: Wed, 31 Jan 2024 13:40:28 +0800 Subject: [PATCH] fix: retrieve content from question prompt chatcompletionmessage --- .../src/features/admin-form/assistance/mutations.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/features/admin-form/assistance/mutations.ts b/frontend/src/features/admin-form/assistance/mutations.ts index 7cad349369..abbd864f12 100644 --- a/frontend/src/features/admin-form/assistance/mutations.ts +++ b/frontend/src/features/admin-form/assistance/mutations.ts @@ -32,9 +32,13 @@ export const useAssistanceMutations = () => { const createFieldsFromPromptMutation = useMutation((prompt: string) => generateQuestions(prompt) - .then((questions) => - generateFormFields(ContentTypes.QUESTIONS, String(questions)), - ) + .then((questions) => { + if (!questions.content) { + throw new Error('No content in questions') + } + + return generateFormFields(ContentTypes.QUESTIONS, questions.content) + }) .then((data) => { let formFields if (data.content) {