Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions libs/shared/data-access/api/src/lib/chats/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
ChatResponse,
CompleteChatRequest,
CompleteChatResponse,
CompletedChat,
CreateNewChatRequest,
GetArchivedChatListRequest,
MoveChatToFolderRequest,
Expand Down Expand Up @@ -553,15 +552,6 @@ function useCompleteChat(
});
}

function useCompletedChat(
options?: UseMutationOptions<CompletedChat, AxiosError, CompletedChat>,
): UseMutationResult<CompletedChat, AxiosError, CompletedChat> {
return useMutation({
mutationFn: (params) => chatService.handleCompletedChat(params),
...options,
});
}

function useShareChat({
onSuccess,
...options
Expand Down Expand Up @@ -818,7 +808,6 @@ export const chatApi = {
useSearchInfinite,
useCreateNewChat,
useCompleteChat,
useCompletedChat,
useShareChat,
useDeleteShareChatLink,
useArchiveChat,
Expand Down
23 changes: 0 additions & 23 deletions libs/shared/data-access/api/src/lib/chats/models/completed-chat.ts

This file was deleted.

1 change: 0 additions & 1 deletion libs/shared/data-access/api/src/lib/chats/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export * from './complete-chat-response';
export * from './background-tasks';
export * from './get-chat-list-request';
export * from './chat-list-item';
export * from './completed-chat';
export * from './search-chat-list-request';
export * from './share-chat-response';
export * from './chat-message';
Expand Down
9 changes: 0 additions & 9 deletions libs/shared/data-access/api/src/lib/chats/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
ChatResponse,
CompleteChatRequest,
CompleteChatResponse,
CompletedChat,
CreateNewChatRequest,
GetArchivedChatListRequest,
GetChatListRequest,
Expand Down Expand Up @@ -129,14 +128,6 @@ export class ChatService extends EntityPromiseService<ChatResponse> {
);
}

public async handleCompletedChat(params: CompletedChat): Promise<CompletedChat> {
const request = instanceToPlain<CompletedChat>(params);

const response = await getApiService().post<CompletedChat>(`${chatServiceConfig.route}/completed`, request);

return plainToInstance(CompletedChat, response);
}

public async shareChat(chatId: string): Promise<ShareChatResponse> {
const response = await getApiService().post<ShareChatResponse>(
`${chatServiceConfig.versionedRoute}/${chatId}/share`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { merge, uniqBy } from 'lodash-es';
import { captureApiError } from '@open-webui-react-native/shared/data-access/api-client';
import { AttachedFile, FileType, MessageSource } from '@open-webui-react-native/shared/data-access/common';
import { queryClient } from '@open-webui-react-native/shared/data-access/query-client';
import { chatQueriesKeys } from '../chat-queries-keys';
import { Chat, ChatResponse, History, Message } from '../models';
import { chatService } from '../service';
import { prepareCompletedChatPayload } from './prepare-completed-chat-payload';
import { isTemporaryChatId } from './temporary-chat-id';

// NOTE: Deliberately does not call `POST /chat/completed`. The app supports Open WebUI 0.10 and
// newer, and since 0.9.0 the backend runs outlet filters inline during the completion and persists
// the assistant message itself — the web client dropped the call in that same release, leaving it
// for external integrations only. Calling it re-ran the filters on a payload this client discards,
// and the endpoint turns every internal error into a 400 (a missing `model`, a stale `session_id`,
// a throwing filter), which used to abort the chat update below.
export const handleCompletedChat = async (
message: string,
chatId: string,
sessionId: string,
sources?: Array<MessageSource>,
output?: Message['output'],
): Promise<void> => {
Expand Down Expand Up @@ -43,15 +46,6 @@ export const handleCompletedChat = async (
currentId: chat.history.currentId,
});

const completedChatPayload = prepareCompletedChatPayload(
chatId,
updatedHistory.currentId,
updatedMessages,
chat.models?.[0],
sessionId,
message,
);

// Only files should be included in `files` field
const files = uniqBy(
chat.messages.flatMap((msg) => msg.files ?? []).filter((file): file is AttachedFile => file.type === FileType.FILE),
Expand All @@ -64,17 +58,5 @@ export const handleCompletedChat = async (
files,
});

const sentryContext = { chatId, sessionId };

try {
const data = await chatService.handleCompletedChat(completedChatPayload);

try {
await chatService.update({ id: data.chatId, chat: updateChatPayload });
} catch (error) {
captureApiError(error, { operation: 'chat.update', context: sentryContext });
}
} catch (error) {
captureApiError(error, { operation: 'chat.completed', context: sentryContext });
}
await chatService.update({ id: chatId, chat: updateChatPayload });
};
1 change: 0 additions & 1 deletion libs/shared/data-access/api/src/lib/chats/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './prepare-create-chat-payload';
export * from './prepare-complete-chat-payload';
export * from './prepare-completed-chat-payload';
export * from './prepare-send-message-payload';
export * from './patch-chat-message-with-completion';
export * from './patch-completed-message';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
ChatCompletionChunk,
getOutputText,
seedResponseStreamState,
socketService,
} from '@open-webui-react-native/shared/data-access/websocket';
import { hapticFeedbackService } from '@open-webui-react-native/shared/utils/haptic-feedback-service';
import { chatQueriesKeys } from '../../chat-queries-keys';
Expand All @@ -25,7 +24,6 @@ import {
// event is left carrying the tool-call boundaries and the terminal `done`. Both remain authoritative,
// which is why a snapshot also re-seeds the delta accumulator.
export const handleChatCompletionEvent = async (socketResponse: ChatEventBase): Promise<void> => {
const sessionId = socketService.socketSessionId;
const chatId = socketResponse.chatId;

const chatCompletionData = plainToInstance(ChatCompletionChunk, socketResponse.data.data);
Expand Down Expand Up @@ -66,7 +64,7 @@ export const handleChatCompletionEvent = async (socketResponse: ChatEventBase):
queryClient.setQueryData(chatQueriesKeys.get(chatId).queryKey, (oldData: ChatResponse) =>
patchCompletedMessage(oldData),
);
await handleCompletedChat(buffer.content, chatId, sessionId, buffer.sources, buffer.output);
await handleCompletedChat(buffer.content, chatId, buffer.sources, buffer.output);
resetChatStreamBuffer(chatId);
await hapticFeedbackService.trigger();
}
Expand Down
Loading