| 1 | import { createAsyncThunk } from "@reduxjs/toolkit"; |
| 2 | import { |
| 3 | abortStream, |
| 4 | clearLastEmptyResponse, |
| 5 | setInactive, |
| 6 | } from "../slices/sessionSlice"; |
| 7 | import { ThunkApiType } from "../store"; |
| 8 | |
| 9 | export const cancelStream = createAsyncThunk<void, undefined, ThunkApiType>( |
| 10 | "chat/cancelStream", |
| 11 | async (messages, { dispatch, extra, getState }) => { |
| 12 | dispatch(setInactive()); |
| 13 | dispatch(abortStream()); |
| 14 | |
| 15 | // In the case tool calls were being generated, |
| 16 | // Replace them with |
| 17 | // If the assistant message is empty, then remove it and the user message, placing the user input in the main text box |
| 18 | dispatch(clearLastEmptyResponse()); |
| 19 | }, |
| 20 | ); |