diff --git a/src/components/chat.tsx b/src/components/chat.tsx index 195ee22..1a4d47b 100644 --- a/src/components/chat.tsx +++ b/src/components/chat.tsx @@ -7,9 +7,7 @@ export function MessageUI(message: ChatMessage) { return (
@@ -26,7 +24,7 @@ export function MessageUI(message: ChatMessage) {
); -}; +} function parseMessageJson(message: ChatMessage) { let content; @@ -40,8 +38,10 @@ function parseMessageJson(message: ChatMessage) { content = parsed; } else if ('text' in parsed && typeof parsed.text === 'string') { content = parsed.text; - } else if ('user_message' in parsed && - typeof parsed.user_message === 'string') { + } else if ( + 'user_message' in parsed && + typeof parsed.user_message === 'string' + ) { content = parsed.user_message; } else if ('action' in parsed && parsed.action === 'exit') { content = 'Your response was successfully submitted.'; diff --git a/src/components/home/modes/DashboardMode.tsx b/src/components/home/modes/DashboardMode.tsx index fc6c3b2..d17321e 100644 --- a/src/components/home/modes/DashboardMode.tsx +++ b/src/components/home/modes/DashboardMode.tsx @@ -59,7 +59,9 @@ export default function DashboardMode(props: DashboardModeProps) {

- {f.description ? f.description.slice(0, 128) + '...' : f.raw_instructions.slice(0, 128) + '...'} + {f.description + ? f.description.slice(0, 128) + '...' + : f.raw_instructions.slice(0, 128) + '...'}

diff --git a/src/components/home/modes/NewFormMode.tsx b/src/components/home/modes/NewFormMode.tsx index 477c9bb..561cb2a 100644 --- a/src/components/home/modes/NewFormMode.tsx +++ b/src/components/home/modes/NewFormMode.tsx @@ -50,21 +50,26 @@ export default function NewFormMode(props: NewFormModeProps) { const conversationThread: ChatMessage[] = [ { role: 'user', - content: 'Here is a short text description of what I want to create a survey form about: ' + formTopic + '\n' + 'What should the title of this survey form be?', - } + content: + 'Here is a short text description of what I want to create a survey form about: ' + + formTopic + + '\n' + + 'What should the title of this survey form be?', + }, ]; const titleResponse = await callLLM(PROMPT_BUILD, conversationThread); if (!titleResponse) { console.error('No response from LLM'); setStep(1); return; - }; + } setTitle(removeStartAndEndQuotes(titleResponse.content) || ''); conversationThread.push(titleResponse); conversationThread.push({ role: 'user', - content: 'Create a short description of this survey form. This description will be given to a person who is in charge of administering the form data collection. This person will use this description to understand what the form is about, so that they can collect the correct information from respondents. Don\'t include information that is not relevant to the form, or state that this is a form. This survey administrator already knows that, instead they care about information relation the forms content. For example, if you want to collect a respondent\'s name and age, you can write: "This form is to collect the names and ages of people attending a birthday party."', + content: + 'Create a short description of this survey form. This description will be given to a person who is in charge of administering the form data collection. This person will use this description to understand what the form is about, so that they can collect the correct information from respondents. Don\'t include information that is not relevant to the form, or state that this is a form. This survey administrator already knows that, instead they care about information relation the forms content. For example, if you want to collect a respondent\'s name and age, you can write: "This form is to collect the names and ages of people attending a birthday party."', }); const descriptionResponse = await callLLM(PROMPT_BUILD, conversationThread); if (!descriptionResponse) { @@ -77,29 +82,39 @@ export default function NewFormMode(props: NewFormModeProps) { conversationThread.push(descriptionResponse); conversationThread.push({ role: 'user', - content: 'Write any guidance that will help respondents fill out this form, such as conditional information to collect or how to answer questions. The survey administrator will reference this guidence when deciding which follow up questions to ask or how to interpret the answers. For example, if you want to collect a RSVP for a birthday party, including the number of guests attending, you may write "Please include the number of guests attending the birthday party, but only if the RSVP is yes." because it doesn\'t make sense to ask for the number of guests if the respondent is not attending.', + content: + 'Write any guidance that will help respondents fill out this form, such as conditional information to collect or how to answer questions. The survey administrator will reference this guidence when deciding which follow up questions to ask or how to interpret the answers. For example, if you want to collect a RSVP for a birthday party, including the number of guests attending, you may write "Please include the number of guests attending the birthday party, but only if the RSVP is yes." because it doesn\'t make sense to ask for the number of guests if the respondent is not attending.', }); - const fieldsGuidanceResponse = await callLLM(PROMPT_BUILD, conversationThread); + const fieldsGuidanceResponse = await callLLM( + PROMPT_BUILD, + conversationThread + ); if (!fieldsGuidanceResponse) { console.error('No response from LLM'); setStep(1); return; - }; - setFieldsGuidance(removeStartAndEndQuotes(fieldsGuidanceResponse.content) || ''); + } + setFieldsGuidance( + removeStartAndEndQuotes(fieldsGuidanceResponse.content) || '' + ); conversationThread.push(fieldsGuidanceResponse); conversationThread.push({ role: 'user', - content: 'Now return a JSON object that will serve as a template for the form responses. This object should have keys that are strings and values that are strings. The keys are the names of the fields that the survey administrator should attempt to obtain. They values should be descriptions of those fields, including any formatting information or non-obvious ways to validate the provided information. For example, if you want to collect a respondent\'s name and age, you can write: {"name": "name of the respondent", "age": "age of the respondent"}', + content: + 'Now return a JSON object that will serve as a template for the form responses. This object should have keys that are strings and values that are strings. The keys are the names of the fields that the survey administrator should attempt to obtain. They values should be descriptions of those fields, including any formatting information or non-obvious ways to validate the provided information. For example, if you want to collect a respondent\'s name and age, you can write: {"name": "name of the respondent", "age": "age of the respondent"}', }); - const fieldsSchemaResponse = await callLLM(PROMPT_BUILD, conversationThread); + const fieldsSchemaResponse = await callLLM( + PROMPT_BUILD, + conversationThread + ); if (!fieldsSchemaResponse) { console.error('No response from LLM'); setStep(1); return; - }; + } const fieldsSchema = fieldsSchemaResponse.content || '{}'; const fieldsSchemaJSON = JSON.parse(fieldsSchema); setFieldsSchema(fieldsSchemaJSON); @@ -108,7 +123,6 @@ export default function NewFormMode(props: NewFormModeProps) { const renderStepContent = () => { if (step === 1) { - return (
diff --git a/src/pages/forms/fill/[id].tsx b/src/pages/forms/fill/[id].tsx index bdf7cdb..fb8f78b 100644 --- a/src/pages/forms/fill/[id].tsx +++ b/src/pages/forms/fill/[id].tsx @@ -68,10 +68,15 @@ export function CreateFormInner(props: { formId: string }) { }, []); // The empty array ensures this effect runs only once on mount return form ? ( - ) : - <>{error ? ErrorBox(error) :

Loading...

} + ) : ( + <> + {error ? ( + ErrorBox(error) + ) : ( +

Loading...

+ )} - ; + ); } export function InnerChat(props: { form: Form; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 84be96a..1220367 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -112,7 +112,11 @@ function SpecificsTextOnLeft(props: { ); } -function SpecificsTextOnRight(props: { heading: string; content: string; children: React.ReactNode }) { +function SpecificsTextOnRight(props: { + heading: string; + content: string; + children: React.ReactNode; +}) { return (
{props.children}
@@ -121,12 +125,9 @@ function SpecificsTextOnRight(props: { heading: string; content: string; childre

{props.heading}

-

- {props.content} -

+

{props.content}

- ); } @@ -149,8 +150,7 @@ function Specifics() {
Waitlist for my startup: name, email address, company, job title, and what technologies they currently use for marketing research. - If they’re a software engineer, ask for their - GitHub. + If they’re a software engineer, ask for their GitHub.
@@ -162,7 +162,9 @@ function Specifics() {
- +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameEmailCompanyTitleTechGitHub
Jane Doejd@ex.coTech Co.ML EngineerReact, Node, Pythonjd-70B
Bill Smithbsx@ex.coBiz Corp.Marketing ManagerGoogle Analytics-
-
- + > +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameEmailCompanyTitleTechGitHub
Jane Doejd@ex.coTech Co.ML EngineerReact, Node, Pythonjd-70B
Bill Smithbsx@ex.coBiz Corp.Marketing ManagerGoogle Analytics-
+
+ { +export const removeStartAndEndQuotes = (str: string | null) => { if (!str) { return str; } return str.replace(/^"(.*)"$/, '$1'); -}; \ No newline at end of file +}; diff --git a/types/supabase.ts b/types/supabase.ts index 2404c9f..366ef77 100644 --- a/types/supabase.ts +++ b/types/supabase.ts @@ -4,113 +4,113 @@ export type Json = | boolean | null | { [key: string]: Json | undefined } - | Json[] + | Json[]; export interface Database { public: { Tables: { forms: { Row: { - created_at: string | null - description: string | null - fields_guidance: string - fields_schema: Json - id: string - is_open: boolean - name: string - raw_instructions: string - updated_at: string | null - user_id: string - } + created_at: string | null; + description: string | null; + fields_guidance: string; + fields_schema: Json; + id: string; + is_open: boolean; + name: string; + raw_instructions: string; + updated_at: string | null; + user_id: string; + }; Insert: { - created_at?: string | null - description?: string | null - fields_guidance: string - fields_schema: Json - id: string - is_open: boolean - name: string - raw_instructions: string - updated_at?: string | null - user_id: string - } + created_at?: string | null; + description?: string | null; + fields_guidance: string; + fields_schema: Json; + id: string; + is_open: boolean; + name: string; + raw_instructions: string; + updated_at?: string | null; + user_id: string; + }; Update: { - created_at?: string | null - description?: string | null - fields_guidance?: string - fields_schema?: Json - id?: string - is_open?: boolean - name?: string - raw_instructions?: string - updated_at?: string | null - user_id?: string - } - Relationships: [] - } + created_at?: string | null; + description?: string | null; + fields_guidance?: string; + fields_schema?: Json; + id?: string; + is_open?: boolean; + name?: string; + raw_instructions?: string; + updated_at?: string | null; + user_id?: string; + }; + Relationships: []; + }; responses: { Row: { - created_at: string | null - fields: Json - form_id: string - id: string - updated_at: string | null - } + created_at: string | null; + fields: Json; + form_id: string; + id: string; + updated_at: string | null; + }; Insert: { - created_at?: string | null - fields: Json - form_id: string - id: string - updated_at?: string | null - } + created_at?: string | null; + fields: Json; + form_id: string; + id: string; + updated_at?: string | null; + }; Update: { - created_at?: string | null - fields?: Json - form_id?: string - id?: string - updated_at?: string | null - } - Relationships: [] - } + created_at?: string | null; + fields?: Json; + form_id?: string; + id?: string; + updated_at?: string | null; + }; + Relationships: []; + }; users: { Row: { - avatar_url: string | null - created_at: string | null - email: string - full_name: string | null - id: string - updated_at: string | null - } + avatar_url: string | null; + created_at: string | null; + email: string; + full_name: string | null; + id: string; + updated_at: string | null; + }; Insert: { - avatar_url?: string | null - created_at?: string | null - email: string - full_name?: string | null - id: string - updated_at?: string | null - } + avatar_url?: string | null; + created_at?: string | null; + email: string; + full_name?: string | null; + id: string; + updated_at?: string | null; + }; Update: { - avatar_url?: string | null - created_at?: string | null - email?: string - full_name?: string | null - id?: string - updated_at?: string | null - } - Relationships: [] - } - } + avatar_url?: string | null; + created_at?: string | null; + email?: string; + full_name?: string | null; + id?: string; + updated_at?: string | null; + }; + Relationships: []; + }; + }; Views: { - [_ in never]: never - } + [_ in never]: never; + }; Functions: { - [_ in never]: never - } + [_ in never]: never; + }; Enums: { - [_ in never]: never - } + [_ in never]: never; + }; CompositeTypes: { - [_ in never]: never - } - } + [_ in never]: never; + }; + }; }