jan/web/types/chatMessage.d.ts
NamH 1fc9c4e220
fix(#591): prevent duplicate message id issue (#595)
Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
2023-11-14 09:37:54 +07:00

64 lines
1.1 KiB
TypeScript

/* eslint-disable @typescript-eslint/naming-convention */
enum MessageType {
Text = 'Text',
Image = 'Image',
ImageWithText = 'ImageWithText',
Error = 'Error',
}
export enum MessageSenderType {
Ai = 'assistant',
User = 'user',
}
enum MessageStatus {
Ready = 'ready',
Pending = 'pending',
}
interface ChatMessage {
id: string
conversationId: string
messageType: MessageType
messageSenderType: MessageSenderType
senderUid: string
senderName: string
senderAvatarUrl: string
text: string | undefined
imageUrls?: string[] | undefined
createdAt: number
status: MessageStatus
}
interface RawMessage {
_id?: string
conversationId?: string
user?: string
avatar?: string
message?: string
createdAt?: string
updatedAt?: string
}
interface Conversation {
_id: string
modelId?: string
name?: string
image?: string
message?: string
lastMessage?: string
summary?: string
createdAt?: string
updatedAt?: string
botId?: string
}
/**
* Store the state of conversation like fetching, waiting for response, etc.
*/
type ConversationState = {
hasMore: boolean
waitingForResponse: boolean
error?: Error
}