Merge pull request #4789 from usamanasar38/4708-fix-thinking-not-terminated-for-reasoning-model

fix: terminate thinking animation for reasoning model on request completion
This commit is contained in:
Patrick Erichsen 2025-03-31 17:49:31 -07:00 • committed by GitHub
commit d570f54330
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -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;

View file

@ -9,7 +9,7 @@ import {
addPromptCompletionPair,
selectUseTools,
setToolGenerated,
streamUpdate,
streamUpdate
} from "../slices/sessionSlice";
import { ThunkApiType } from "../store";
import { callTool } from "./callTool";
@ -70,7 +70,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]));