diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 8545813bce..851a6f13b5 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -57,6 +57,7 @@ import { setShowDialog, } from "../../redux/slices/uiSlice"; import { RootState } from "../../redux/store"; +import { cancelStream } from "../../redux/thunks/cancelStream"; import { exitEditMode } from "../../redux/thunks/exitEditMode"; import { streamResponseThunk } from "../../redux/thunks/streamResponse"; import { @@ -203,7 +204,7 @@ export function Chat() { isMetaEquivalentKeyPressed(e) && !e.shiftKey ) { - // dispatch(cancelGeneration()); TODO!!! + dispatch(cancelStream()); } }; window.addEventListener("keydown", listener); diff --git a/gui/src/redux/thunks/cancelStream.ts b/gui/src/redux/thunks/cancelStream.ts new file mode 100644 index 0000000000..dc23c04a62 --- /dev/null +++ b/gui/src/redux/thunks/cancelStream.ts @@ -0,0 +1,15 @@ +import { createAsyncThunk } from "@reduxjs/toolkit"; +import { abortStream, setInactive } from "../slices/sessionSlice"; +import { ThunkApiType } from "../store"; + +export const cancelStream = createAsyncThunk( + "chat/cancelStream", + async (messages, { dispatch, extra, getState }) => { + dispatch(setInactive()); + dispatch(abortStream()); + + // If the assistant message is empty, then remove it and the user message, placing the user input in the main text box + // TODO: Waiting until next release + // dispatch(clearLastEmptyResponse()); + }, +);