Skip to content

Commit

Permalink
Merge pull request #3240 from continuedev/nate/quick-edit-e6e1
Browse files Browse the repository at this point in the history
cancelStream
  • Loading branch information
sestinj authored Dec 7, 2024
2 parents f138202 + 1520d08 commit f3387b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gui/src/pages/gui/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -203,7 +204,7 @@ export function Chat() {
isMetaEquivalentKeyPressed(e) &&
!e.shiftKey
) {
// dispatch(cancelGeneration()); TODO!!!
dispatch(cancelStream());
}
};
window.addEventListener("keydown", listener);
Expand Down
15 changes: 15 additions & 0 deletions gui/src/redux/thunks/cancelStream.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { createAsyncThunk } from "@reduxjs/toolkit";
import { abortStream, setInactive } from "../slices/sessionSlice";
import { ThunkApiType } from "../store";

export const cancelStream = createAsyncThunk<void, undefined, ThunkApiType>(
"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());
},
);

0 comments on commit f3387b7

Please sign in to comment.