UNPKG

@mi-gpt/chat

Version:
29 lines (26 loc) 773 B
import { StreamResponse } from '@mi-gpt/stream'; import { ChatConfig } from './config.js'; import '@mi-gpt/openai/config'; import '@mi-gpt/stream/config'; import '@mi-gpt/utils/typing'; interface IMessage { id: string; text: string; timestamp: number; sender: 'user' | 'assistant'; } declare class _ChatBot { history: IMessage[]; config: ChatConfig; init(config?: ChatConfig): void; dispose(): void; chat(msg: IMessage): Promise<string>; /** * 处理用户消息,返回流式响应 */ chatWithStream(msg: IMessage, onError?: (error: Error) => Promise<void>): Promise<StreamResponse>; private _getMessages; private _addMessage; } declare const ChatBot: _ChatBot; export { ChatBot, type IMessage, _ChatBot };