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.

37 lines (31 loc) 1.02 kB
import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk'; import { produce } from 'immer'; import { PluginManifestMap } from '@/types/tool/plugin'; type AddManifestDispatch = { id: string; plugin: LobeChatPluginManifest; type: 'addManifest' }; type DeleteManifestDispatch = { id: string; type: 'deleteManifest' }; // type UpdateManifestDispatch = { // id: string; // plugin: LobeChatPlugin; // type: 'updateManifest'; // version: string; // }; export type PluginDispatch = AddManifestDispatch | DeleteManifestDispatch; // | UpdateManifestDispatch; export const pluginManifestReducer = ( state: PluginManifestMap, payload: PluginDispatch, ): PluginManifestMap => { switch (payload.type) { case 'addManifest': { return produce(state, (draftState) => { draftState[payload.id] = payload.plugin; }); } case 'deleteManifest': { return produce(state, (draftState) => { delete draftState[payload.id]; }); } // case 'updateManifest' } };