quivr/frontend/lib/api/chat/useChatApi.ts
Antoine Dewez da8e7513e6
feat(frontend & backend): thumbs for message feedback (#2360)
# Description

Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):

---------

Co-authored-by: Stan Girard <girard.stanislas@gmail.com>
2024-03-21 00:11:06 -07:00

45 lines
1.4 KiB
TypeScript

import { useAxios } from "@/lib/hooks";
import {
addQuestionAndAnswer,
QuestionAndAnwser,
} from "./addQuestionAndAnswer";
import {
addQuestion,
AddQuestionParams,
ChatMessageUpdatableProperties,
ChatUpdatableProperties,
createChat,
deleteChat,
getChatItems,
getChats,
updateChat,
updateChatMessage,
} from "./chat";
// TODO: split './chat.ts' into multiple files, per function for example
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const useChatApi = () => {
const { axiosInstance } = useAxios();
return {
createChat: async (chatName: string) => createChat(chatName, axiosInstance),
getChats: async () => getChats(axiosInstance),
deleteChat: async (chatId: string) => deleteChat(chatId, axiosInstance),
addQuestion: async (props: AddQuestionParams) =>
addQuestion(props, axiosInstance),
getChatItems: async (chatId: string) => getChatItems(chatId, axiosInstance),
updateChat: async (chatId: string, props: ChatUpdatableProperties) =>
updateChat(chatId, props, axiosInstance),
addQuestionAndAnswer: async (
chatId: string,
questionAndAnswer: QuestionAndAnwser
) => addQuestionAndAnswer(chatId, questionAndAnswer, axiosInstance),
updateChatMessage: async (
chatId: string,
messageId: string,
props: ChatMessageUpdatableProperties
) => updateChatMessage(chatId, messageId, props, axiosInstance),
};
};