import request from '@/utils/request'

export function executeInstruction(data) {
  return request({
    url: '/jarvis/instruction/execute',
    method: 'post',
    data
  })
}

export function executeInstructionWithForce(data) {
  return request({
    url: '/jarvis/instruction/execute',
    method: 'post',
    data: {
      ...data,
      forceGenerate: true
    }
  })
}

/**
 * 获取历史消息记录
 * @param type request | response
 * @param limit 条数上限
 * @param keyword 可选，搜索关键词；传则后端在全部数据中过滤后返回
 */
export function getHistory(type, limit, keyword) {
  const params = { type, limit }
  if (keyword != null && String(keyword).trim() !== '') {
    params.keyword = String(keyword).trim()
  }
  return request({
    url: '/jarvis/instruction/history',
    method: 'get',
    params
  })
}


