import request from './request'

// 对话历史接口
export interface ChatMessage {
  id: string
  role: 'user' | 'assistant'
  type?: 'text' | 'action_card'
  content?: string
  action?: string
  card?: Record<string, any>  // action_card 结构化数据
  created_at?: string
  metadata?: Record<string, any>
}

// 获取对话历史
export const getChatHistory = (limit: number = 50) => {
  return request.get<{ data: ChatMessage[] }>('/chat/history', { params: { limit } })
}

// 获取动作卡片回调
export const sendActionCardCallback = (data: { card_type: string; action_key: string; params: Record<string, any> }) => {
  return request.post('/chat/action-card/callback', data)
}
