mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-12-02 18:13:13 +00:00
feat: Enhance agent selection and conversation handling
- Added functionality to select agents in the Navigation component, allowing users to reset conversations and set the selected agent. - Updated the MessageInput component to conditionally show source and tool buttons based on the selected agent. - Modified the Conversation component to handle agent-specific queries and manage file uploads. - Improved conversation fetching logic to include agent IDs and handle attachments. - Introduced new types for conversation summaries and results to streamline API responses. - Refactored Redux slices to manage selected agent state and improve overall state management. - Enhanced error handling and loading states across components for better user experience.
This commit is contained in:
@@ -38,8 +38,8 @@ export const fetchAnswer = createAsyncThunk<
|
||||
|
||||
let isSourceUpdated = false;
|
||||
const state = getState() as RootState;
|
||||
const attachments = state.conversation.attachments?.map(a => a.id) || [];
|
||||
|
||||
const attachments = state.conversation.attachments?.map((a) => a.id) || [];
|
||||
|
||||
if (state.preference) {
|
||||
if (API_STREAMING) {
|
||||
await handleFetchAnswerSteaming(
|
||||
@@ -80,7 +80,6 @@ export const fetchAnswer = createAsyncThunk<
|
||||
);
|
||||
} else if (data.type === 'thought') {
|
||||
const result = data.thought;
|
||||
console.log('thought', result);
|
||||
dispatch(
|
||||
updateThought({
|
||||
index: indx ?? state.conversation.queries.length - 1,
|
||||
@@ -122,7 +121,8 @@ export const fetchAnswer = createAsyncThunk<
|
||||
}
|
||||
},
|
||||
indx,
|
||||
attachments
|
||||
state.preference.selectedAgent?.id,
|
||||
attachments,
|
||||
);
|
||||
} else {
|
||||
const answer = await handleFetchAnswer(
|
||||
@@ -135,7 +135,8 @@ export const fetchAnswer = createAsyncThunk<
|
||||
state.preference.prompt.id,
|
||||
state.preference.chunks,
|
||||
state.preference.token_limit,
|
||||
attachments
|
||||
state.preference.selectedAgent?.id,
|
||||
attachments,
|
||||
);
|
||||
if (answer) {
|
||||
let sourcesPrepped = [];
|
||||
@@ -286,7 +287,10 @@ export const conversationSlice = createSlice({
|
||||
const { index, message } = action.payload;
|
||||
state.queries[index].error = message;
|
||||
},
|
||||
setAttachments: (state, action: PayloadAction<{ fileName: string; id: string }[]>) => {
|
||||
setAttachments: (
|
||||
state,
|
||||
action: PayloadAction<{ fileName: string; id: string }[]>,
|
||||
) => {
|
||||
state.attachments = action.payload;
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user