Thinking stream (#2276)

* feat: stream thinking tokens

* fix: retry bug

* fix test
This commit is contained in:
Alex
2026-02-09 14:27:53 +00:00
committed by GitHub
parent fea94379d7
commit 36c7bd9206
8 changed files with 103 additions and 36 deletions

View File

@@ -195,12 +195,21 @@ export const agentPreviewSlice = createSlice({
},
resendQuery(
state,
action: PayloadAction<{ index: number; prompt: string; query?: Query }>,
action: PayloadAction<{ index: number; prompt: string }>,
) {
state.queries = [
...state.queries.splice(0, action.payload.index),
action.payload,
];
const { index, prompt } = action.payload;
if (index < 0 || index >= state.queries.length) return;
state.queries.splice(index + 1);
state.queries[index].prompt = prompt;
delete state.queries[index].response;
delete state.queries[index].thought;
delete state.queries[index].sources;
delete state.queries[index].tool_calls;
delete state.queries[index].error;
delete state.queries[index].structured;
delete state.queries[index].schema;
delete state.queries[index].feedback;
},
updateStreamingQuery(
state,
@@ -309,10 +318,13 @@ export const agentPreviewSlice = createSlice({
.addCase(fetchPreviewAnswer.rejected, (state, action) => {
if (action.meta.aborted) {
state.status = 'idle';
return state;
return;
}
state.status = 'failed';
state.queries[state.queries.length - 1].error = 'Something went wrong';
if (state.queries.length > 0) {
state.queries[state.queries.length - 1].error =
'Something went wrong';
}
});
},
});