import api from './client' export interface ChatMessage { id: string role: 'user' | 'assistant' | 'system' content: string created_at: string } export interface ChatSession { session_id: string last_message: string message_count: number created_at: string } export interface ChatResponse { session_id: string user_message: ChatMessage assistant_message: ChatMessage } export async function sendChatMessage( message: string, sessionId?: string, contextType?: string, contextId?: string, ): Promise { const res = await api.post('/chat/messages', { message, session_id: sessionId || undefined, context_type: contextType || undefined, context_id: contextId || undefined, }) return res.data } export async function getChatSessions(): Promise { const res = await api.get('/chat/sessions') return res.data } export async function getSessionMessages(sessionId: string): Promise { const res = await api.get(`/chat/sessions/${sessionId}/messages`) return res.data } export async function deleteChatSession(sessionId: string): Promise { await api.delete(`/chat/sessions/${sessionId}`) }