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.

25 lines (16 loc) 912 B
import { shallow } from 'zustand/shallow'; import { createWithEqualityFn } from 'zustand/traditional'; import { StateCreator } from 'zustand/vanilla'; import { createDevtools } from '../middleware/createDevtools'; import { AgentStoreState, initialState } from './initialState'; import { AgentChatAction, createChatSlice } from './slices/chat/action'; // =============== aggregate createStoreFn ============ // export interface AgentStore extends AgentChatAction, AgentStoreState {} const createStore: StateCreator<AgentStore, [['zustand/devtools', never]]> = (...parameters) => ({ ...initialState, ...createChatSlice(...parameters), }); // =============== implement useStore ============ // const devtools = createDevtools('agent'); export const useAgentStore = createWithEqualityFn<AgentStore>()(devtools(createStore), shallow); export const getAgentStoreState = () => useAgentStore.getState();