quivr/frontend/lib/helpers/getAccessibleModels.ts
Stan Girard 322ee318be
feat: the good user management (#1158)
* feat(user_management): added user management

* feat(user_management): added user management

* feat(user_management): removed print

* feat: use tanstack query for user data fecthing

* feat: add getUser to sdk

* feat: improve user page ux use tanstack query

* feat: fetch models from backend on brains settings page

* feat: update model selection on chat page

* feat: update tests

---------

Co-authored-by: mamadoudicko <mamadoudicko100@gmail.com>
2023-09-13 13:47:12 +02:00

21 lines
535 B
TypeScript

import { UserStats } from "@/lib/types/User";
import { freeModels, paidModels } from "@/lib/types/brainConfig";
type GetAccessibleModelsInput = {
openAiKey?: string | null;
userData?: UserStats;
};
export const getAccessibleModels = ({
openAiKey,
userData,
}: GetAccessibleModelsInput): string[] => {
if (userData?.models !== undefined) {
return userData.models;
}
if (openAiKey !== undefined && openAiKey !== null) {
return paidModels as unknown as string[];
}
return freeModels as unknown as string[];
};