quivr/frontend/lib/api/brain/useBrainApi.ts
Stan Girard 36b008e0eb
feat: Refactor get_question_context_for_brain endpoint (#1872)
to return a list of DocumentAnswer objects

# 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):
2023-12-12 22:33:23 +01:00

60 lines
1.9 KiB
TypeScript

import { useAxios } from "@/lib/hooks";
import {
addBrainSubscriptions,
createBrain,
deleteBrain,
getBrain,
getBrains,
getBrainUsers,
getDefaultBrain,
getDocsFromQuestion,
getPublicBrains,
setAsDefaultBrain,
Subscription,
updateBrain,
updateBrainAccess,
updateBrainSecrets,
} from "./brain";
import {
CreateBrainInput,
SubscriptionUpdatableProperties,
UpdateBrainInput,
} from "./types";
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const useBrainApi = () => {
const { axiosInstance } = useAxios();
return {
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),
updateBrain: async (brainId: string, brain: UpdateBrainInput) =>
updateBrain(brainId, brain, axiosInstance),
getPublicBrains: async () => getPublicBrains(axiosInstance),
getDocsFromQuestion: async (brainId: string, question: string) =>
getDocsFromQuestion(brainId, question, axiosInstance),
updateBrainSecrets: async (
brainId: string,
secrets: Record<string, string>
) => updateBrainSecrets(brainId, secrets, axiosInstance),
};
};