This commit is contained in:
Alex
2024-03-14 11:37:33 +00:00
parent 70e1560cb3
commit 80a4a094af
10 changed files with 193 additions and 133 deletions

View File

@@ -32,7 +32,6 @@ export const fetchAnswer = createAsyncThunk<Answer, { question: string }>(
(event) => {
const data = JSON.parse(event.data);
// check if the 'end' event has been received
if (data.type === 'end') {
// set status to 'idle'
@@ -45,13 +44,14 @@ export const fetchAnswer = createAsyncThunk<Answer, { question: string }>(
console.error('Failed to fetch conversations: ', error);
});
searchEndpoint( //search for sources post streaming
searchEndpoint(
//search for sources post streaming
question,
state.preference.apiKey,
state.preference.selectedDocs!,
state.conversation.conversationId,
state.conversation.queries
).then(sources => {
state.conversation.queries,
).then((sources) => {
//dispatch streaming sources
dispatch(
updateStreamingSource({
@@ -168,7 +168,6 @@ export const conversationSlice = createSlice({
state,
action: PayloadAction<{ index: number; query: Partial<Query> }>,
) {
const { index, query } = action.payload;
if (!state.queries[index].sources) {
state.queries[index].sources = query?.sources;
@@ -196,8 +195,7 @@ export const conversationSlice = createSlice({
state.status = 'loading';
})
.addCase(fetchAnswer.rejected, (state, action) => {
if(action.meta.aborted)
{
if (action.meta.aborted) {
state.status = 'idle';
return state;
}