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

Fix chatstyling #677

Merged
merged 6 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion webapp/src/components/chat/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const useClasses = makeStyles({
root: {
display: 'flex',
flexDirection: 'column',
...shorthands.margin(0, '72px'),
width: '100%',
maxWidth: '105em',
...shorthands.margin(tokens.spacingVerticalNone, tokens.spacingHorizontalM),
},
typingIndicator: {
maxHeight: '28px',
Expand Down
9 changes: 6 additions & 3 deletions webapp/src/components/chat/ChatRoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ const useClasses = makeStyles({
},
history: {
...shorthands.padding(tokens.spacingVerticalM),
marginLeft: '40px',
paddingRight: '40px',
paddingLeft: tokens.spacingHorizontalM,
paddingRight: tokens.spacingHorizontalM,
display: 'flex',
justifyContent: 'center',
},
input: {
...shorthands.padding(tokens.spacingVerticalM),
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
...shorthands.padding(tokens.spacingVerticalS, tokens.spacingVerticalNone),
},
});

Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/chat/chat-history/ChatHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const useClasses = makeStyles({
...shorthands.gap(tokens.spacingVerticalM),
display: 'flex',
flexDirection: 'column',
maxWidth: '900px',
maxWidth: '105em',
width: '100%',
justifySelf: 'center',
},
Expand Down
54 changes: 32 additions & 22 deletions webapp/src/components/chat/chat-history/ChatHistoryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const useClasses = makeStyles({
display: 'flex',
flexDirection: 'row',
maxWidth: '75%',
minWidth: '24em',
...shorthands.borderRadius(customTokens.borderRadiusMedium),
...Breakpoints.small({
maxWidth: '100%',
Expand All @@ -52,10 +53,11 @@ const useClasses = makeStyles({
item: {
backgroundColor: customTokens.colorNeutralBackground1,
...shorthands.borderRadius(customTokens.borderRadiusMedium),
...shorthands.padding(customTokens.spacingVerticalS, customTokens.spacingHorizontalL),
...shorthands.padding(customTokens.spacingVerticalXS, customTokens.spacingHorizontalS),
},
me: {
backgroundColor: customTokens.colorMeBackground,
width: '100%',
},
time: {
color: customTokens.colorNeutralForeground3,
Expand Down Expand Up @@ -138,6 +140,10 @@ export const ChatHistoryItem: React.FC<ChatHistoryItemProps> = ({ message, messa
messageIndex === conversations[selectedId].messages.length - 1 &&
message.userId === 'Bot';

const messageCitations = message.citations ?? [];
const showMessageCitation = messageCitations.length > 0;
const showExtra = showMessageCitation || showShowRLHFMessage || showCitationCards;

return (
<div
className={isMe ? mergeClasses(classes.root, classes.alignEnd) : classes.root}
Expand All @@ -164,27 +170,31 @@ export const ChatHistoryItem: React.FC<ChatHistoryItemProps> = ({ message, messa
{isBot && <PromptDialog message={message} />}
</div>
{content}
<div className={classes.controls}>
{message.citations && message.citations.length > 0 && (
<ToggleButton
appearance="subtle"
checked={showCitationCards}
className={classes.citationButton}
icon={showCitationCards ? <ChevronUp20Regular /> : <ChevronDown20Regular />}
iconPosition="after"
onClick={() => {
setShowCitationCards(!showCitationCards);
}}
size="small"
>
{`${message.citations.length} ${message.citations.length === 1 ? 'citation' : 'citations'}`}
</ToggleButton>
)}
{showShowRLHFMessage && (
<div className={classes.rlhf}>{<UserFeedbackActions messageIndex={messageIndex} />}</div>
)}
</div>
{showCitationCards && <CitationCards message={message} />}
{showExtra && (
<div className={classes.controls}>
{showMessageCitation && (
<ToggleButton
appearance="subtle"
checked={showCitationCards}
className={classes.citationButton}
icon={showCitationCards ? <ChevronUp20Regular /> : <ChevronDown20Regular />}
iconPosition="after"
onClick={() => {
setShowCitationCards(!showCitationCards);
}}
size="small"
>
{`${messageCitations.length} ${
messageCitations.length === 1 ? 'citation' : 'citations'
}`}
</ToggleButton>
)}
{showShowRLHFMessage && (
<div className={classes.rlhf}>{<UserFeedbackActions messageIndex={messageIndex} />}</div>
)}
{showCitationCards && <CitationCards message={message} />}
</div>
)}
</div>
{features[FeatureKeys.RLHF].enabled && message.userFeedback === UserFeedback.Positive && (
<ThumbLikeFilled color="gray" />
Expand Down