import { defineStore } from 'pinia'
import { ref } from 'vue'

export interface AnswerSettingStateTypes {
  id?: string; // 智能体id
  name?: string;  // 智能体名称
  applicationDesc?: string; // 智能体描述
  imgUrl?: string; // 图片地址
  imgRelUrl?: string; // 图片相对地址
  model?: string; // 模型
  random?: number; // 生成随机性
  circles?: number; // 携带上下文轮数
  replayLength?: number; // 最大回复长度
  spStatus?: boolean; // SP防泄漏指令状态
  showThinkStatus?: boolean; // 展示思考过程状态
  opening?: string; // 开场白
  questions?: Array<any>; // 引导问题
  reminder?: string; // 提示词
  state?: boolean;  // 状态
  labelIds?: Array<any>; // 标签
  knowledgeIds?: Array<any>; // 知识库
}


const useAnswerSettingStore = defineStore('answerSetting',  () =>{
  const info = ref<AnswerSettingStateTypes>({
    id:'',
    name: '',
    applicationDesc: '',
    imgUrl: '',
    imgRelUrl: '',
    model: '',
    random: 0,
    circles: 0,
    replayLength: 0,
    spStatus: false,
    showThinkStatus: false,
    opening: '',
    reminder: '',
    questions: [],
    labelIds: [],
    knowledgeIds:[]
  })

  /* Actions */
  async function addAnswers(data: AnswerSettingStateTypes) {
    const { id, name, applicationDesc, imgUrl, imgRelUrl, model, random, circles, replayLength, spStatus, showThinkStatus, opening, reminder, questions, labelIds, knowledgeIds} = data;
    info.value = {
      id, 
      name, 
      applicationDesc, 
      imgUrl, 
      imgRelUrl,
      model, 
      random: random ? random * 1 : 0,
      circles, 
      replayLength, 
      spStatus, 
      showThinkStatus, 
      opening, 
      reminder, 
      questions, 
      labelIds, 
      knowledgeIds,
    }
  }

  return {
    info,
    addAnswers,
  }
})

export default useAnswerSettingStore
