mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 18:30:15 +01:00
15 lines
595 B
TypeScript
15 lines
595 B
TypeScript
|
|
import { useGetEndpointsQuery } from 'librechat-data-provider';
|
||
|
|
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 };
|
||
|
|
}
|