Skip to content

Commit

Permalink
refactor: refactor prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianwzq committed Jan 31, 2024
1 parent 4244e30 commit 30e67d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 212 deletions.
205 changes: 1 addition & 204 deletions src/app/modules/form/admin-form/admin-form.assistance.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,207 +5,4 @@ export enum Roles {

export const MODEL_TYPE = 'gpt-3.5-turbo'

export const sampleFormFields = [
{
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'section',
},
{
ValidationOptions: {
selectedValidation: null,
customVal: null,
},
allowPrefill: '<boolean>',
lockPrefill: '<boolean>',
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'textfield',
},
{
ValidationOptions: {
selectedValidation: null,
customVal: null,
},
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'textarea',
},
{
fieldOptions: ['<string>'],
othersRadioButton: '<boolean>',
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'radiobutton',
},
{
ValidationOptions: {
customMax: null,
customMin: null,
},
fieldOptions: ['<string>'],
othersRadioButton: '<boolean>',
validateByValue: '<boolean>',
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'checkbox',
},
{
fieldOptions: ['<string>'],
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'dropdown',
},
{
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'yes_no',
},
{
ratingOptions: {
steps: 5,
shape: 'Star',
},
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'rating',
},
{
autoReplyOptions: {
hasAutoReply: '<boolean>',
autoReplySubject: '<string>',
autoReplySender: '<string>',
autoReplyMessage: '<string>',
includeFormSummary: '<boolean>',
},
isVerifiable: '<boolean>',
hasAllowedEmailDomains: false as const,
allowedEmailDomains: [],
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'email',
},
{
allowIntlNumbers: '<boolean>',
isVerifiable: '<boolean>',
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'mobile',
},
{
allowIntlNumbers: '<boolean>',
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'homeno',
},
{
dateValidation: {
customMinDate: null,
customMaxDate: null,
selectedDateValidation: null,
},
invalidDays: [],
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'date',
},
{
addMoreRows: '<boolean>',
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'table',
columns: [
{
ValidationOptions: {
customVal: null,
selectedValidation: null,
},
allowPrefill: '<boolean>',
lockPrefill: '<boolean>',
columnType: 'textfield',
required: '<boolean>',
title: '<string>',
},
],
minimumRows: 2,
maximumRows: null,
},
{
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'attachment',
attachmentSize: '1',
},
{
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'number',
ValidationOptions: {
LengthValidationOptions: {
customVal: null,
selectedLengthValidation: null,
},
RangeValidationOptions: {
customMin: null,
customMax: null,
},
selectedValidation: null,
},
},
{
ValidationOptions: {
customMax: null,
customMin: null,
},
validateByValue: '<boolean>',
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'decimal',
},
{
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'nric',
},
{
title: '<string>',
description: '<string>',
required: '<boolean>',
disabled: '<boolean>',
fieldType: 'uen',
},
]
export const sampleFormFields = `[{"title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"section"},{"ValidationOptions":{"selectedValidation":null,"customVal":null},"allowPrefill":"<boolean>","lockPrefill":"<boolean>","title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"textfield"},{"ValidationOptions":{"selectedValidation":null,"customVal":null},"title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"textarea"},{"fieldOptions":["<string>"],"othersRadioButton":"<boolean>","title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"radiobutton"},{"ValidationOptions":{"customMax":null,"customMin":null},"fieldOptions":["<string>"],"othersRadioButton":"<boolean>","validateByValue":"<boolean>","title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"checkbox"},{"fieldOptions":["<string>"],"title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"dropdown"},{"title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"yes_no"},{"ratingOptions":{"steps":5,"shape":"Star"},"title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"rating"},{"autoReplyOptions":{"hasAutoReply":"<boolean>","autoReplySubject":"<string>","autoReplySender":"<string>","autoReplyMessage":"<string>","includeFormSummary":"<boolean>"},"isVerifiable":"<boolean>","hasAllowedEmailDomains":false,"allowedEmailDomains":[],"title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"email"},{"allowIntlNumbers":"<boolean>","isVerifiable":"<boolean>","title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"mobile"},{"allowIntlNumbers":"<boolean>","title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"homeno"},{"dateValidation":{"customMinDate":null,"customMaxDate":null,"selectedDateValidation":null},"invalidDays":[],"title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"date"},{"addMoreRows":"<boolean>","title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"table","columns":[{"ValidationOptions":{"customVal":null,"selectedValidation":null},"allowPrefill":"<boolean>","lockPrefill":"<boolean>","columnType":"textfield","required":"<boolean>","title":"<string>"}],"minimumRows":2,"maximumRows":null},{"title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"attachment","attachmentSize":"1"},{"title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"number","ValidationOptions":{"LengthValidationOptions":{"customVal":null,"selectedLengthValidation":null},"RangeValidationOptions":{"customMin":null,"customMax":null},"selectedValidation":null}},{"ValidationOptions":{"customMax":null,"customMin":null},"validateByValue":"<boolean>","title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"decimal"},{"title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"nric"},{"title":"<string>","description":"<string>","required":"<boolean>","disabled":"<boolean>","fieldType":"uen"}]`
13 changes: 5 additions & 8 deletions src/app/modules/form/admin-form/admin-form.assistance.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,27 @@ const expectedFormFieldSchemaFormat =
const expectedQuestionsListFormat =
'---\n1. <question> | <answer type>\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
}

0 comments on commit 30e67d1

Please sign in to comment.