From d0e8573ba794459ad482987aba5d34496e0c653b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Demetrius=20Feij=C3=B3o?= Date: Mon, 13 Jan 2025 21:09:13 -0300 Subject: [PATCH] feat(SHAPE-8085): apply review feedback --- packages/demo/src/components/PromptAI.tsx | 32 ++++++++++++++++--- .../PromptAIResponseMessage.ts | 10 +++--- .../MessageToContainer.ts | 2 +- .../PromptAIMessage.ts | 3 +- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/packages/demo/src/components/PromptAI.tsx b/packages/demo/src/components/PromptAI.tsx index 8a8a4fdf..8b95c2b9 100644 --- a/packages/demo/src/components/PromptAI.tsx +++ b/packages/demo/src/components/PromptAI.tsx @@ -1,4 +1,13 @@ -import { Button, MenuItem, Stack, TextField, Typography } from '@mui/material' +import { + Button, + Checkbox, + FormControl, + FormLabel, + MenuItem, + Stack, + TextField, + Typography, +} from '@mui/material' import { useState } from 'react' import { isPromptAIPayloadValid, @@ -14,7 +23,9 @@ export const PromptAI: PluginComponent = (props) => { const [promptAction, setPromptAction] = useState('prompt') const [promptLanguage, setPromptLanguage] = useState() const [promptTone, setPromptTone] = useState() - const [promptOutput, setPromptOutput] = useState() + const [promptAIGeneratedText, setPromptAIGeneratedText] = useState() + const [promptBasedOnCurrentStory, setPromptBasedOnCurrentStory] = + useState(false) const onSubmit = async () => { const payload = { @@ -22,6 +33,7 @@ export const PromptAI: PluginComponent = (props) => { text: promptQuestion, language: promptLanguage, tone: promptTone, + basedOnCurrentStory: promptBasedOnCurrentStory, } if (!isPromptAIPayloadValid(payload)) { @@ -29,9 +41,9 @@ export const PromptAI: PluginComponent = (props) => { return } - const output = await actions.promptAI(payload) + const promptAIGeneratedText = await actions.promptAI(payload) - setPromptOutput(output) + setPromptAIGeneratedText(promptAIGeneratedText) } return ( @@ -70,7 +82,17 @@ export const PromptAI: PluginComponent = (props) => { label="Tone (optional)" onChange={(e) => setPromptTone(e.target.value)} /> - Output: {promptOutput} + + + Based on the current story: + + setPromptBasedOnCurrentStory(e.target.checked)} + /> + + AI Generated Text: {promptAIGeneratedText}