diff --git a/src/app/modules/form/admin-form/admin-form.assistance.constants.ts b/src/app/modules/form/admin-form/admin-form.assistance.constants.ts index 1be88037da..921435bfc7 100644 --- a/src/app/modules/form/admin-form/admin-form.assistance.constants.ts +++ b/src/app/modules/form/admin-form/admin-form.assistance.constants.ts @@ -5,207 +5,4 @@ export enum Roles { export const MODEL_TYPE = 'gpt-3.5-turbo' -export const sampleFormFields = [ - { - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'section', - }, - { - ValidationOptions: { - selectedValidation: null, - customVal: null, - }, - allowPrefill: '', - lockPrefill: '', - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'textfield', - }, - { - ValidationOptions: { - selectedValidation: null, - customVal: null, - }, - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'textarea', - }, - { - fieldOptions: [''], - othersRadioButton: '', - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'radiobutton', - }, - { - ValidationOptions: { - customMax: null, - customMin: null, - }, - fieldOptions: [''], - othersRadioButton: '', - validateByValue: '', - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'checkbox', - }, - { - fieldOptions: [''], - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'dropdown', - }, - { - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'yes_no', - }, - { - ratingOptions: { - steps: 5, - shape: 'Star', - }, - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'rating', - }, - { - autoReplyOptions: { - hasAutoReply: '', - autoReplySubject: '', - autoReplySender: '', - autoReplyMessage: '', - includeFormSummary: '', - }, - isVerifiable: '', - hasAllowedEmailDomains: false as const, - allowedEmailDomains: [], - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'email', - }, - { - allowIntlNumbers: '', - isVerifiable: '', - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'mobile', - }, - { - allowIntlNumbers: '', - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'homeno', - }, - { - dateValidation: { - customMinDate: null, - customMaxDate: null, - selectedDateValidation: null, - }, - invalidDays: [], - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'date', - }, - { - addMoreRows: '', - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'table', - columns: [ - { - ValidationOptions: { - customVal: null, - selectedValidation: null, - }, - allowPrefill: '', - lockPrefill: '', - columnType: 'textfield', - required: '', - title: '', - }, - ], - minimumRows: 2, - maximumRows: null, - }, - { - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'attachment', - attachmentSize: '1', - }, - { - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'number', - ValidationOptions: { - LengthValidationOptions: { - customVal: null, - selectedLengthValidation: null, - }, - RangeValidationOptions: { - customMin: null, - customMax: null, - }, - selectedValidation: null, - }, - }, - { - ValidationOptions: { - customMax: null, - customMin: null, - }, - validateByValue: '', - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'decimal', - }, - { - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'nric', - }, - { - title: '', - description: '', - required: '', - disabled: '', - fieldType: 'uen', - }, -] +export const sampleFormFields = `[{"title":"","description":"","required":"","disabled":"","fieldType":"section"},{"ValidationOptions":{"selectedValidation":null,"customVal":null},"allowPrefill":"","lockPrefill":"","title":"","description":"","required":"","disabled":"","fieldType":"textfield"},{"ValidationOptions":{"selectedValidation":null,"customVal":null},"title":"","description":"","required":"","disabled":"","fieldType":"textarea"},{"fieldOptions":[""],"othersRadioButton":"","title":"","description":"","required":"","disabled":"","fieldType":"radiobutton"},{"ValidationOptions":{"customMax":null,"customMin":null},"fieldOptions":[""],"othersRadioButton":"","validateByValue":"","title":"","description":"","required":"","disabled":"","fieldType":"checkbox"},{"fieldOptions":[""],"title":"","description":"","required":"","disabled":"","fieldType":"dropdown"},{"title":"","description":"","required":"","disabled":"","fieldType":"yes_no"},{"ratingOptions":{"steps":5,"shape":"Star"},"title":"","description":"","required":"","disabled":"","fieldType":"rating"},{"autoReplyOptions":{"hasAutoReply":"","autoReplySubject":"","autoReplySender":"","autoReplyMessage":"","includeFormSummary":""},"isVerifiable":"","hasAllowedEmailDomains":false,"allowedEmailDomains":[],"title":"","description":"","required":"","disabled":"","fieldType":"email"},{"allowIntlNumbers":"","isVerifiable":"","title":"","description":"","required":"","disabled":"","fieldType":"mobile"},{"allowIntlNumbers":"","title":"","description":"","required":"","disabled":"","fieldType":"homeno"},{"dateValidation":{"customMinDate":null,"customMaxDate":null,"selectedDateValidation":null},"invalidDays":[],"title":"","description":"","required":"","disabled":"","fieldType":"date"},{"addMoreRows":"","title":"","description":"","required":"","disabled":"","fieldType":"table","columns":[{"ValidationOptions":{"customVal":null,"selectedValidation":null},"allowPrefill":"","lockPrefill":"","columnType":"textfield","required":"","title":""}],"minimumRows":2,"maximumRows":null},{"title":"","description":"","required":"","disabled":"","fieldType":"attachment","attachmentSize":"1"},{"title":"","description":"","required":"","disabled":"","fieldType":"number","ValidationOptions":{"LengthValidationOptions":{"customVal":null,"selectedLengthValidation":null},"RangeValidationOptions":{"customMin":null,"customMax":null},"selectedValidation":null}},{"ValidationOptions":{"customMax":null,"customMin":null},"validateByValue":"","title":"","description":"","required":"","disabled":"","fieldType":"decimal"},{"title":"","description":"","required":"","disabled":"","fieldType":"nric"},{"title":"","description":"","required":"","disabled":"","fieldType":"uen"}]` diff --git a/src/app/modules/form/admin-form/admin-form.assistance.utils.ts b/src/app/modules/form/admin-form/admin-form.assistance.utils.ts index 4b01dc4997..f7f29b191f 100644 --- a/src/app/modules/form/admin-form/admin-form.assistance.utils.ts +++ b/src/app/modules/form/admin-form/admin-form.assistance.utils.ts @@ -15,30 +15,27 @@ const expectedFormFieldSchemaFormat = const expectedQuestionsListFormat = '---\n1. | \n2. ...\n---' -export const schemaPromptBuilder = (schema: any) => { +export const schemaPromptBuilder = (schema: string) => { const prompt = `I am a FormSG, a form builder that has the possible form field schemas in the following list:\n - ${JSON.stringify(schema)} + ${schema} Please keep any null values in the schema as null, and false values in the schema as false. Strictly include all keys in the schema, even if they are null or false.` return prompt } export const questionListPromptBuilder = (purpose: string) => { - const prompt = `I am a public officer who wants to create a form that collects ${purpose}. + return `I am a public officer who wants to create a form that collects ${purpose}. Give me a list of content / questions I should have in my form built with this form builder, in the form of "${expectedQuestionsListFormat}".` - return prompt } export const formFieldsPromptBuilder = (questions: string) => { - const prompt = `Help me generate a form with the following list of questions: ${questions} + return `Help me generate a form with the following list of questions: ${questions} Present the questions as FormSG form fields in JSON (list of form field schemas), in the form of "${expectedFormFieldSchemaFormat}" as defined by the system, without any code blocks. Format the JSON as a single line.` - return prompt } export const migratePromptBuilder = (parsedContent: string) => { - const prompt = `Help me generate the corresponding JSON form fields from content parsed from a PDF document. + return `Help me generate the corresponding JSON form fields from content parsed from a PDF document. Here is the parsed content from the PDF document (wrapped in triple quotes): """ ${parsedContent} """ Based on the parsed content, extract content that should be added to the form builder form and present them as a list, in the form of "${expectedQuestionsListFormat}".` - return prompt }