Skip to content

Commit

Permalink
chore: test
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwisecodes committed Nov 18, 2024
1 parent 8225298 commit 275dea7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
8 changes: 8 additions & 0 deletions apps/nextjs/src/components/AppComponents/Chat/chat-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function DemoLimitMessage({ id }: Readonly<{ id: string }>) {
'{"type": "error", "message": "**Your lesson is complete**\\nYou can no longer edit this lesson. [Create new lesson.](/aila)"}',
}}
persistedModerations={[]}
scrollToBottom={() => {}}
separator={<span className="my-10 flex" />}
/>
</div>
Expand Down Expand Up @@ -104,6 +105,7 @@ export function ChatList({
persistedModerations={persistedModerations}
ailaStreamingStatus={ailaStreamingStatus}
demo={demo}
scrollToBottom={scrollToBottom}
/>

{isDemoLocked && <DemoLimitMessage id={id} />}
Expand All @@ -119,13 +121,15 @@ export const ChatMessagesDisplay = ({
persistedModerations = [],
ailaStreamingStatus,
demo,
scrollToBottom,
}: {
id: string;
messages: Message[];
lastModeration: PersistedModerationBase | null;
persistedModerations: PersistedModerationBase[];
ailaStreamingStatus: AilaStreamingStatus;
demo: DemoContextProps;
scrollToBottom: () => void;
}) => {
const { lessonPlan, isStreaming } = useLessonChat();
const { setDialogWindow } = useDialog();
Expand Down Expand Up @@ -153,6 +157,7 @@ export const ChatMessagesDisplay = ({
persistedModerations={persistedModerations}
ailaStreamingStatus={ailaStreamingStatus}
isLastMessage={isLastMessage}
scrollToBottom={scrollToBottom}
separator={<span className="my-10 flex" />}
/>
<ChatMessage
Expand All @@ -165,6 +170,7 @@ export const ChatMessagesDisplay = ({
}}
lastModeration={lastModeration}
persistedModerations={[]}
scrollToBottom={scrollToBottom}
separator={<span className="my-10 flex" />}
ailaStreamingStatus={ailaStreamingStatus}
isLastMessage={isLastMessage}
Expand All @@ -181,6 +187,7 @@ export const ChatMessagesDisplay = ({
key={message.id}
chatId={id}
ailaStreamingStatus={ailaStreamingStatus}
scrollToBottom={scrollToBottom}
message={
!["Moderating", "Idle"].includes(ailaStreamingStatus) &&
message.role === "assistant" &&
Expand Down Expand Up @@ -209,6 +216,7 @@ export const ChatMessagesDisplay = ({
<div className="w-full flex-col gap-11">
<ChatMessage
chatId={id}
scrollToBottom={scrollToBottom}
ailaStreamingStatus={ailaStreamingStatus}
message={{
id: "working-on-it-initial",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface ChatMessageProps {
separator?: JSX.Element;
ailaStreamingStatus: AilaStreamingStatus;
isLastMessage: boolean;
scrollToBottom: () => void;
}

export function ChatMessage({
Expand All @@ -52,6 +53,7 @@ export function ChatMessage({
separator,
ailaStreamingStatus,
isLastMessage,
scrollToBottom,
}: Readonly<ChatMessageProps>) {
const { moderationModalHelpers } = useChatModeration();

Expand Down Expand Up @@ -226,13 +228,15 @@ export interface ChatMessagePartProps {
inspect: boolean;
moderationModalHelpers: ModerationModalHelpers;
isLastMessage: boolean;
scrollToBottom: () => void;
}

function ChatMessagePart({
part,
inspect,
moderationModalHelpers,
isLastMessage,
scrollToBottom,
}: Readonly<ChatMessagePartProps>) {
const PartComponent = {
comment: CommentMessagePart,
Expand All @@ -250,6 +254,7 @@ function ChatMessagePart({
part: typeof part.document;
moderationModalHelpers: ModerationModalHelpers;
isLastMessage: boolean;
scrollToBottom: () => void;
}>;

if (!PartComponent) {
Expand All @@ -263,6 +268,7 @@ function ChatMessagePart({
part={part.document}
moderationModalHelpers={moderationModalHelpers}
isLastMessage={isLastMessage}
scrollToBottom={scrollToBottom}
/>

{
Expand Down Expand Up @@ -317,7 +323,7 @@ export const InLineButton = ({
return (
<button
onClick={handleClick}
className="my-6 w-fit rounded-lg border border-black border-opacity-30 bg-white p-7 text-blue"
className="my-6 w-fit rounded-lg border border-black border-opacity-30 bg-white p-7 text-base text-blue"
>
{text}
</button>
Expand All @@ -327,7 +333,12 @@ export const InLineButton = ({
function TextMessagePart({
part,
isLastMessage,
}: Readonly<{ part: TextDocument; isLastMessage: boolean }>) {
scrollToBottom,
}: Readonly<{
part: TextDocument;
isLastMessage: boolean;
scrollToBottom: () => void;
}>) {
function containsRelevantList(text: string): boolean {
const relevancePhraseRegex =
/might\s*be\s*relevant|could\s*be\s*relevant|are\s*relevant/i; // Variations of "might be relevant"
Expand Down Expand Up @@ -367,6 +378,7 @@ function TextMessagePart({
handleContinue={handleContinue}
part={part}
setUserHasSelected={setUserHasSelected}
scrollToBottom={scrollToBottom}
/>
)}
</div>
Expand All @@ -387,6 +399,7 @@ function TextMessagePart({
handleContinue={handleContinue}
part={part}
setUserHasSelected={setUserHasSelected}
scrollToBottom={scrollToBottom}
/>
)}
</div>
Expand All @@ -404,10 +417,12 @@ const InlineButtonGroup = ({
handleContinue,
part,
setUserHasSelected,
scrollToBottom,
}: {
handleContinue: (text: string) => void;
part: TextDocument;
setUserHasSelected: (value: boolean) => void;
scrollToBottom: () => void;
}) => {
const [showExmapleEdits, setShowExampleEdits] = useState(false);
const isFinalStep =
Expand All @@ -421,6 +436,7 @@ const InlineButtonGroup = ({
text="Make them easier"
onClick={() => {
handleContinue("Make them easier");
scrollToBottom();
}}
/>
<InLineButton
Expand Down

0 comments on commit 275dea7

Please sign in to comment.