quivr/frontend/lib/api/brain/useBrainApi.ts
Mamadou DICKO 046cc3fc1d
[Brain management] Add new fields to creation modal (#755)
* refactor(ModalConfig): move defineMaxTokensto helpers

* feat(AddBrain): add new properties

* feat(sdk): update createBrain

* feat(sdk): add setAsDefaultBrain
2023-07-25 12:08:08 +02:00

47 lines
1.5 KiB
TypeScript

import { useAxios } from "@/lib/hooks";
import {
addBrainSubscriptions,
createBrain,
CreateBrainInput,
deleteBrain,
getBrain,
getBrainDocuments,
getBrains,
getBrainUsers,
getDefaultBrain,
setAsDefaultBrain,
Subscription,
updateBrainAccess,
} from "./brain";
import { SubscriptionUpdatableProperties } from "./types";
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const useBrainApi = () => {
const { axiosInstance } = useAxios();
return {
getBrainDocuments: async (brainId: string) =>
getBrainDocuments(brainId, axiosInstance),
createBrain: async (brain: CreateBrainInput) =>
createBrain(brain, axiosInstance),
deleteBrain: async (id: string) => deleteBrain(id, axiosInstance),
getDefaultBrain: async () => getDefaultBrain(axiosInstance),
getBrains: async () => getBrains(axiosInstance),
getBrain: async (id: string) => getBrain(id, axiosInstance),
addBrainSubscriptions: async (
brainId: string,
subscriptions: Subscription[]
) => addBrainSubscriptions(brainId, subscriptions, axiosInstance),
getBrainUsers: async (brainId: string) =>
getBrainUsers(brainId, axiosInstance),
updateBrainAccess: async (
brainId: string,
userEmail: string,
subscription: SubscriptionUpdatableProperties
) => updateBrainAccess(brainId, userEmail, subscription, axiosInstance),
setAsDefaultBrain: async (brainId: string) =>
setAsDefaultBrain(brainId, axiosInstance),
};
};