2023-12-11 14:48:40 -05:00
|
|
|
import { useGetEndpointsQuery } from 'librechat-data-provider/react-query';
|
2023-12-05 09:38:04 -05:00
|
|
|
import { useChatContext } from '~/Providers/ChatContext';
|
|
|
|
|
import useUserKey from './useUserKey';
|
|
|
|
|
|
|
|
|
|
export default function useRequiresKey() {
|
|
|
|
|
const { conversation } = useChatContext();
|
|
|
|
|
const { data: endpointsConfig } = useGetEndpointsQuery();
|
|
|
|
|
const { endpoint } = conversation || {};
|
|
|
|
|
const userProvidesKey = endpointsConfig?.[endpoint ?? '']?.userProvide;
|
|
|
|
|
const { getExpiry } = useUserKey(endpoint ?? '');
|
|
|
|
|
const expiryTime = getExpiry();
|
|
|
|
|
const requiresKey = !expiryTime && userProvidesKey;
|
|
|
|
|
return { requiresKey };
|
|
|
|
|
}
|