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

Add back chat queue info #3023

Merged
merged 1 commit into from
May 3, 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
55 changes: 32 additions & 23 deletions website/src/components/Chat/ChatConversation.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Box, CircularProgress, useBoolean, useToast } from "@chakra-ui/react";
import { Badge, Box, CircularProgress, useBoolean, useToast } from "@chakra-ui/react";
import { useTranslation } from "next-i18next";
import { KeyboardEvent, memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { UseFormGetValues } from "react-hook-form";
import { useChatContext } from "src/components/Chat/ChatContext";
import SimpleBar from "simplebar-react";
import { useMessageVote } from "src/hooks/chat/useMessageVote";
import { get, post } from "src/lib/api";
Expand Down Expand Up @@ -30,6 +30,7 @@ interface ChatConversationProps {
}

export const ChatConversation = memo(function ChatConversation({ chatId, getConfigValues }: ChatConversationProps) {
const { t } = useTranslation("chat");
const inputRef = useRef<HTMLTextAreaElement>(null);
const [messages, setMessages] = useState<InferenceMessage[]>([]);

Expand Down Expand Up @@ -260,27 +261,35 @@ export const ChatConversation = memo(function ChatConversation({ chatId, getConf
bg: "blackAlpha.300",
}}
>
{isLoadingMessages && <CircularProgress isIndeterminate size="20px" mx="auto" />}
<SimpleBar
onMouseDown={updateEnableAutoScroll}
scrollableNodeProps={scrollableNodeProps}
style={{ maxHeight: "100%", height: "100%", minHeight: "0" }}
classNames={{
contentEl: "space-y-4 mx-4 flex flex-col overflow-y-auto items-center",
}}
>
<ChatConversationTree
messages={messages}
onVote={handleOnVote}
onRetry={handleOnRetry}
isSending={isSending}
retryingParentId={retryingParentId}
onEditPromtp={handleEditPrompt}
></ChatConversationTree>
{isSending && streamedResponse && <PendingMessageEntry isAssistant content={streamedResponse} />}
<div ref={messagesEndRef} style={{ height: 0 }}></div>
</SimpleBar>
<ChatForm ref={inputRef} isSending={isSending} onSubmit={sendPrompterMessage} queueInfo={queueInfo}></ChatForm>
<Box height="full" minH={0} position="relative">
{isLoadingMessages && <CircularProgress isIndeterminate size="20px" mx="auto" />}
<SimpleBar
onMouseDown={updateEnableAutoScroll}
scrollableNodeProps={scrollableNodeProps}
style={{ maxHeight: "100%", height: "100%", minHeight: "0", paddingBottom: "1rem" }}
classNames={{
contentEl: "space-y-4 mx-4 flex flex-col overflow-y-auto items-center",
}}
>
<ChatConversationTree
messages={messages}
onVote={handleOnVote}
onRetry={handleOnRetry}
isSending={isSending}
retryingParentId={retryingParentId}
onEditPromtp={handleEditPrompt}
></ChatConversationTree>
{isSending && streamedResponse && <PendingMessageEntry isAssistant content={streamedResponse} />}
<div ref={messagesEndRef} style={{ height: 0 }}></div>
</SimpleBar>

{queueInfo && (
<Badge position="absolute" bottom="0" left="50%" transform="translate(-50%)">
{t("queue_info", queueInfo)}
</Badge>
)}
</Box>
<ChatForm ref={inputRef} isSending={isSending} onSubmit={sendPrompterMessage}></ChatForm>
<ChatWarning />
</Box>
);
Expand Down
5 changes: 2 additions & 3 deletions website/src/components/Chat/ChatForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ import { useTranslation } from "next-i18next";
import { forwardRef, KeyboardEvent, SyntheticEvent, useCallback, useEffect } from "react";
import TextareaAutosize from "react-textarea-autosize";
import { useFallbackRef } from "src/hooks/ui/useFallbackRef";
import { QueueInfo } from "src/lib/chat_stream";

import { ChatConfigDrawer } from "./ChatConfigMobile";
import { ChatInputIconButton } from "./ChatInputIconButton";

type ChatFormProps = {
isSending: boolean;
onSubmit: () => void;
queueInfo: QueueInfo | null;
};

// eslint-disable-next-line react/display-name
export const ChatForm = forwardRef<HTMLTextAreaElement, ChatFormProps>((props, forwardedRef) => {
const { isSending, onSubmit: onSubmit, queueInfo } = props;
const { isSending, onSubmit: onSubmit } = props;
const { t } = useTranslation("chat");
const handleSubmit = useCallback(
(e: SyntheticEvent) => {
Expand Down