From 024c224121f45191a7d0ff0c257461825a58a872 Mon Sep 17 00:00:00 2001 From: Andrew Nguonly Date: Mon, 15 Apr 2024 22:47:54 -0700 Subject: [PATCH] Remove commented out code. Fix lint errors in frontend code. --- frontend/src/App.tsx | 10 +++++++--- frontend/src/components/Chat.tsx | 16 ++++++++++++++-- frontend/src/hooks/useStreamState.tsx | 10 ++++++++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index e84b0c09..c2e2ef1f 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -28,7 +28,11 @@ function App(props: { edit?: boolean }) { const { currentChat, assistantConfig, isLoading } = useThreadAndAssistant(); const startTurn = useCallback( - async (message: MessageWithFiles | null, thread_id: string, assistantType: string) => { + async ( + message: MessageWithFiles | null, + thread_id: string, + assistantType: string, + ) => { const files = message?.files || []; if (files.length > 0) { const formData = files.reduce((formData, file) => { @@ -58,7 +62,7 @@ function App(props: { edit?: boolean }) { example: false, id: `human-${Math.random()}`, }, - ] + ]; if (assistantType === "chat_retrieval") { // The RAG assistant type requires an object with a `messages` field. @@ -68,7 +72,7 @@ function App(props: { edit?: boolean }) { msg.role = "human"; return msg; }), - } + }; } } diff --git a/frontend/src/components/Chat.tsx b/frontend/src/components/Chat.tsx index 3200bcad..8f5bf74b 100644 --- a/frontend/src/components/Chat.tsx +++ b/frontend/src/components/Chat.tsx @@ -75,7 +75,13 @@ export function Chat(props: ChatProps) { {next.length > 0 && props.stream?.status !== "inflight" && (
props.startStream(null, currentChat.thread_id, assistantConfig.config.configurable?.type as string)} + onClick={() => + props.startStream( + null, + currentChat.thread_id, + assistantConfig.config.configurable?.type as string, + ) + } > Click to continue. @@ -83,7 +89,13 @@ export function Chat(props: ChatProps) { )}
props.startStream(msg, currentChat.thread_id, assistantConfig.config.configurable?.type as string)} + onSubmit={(msg) => + props.startStream( + msg, + currentChat.thread_id, + assistantConfig.config.configurable?.type as string, + ) + } onInterrupt={ props.stream?.status === "inflight" ? props.stopStream : undefined } diff --git a/frontend/src/hooks/useStreamState.tsx b/frontend/src/hooks/useStreamState.tsx index 8bfdc72a..8a265007 100644 --- a/frontend/src/hooks/useStreamState.tsx +++ b/frontend/src/hooks/useStreamState.tsx @@ -10,7 +10,10 @@ export interface StreamState { export interface StreamStateProps { stream: StreamState | null; - startStream: (input: Message[] | Record | null, thread_id: string) => Promise; + startStream: ( + input: Message[] | Record | null, + thread_id: string, + ) => Promise; stopStream?: (clear?: boolean) => void; } @@ -19,7 +22,10 @@ export function useStreamState(): StreamStateProps { const [controller, setController] = useState(null); const startStream = useCallback( - async (input: Message[] | Record |null, thread_id: string) => { + async ( + input: Message[] | Record | null, + thread_id: string, + ) => { const controller = new AbortController(); setController(controller); setCurrent({ status: "inflight", messages: input || [] });