fix: end thinking for reasoning models when request is complete
This commit is contained in:
parent
ce7d98291e
commit
51096858ab
2 changed files with 8 additions and 10 deletions
|
|
@ -111,6 +111,12 @@ export const sessionSlice = createSlice({
|
|||
lastMessage.promptLogs = lastMessage.promptLogs
|
||||
? lastMessage.promptLogs.concat(payload)
|
||||
: payload;
|
||||
|
||||
// Inactive thinking for reasoning models when '</think>' tag is not received on request completion
|
||||
if (lastMessage.reasoning?.active) {
|
||||
lastMessage.reasoning.active = false;
|
||||
lastMessage.reasoning.endAt = Date.now();
|
||||
}
|
||||
},
|
||||
setActive: (state) => {
|
||||
state.isStreaming = true;
|
||||
|
|
@ -432,13 +438,6 @@ export const sessionSlice = createSlice({
|
|||
}
|
||||
}
|
||||
},
|
||||
streamComplete: (state) => {
|
||||
const lastItem = state.history[state.history.length - 1];
|
||||
if (lastItem.reasoning?.active) {
|
||||
lastItem.reasoning.active = false;
|
||||
lastItem.reasoning.endAt = Date.now();
|
||||
}
|
||||
},
|
||||
newSession: (state, { payload }: PayloadAction<Session | undefined>) => {
|
||||
state.lastSessionId = state.id;
|
||||
|
||||
|
|
@ -730,7 +729,6 @@ export const {
|
|||
addContextItemsAtIndex,
|
||||
setInactive,
|
||||
streamUpdate,
|
||||
streamComplete,
|
||||
newSession,
|
||||
updateSessionTitle,
|
||||
addHighlightedCode,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {
|
|||
addPromptCompletionPair,
|
||||
selectUseTools,
|
||||
setToolGenerated,
|
||||
streamUpdate,
|
||||
streamUpdate
|
||||
} from "../slices/sessionSlice";
|
||||
import { ThunkApiType } from "../store";
|
||||
import { callTool } from "./callTool";
|
||||
|
|
@ -71,7 +71,7 @@ export const streamNormalInput = createAsyncThunk<
|
|||
next = await gen.next();
|
||||
}
|
||||
|
||||
// Attach prompt log
|
||||
// Attach prompt log and end thinking for reasoning models
|
||||
if (next.done && next.value) {
|
||||
dispatch(addPromptCompletionPair([next.value]));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue