From e752e6d67147e719c0fe8b8d8d70ebeaea36634a Mon Sep 17 00:00:00 2001 From: Weves Date: Fri, 8 Mar 2024 00:53:32 -0800 Subject: [PATCH] Fix bug with persona creation caused by starter messages --- web/src/app/admin/personas/PersonaEditor.tsx | 158 ++++++++++--------- 1 file changed, 82 insertions(+), 76 deletions(-) diff --git a/web/src/app/admin/personas/PersonaEditor.tsx b/web/src/app/admin/personas/PersonaEditor.tsx index be9344e43..375cd6520 100644 --- a/web/src/app/admin/personas/PersonaEditor.tsx +++ b/web/src/app/admin/personas/PersonaEditor.tsx @@ -15,7 +15,7 @@ import * as Yup from "yup"; import { buildFinalPrompt, createPersona, updatePersona } from "./lib"; import { useRouter } from "next/navigation"; import { usePopup } from "@/components/admin/connectors/Popup"; -import { Persona } from "./interfaces"; +import { Persona, StarterMessage } from "./interfaces"; import Link from "next/link"; import { useEffect, useState } from "react"; import { @@ -102,7 +102,7 @@ export function PersonaEditor({ llm_relevance_filter: existingPersona?.llm_relevance_filter ?? false, llm_model_version_override: existingPersona?.llm_model_version_override ?? null, - starter_messages: existingPersona?.starter_messages ?? null, + starter_messages: existingPersona?.starter_messages ?? [], }} validationSchema={Yup.object() .shape({ @@ -471,27 +471,28 @@ export function PersonaEditor({ ( + render={(arrayHelpers: ArrayHelpers) => (
{values.starter_messages && values.starter_messages.length > 0 && - values.starter_messages.map((_, index) => ( -
-
-
-
- - - Shows up as the "title" for this - Starter Message. For example, "Write - an email". - - { + return ( +
+
+
+
+ + + Shows up as the "title" for + this Starter Message. For example, + "Write an email". + + - -
+ autoComplete="off" + /> + +
-
- - - A description which tells the user what - they might want to use this Starter - Message for. For example "to a client - about a new feature" - - + + + A description which tells the user what + they might want to use this Starter + Message for. For example "to a + client about a new feature" + + - -
+ autoComplete="off" + /> + +
-
- - - The actual message to be sent as the - initial user message if a user selects - this starter prompt. For example, - "Write me an email to a client about - a new billing feature we just - released." - - + + + The actual message to be sent as the + initial user message if a user selects + this starter prompt. For example, + "Write me an email to a client + about a new billing feature we just + released." + + - + +
+
+
+ arrayHelpers.remove(index)} />
-
- arrayHelpers.remove(index)} - /> -
-
- ))} + ); + })}