mirror of
https://github.com/arc53/DocsGPT.git
synced 2026-02-23 12:53:43 +00:00
Thinking stream (#2276)
* feat: stream thinking tokens * fix: retry bug * fix test
This commit is contained in:
@@ -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';
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user