From 6d9a9105176ebb00616bee2005d0d374701fa0d8 Mon Sep 17 00:00:00 2001 From: Willy Douhard Date: Thu, 21 Sep 2023 12:42:28 +0200 Subject: [PATCH] Wd/pp template (#408) * enable template mode if at least one prompt has a template * has to update to set module resolution nodenext or precommit fails * revert module resolution change * fix warning --- .../src/components/organisms/playground/basic.tsx | 12 ++++-------- .../organisms/playground/editor/promptMessage.tsx | 2 +- .../src/components/organisms/playground/index.tsx | 2 +- tsconfig.json | 15 +++------------ 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/frontend/src/components/organisms/playground/basic.tsx b/frontend/src/components/organisms/playground/basic.tsx index 556f8185bb..21263bcdaa 100644 --- a/frontend/src/components/organisms/playground/basic.tsx +++ b/frontend/src/components/organisms/playground/basic.tsx @@ -17,11 +17,7 @@ interface Props { restoredTime: number; } -export default function BasicPromptPlayground({ - hasTemplate, - prompt, - restoredTime -}: Props) { +export default function BasicPromptPlayground({ prompt, restoredTime }: Props) { const mode = useRecoilValue(modeState); const setPlayground = useSetRecoilState(playgroundState); @@ -55,7 +51,7 @@ export default function BasicPromptPlayground({ return ( @@ -63,11 +59,11 @@ export default function BasicPromptPlayground({ }; const renderFormatted = () => { - if (hasTemplate) { + if (typeof prompt.template === 'string') { return ( diff --git a/frontend/src/components/organisms/playground/editor/promptMessage.tsx b/frontend/src/components/organisms/playground/editor/promptMessage.tsx index deacc29430..af94e1a6fe 100644 --- a/frontend/src/components/organisms/playground/editor/promptMessage.tsx +++ b/frontend/src/components/organisms/playground/editor/promptMessage.tsx @@ -43,7 +43,7 @@ export default function PromptMessage({ onChange(index, state)} /> ); diff --git a/frontend/src/components/organisms/playground/index.tsx b/frontend/src/components/organisms/playground/index.tsx index 248eae6037..13daa7a160 100644 --- a/frontend/src/components/organisms/playground/index.tsx +++ b/frontend/src/components/organisms/playground/index.tsx @@ -78,7 +78,7 @@ function _PromptPlayground({ prompt }: Props) { }; const hasTemplate = prompt?.messages - ? prompt.messages.every((m) => typeof m.template === 'string') + ? !!prompt.messages.find((m) => typeof m.template === 'string') : typeof prompt?.template === 'string'; if (!data || error) { diff --git a/tsconfig.json b/tsconfig.json index 9fcc9b2886..907b680ea9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,7 @@ { "compilerOptions": { - "target": "es2020", - "lib": [ - "ESNext", - "dom" - ], - "types": [ - "cypress", - "node" - ] + "lib": ["ESNext", "dom"], + "types": ["cypress", "node"] }, - "include": [ - "cypress/**/*.ts" - ] + "include": ["cypress/**/*.ts"] }