Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Textarea to gather Custom system message instead of alert modal. #42

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions components/ChatMessageList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { shallow } from 'zustand/shallow';

import { AspectRatio, Box, Button, Grid, List, Stack, Typography, useTheme } from '@mui/joy';
import { AspectRatio, Box, Button, Grid, List, Stack, Textarea, Typography, useTheme } from '@mui/joy';
import { SxProps } from '@mui/joy/styles/types';

import { ChatMessage } from '@/components/ChatMessage';
Expand All @@ -16,16 +16,14 @@ function PurposeSelect() {

const handlePurposeChange = (purpose: SystemPurposeId | null) => {
if (purpose) {

if (purpose === 'Custom') {
const systemMessage = prompt('Enter your custom AI purpose', SystemPurposes['Custom'].systemMessage);
SystemPurposes['Custom'].systemMessage = systemMessage || '';
}

setSystemPurposeId(purpose);
}
};

function handleCustomSystemMessageChange(v: React.ChangeEvent<HTMLTextAreaElement>): void {
SystemPurposes['Custom'].systemMessage = v.target.value;
}

return (
<Stack direction='column' sx={{ justifyContent: 'center', alignItems: 'center', mx: 2, minHeight: '60vh' }}>

Expand Down Expand Up @@ -69,6 +67,21 @@ function PurposeSelect() {
{SystemPurposes[systemPurposeId].description}
</Typography>

{systemPurposeId === 'Custom' && (
<>
<Textarea variant='soft' autoFocus placeholder={"Enter your custom system message here..."}
minRows={5} maxRows={12}
// onKeyDown={handleKeyPress}
// onDragEnter={handleMessageDragEnter}
defaultValue={SystemPurposes['Custom'].systemMessage} onChange={(e) => handleCustomSystemMessageChange(e)}
sx={{
fontSize: '16px',
lineHeight: 1.75,
}} />
</>
)}


</Box>

</Stack>
Expand Down Expand Up @@ -135,4 +148,4 @@ export function ChatMessageList(props: { disableSend: boolean, sx?: SxProps, run
</List>
</Box>
);
}
}