mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-16 10:02:30 +03:00
da8e7513e6
# 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>
45 lines
1.4 KiB
TypeScript
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),
|
|
};
|
|
};
|