@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.
36 lines (30 loc) • 961 B
text/typescript
import { StateCreator } from 'zustand/vanilla';
import { messageService } from '@/services/message';
import { ChatStore } from '@/store/chat/store';
import { ChatTTS } from '@/types/message';
/**
* enhance chat action like translate,tts
*/
export interface ChatTTSAction {
clearTTS: (id: string) => Promise<void>;
ttsMessage: (
id: string,
state?: { contentMd5?: string; file?: string; voice?: string },
) => Promise<void>;
updateMessageTTS: (id: string, data: Partial<ChatTTS> | false) => Promise<void>;
}
export const chatTTS: StateCreator<ChatStore, [['zustand/devtools', never]], [], ChatTTSAction> = (
set,
get,
) => ({
clearTTS: async (id) => {
await get().updateMessageTTS(id, false);
},
ttsMessage: async (id, state = {}) => {
await get().updateMessageTTS(id, state);
},
updateMessageTTS: async (id, data) => {
await messageService.updateMessageTTS(id, data);
await get().refreshMessages();
},
});