mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
feat(api-endpoints.ts): add abortRequest endpoint
feat(data-service.ts): add abortRequestWithMessage function feat(react-query-service.ts): add useAbortRequestWithMessage hook
This commit is contained in:
parent
f946f90ef6
commit
828e438d53
3 changed files with 12 additions and 0 deletions
|
|
@ -6,6 +6,10 @@ export const messages = (id: string) => {
|
|||
return `/api/messages/${id}`;
|
||||
};
|
||||
|
||||
export const abortRequest = (endpoint: string) => {
|
||||
return `/api/ask/${endpoint}/abort`;
|
||||
};
|
||||
|
||||
export const conversations = (pageNumber: string) => {
|
||||
return `/api/convos?pageNumber=${pageNumber}`;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ export function getConversations(pageNumber: string): Promise<t.TGetConversation
|
|||
return request.get(endpoints.conversations(pageNumber));
|
||||
}
|
||||
|
||||
export function abortRequestWithMessage(endpoint: string, abortKey: string, message: string): Promise<void> {
|
||||
return request.post(endpoints.abortRequest(endpoint), { arg: {abortKey, message} });
|
||||
}
|
||||
|
||||
export function deleteConversation(payload: t.TDeleteConversationRequest) {
|
||||
//todo: this should be a DELETE request
|
||||
return request.post(endpoints.deleteConversation(), {arg: payload});
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ export enum QueryKeys {
|
|||
tokenCount = "tokenCount",
|
||||
}
|
||||
|
||||
export const useAbortRequestWithMessage = (): UseMutationResult<void, Error, { endpoint: string; abortKey: string; message: string }> => {
|
||||
return useMutation(({ endpoint, abortKey, message }) => dataService.abortRequestWithMessage(endpoint, abortKey, message));
|
||||
};
|
||||
|
||||
export const useGetUserQuery = (): QueryObserverResult<t.TUser> => {
|
||||
return useQuery<t.TUser>([QueryKeys.user], () => dataService.getUser(), {
|
||||
refetchOnWindowFocus: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue