UNPKG

@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.

29 lines (23 loc) 803 B
import { API_ENDPOINTS } from '@/services/_url'; import { useUserStore } from '@/store/user'; import { preferenceSelectors } from '@/store/user/selectors'; import { TraceEventBasePayload, TraceEventPayloads } from '@/types/trace'; class TraceService { private request = async <T>(data: T) => { try { return fetch(API_ENDPOINTS.trace, { body: JSON.stringify(data), headers: { 'Content-Type': 'application/json' }, method: 'POST', }); } catch (e) { console.error(e); } }; traceEvent = async (data: TraceEventPayloads & TraceEventBasePayload) => { const enabled = preferenceSelectors.userAllowTrace(useUserStore.getState()); if (!enabled) return; return this.request(data); }; } export const traceService = new TraceService();