import request from '@/utils/request'

// 获取提示词模板列表
export function listPromptTemplates() {
  return request({
    url: '/jarvis/social-media/prompt/list',
    method: 'get'
  })
}

// 获取单个提示词模板（key 含冒号时需编码）
export function getPromptTemplate(key) {
  return request({
    url: '/jarvis/social-media/prompt/' + encodeURIComponent(key),
    method: 'get'
  })
}

// 保存提示词模板
export function savePromptTemplate(data) {
  return request({
    url: '/jarvis/social-media/prompt/save',
    method: 'post',
    data
  })
}

// 删除提示词模板（恢复默认）
export function deletePromptTemplate(key) {
  return request({
    url: '/jarvis/social-media/prompt/' + encodeURIComponent(key),
    method: 'delete'
  })
}

// —— 多套大模型接入（与 Jarvis 共用 Redis）——
export function listLlmProfiles() {
  return request({
    url: '/jarvis/social-media/llm-config',
    method: 'get'
  })
}

export function getLlmProfile(id) {
  return request({
    url: '/jarvis/social-media/llm-config/profiles/' + encodeURIComponent(id),
    method: 'get'
  })
}

export function createLlmProfile(data) {
  return request({
    url: '/jarvis/social-media/llm-config/profiles',
    method: 'post',
    data
  })
}

export function updateLlmProfile(id, data) {
  return request({
    url: '/jarvis/social-media/llm-config/profiles/' + encodeURIComponent(id),
    method: 'put',
    data
  })
}

export function deleteLlmProfile(id) {
  return request({
    url: '/jarvis/social-media/llm-config/profiles/' + encodeURIComponent(id),
    method: 'delete'
  })
}

export function setActiveLlmProfile(id) {
  return request({
    url: '/jarvis/social-media/llm-config/active/' + encodeURIComponent(id),
    method: 'put'
  })
}

export function clearActiveLlmProfile() {
  return request({
    url: '/jarvis/social-media/llm-config/active',
    method: 'delete'
  })
}

export function resetAllLlmConfig() {
  return request({
    url: '/jarvis/social-media/llm-config',
    method: 'delete'
  })
}

/** 连通测试：可选 profileId、message，不传 profileId 则用 Jarvis 当前激活/默认 */
export function testLlmProfile(data) {
  return request({
    url: '/jarvis/social-media/llm-config/test',
    method: 'post',
    data: data || {}
  })
}
