@lobehub/chat
Version:
Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.
44 lines (37 loc) • 1.02 kB
text/typescript
import { EdgeConfigClient, createClient } from '@vercel/edge-config';
import { appEnv } from '@/envs/app';
const EdgeConfigKeys = {
/**
* Assistant whitelist
*/
AssistantBlacklist: 'assistant_blacklist',
/**
* Assistant whitelist
*/
AssistantWhitelist: 'assistant_whitelist',
};
export class EdgeConfig {
get client(): EdgeConfigClient {
if (!appEnv.VERCEL_EDGE_CONFIG) {
throw new Error('VERCEL_EDGE_CONFIG is not set');
}
return createClient(appEnv.VERCEL_EDGE_CONFIG);
}
/**
* Check if Edge Config is enabled
*/
static isEnabled() {
return !!appEnv.VERCEL_EDGE_CONFIG;
}
getAgentRestrictions = async () => {
const { assistant_blacklist: blacklist, assistant_whitelist: whitelist } =
await this.client.getAll([
EdgeConfigKeys.AssistantWhitelist,
EdgeConfigKeys.AssistantBlacklist,
]);
return { blacklist, whitelist } as {
blacklist: string[] | undefined;
whitelist: string[] | undefined;
};
};
}