<template>
  <template v-if="state.indexMethod.show">
    <div class="__czr-title_1 mb-[0.5rem]">索引方式</div>
    <div class="flex w-full gap-[1rem]">
      <div
        class="__hover h-[8.38rem] flex-1 rounded-[var(--czr-gap)] bg-[#ffffff] px-[1.5rem] py-[1rem]"
        style="border: var(--czr-border); border-width: 0.13rem"
        :class="{ 'index-method-active': state.indexMethod.value === '高质量' }"
        @click="() => (state.indexMethod.value = '高质量')"
      >
        <div class="flex items-center">
          <img
            src="@/assets/images/model-icon-1.png"
            class="mr-[var(--czr-gap)] h-[3.25rem] w-[3.25rem]"
          />
          <div class="text-[1.25rem] font-bold text-[#2E3238]">高质量</div>
          <img
            src="@/assets/images/model-icon-3.png"
            class="h-[1.27rem] w-[2.88rem]"
          />
        </div>
        <div
          class="mt-[0.5rem] text-[0.88rem] text-[#606266]"
          style="line-height: 1.3rem"
        >
          调用嵌入模型来处理文档以实现更精确的检索，可以帮助大语言模型生成高质量的回答。
        </div>
      </div>
      <!--      <div-->
      <!--        class="__hover h-[8.38rem] flex-1 rounded-[var(&#45;&#45;czr-gap)] bg-[#ffffff] px-[1.5rem] py-[1rem]"-->
      <!--        style="border: var(&#45;&#45;czr-border); border-width: 0.13rem"-->
      <!--        :class="{ 'index-method-active': state.indexMethod.value === 2 }"-->
      <!--        @click="() => state.indexMethod.value = 2"-->
      <!--      >-->
      <!--        <div class="flex items-center">-->
      <!--          <img-->
      <!--            src="@/assets/images/model-icon-2.png"-->
      <!--            class="mr-[var(&#45;&#45;czr-gap)] h-[3.25rem] w-[3.25rem]"-->
      <!--          />-->
      <!--          <div class="text-[1.25rem] font-bold text-[#2E3238]">经济</div>-->
      <!--        </div>-->
      <!--        <div-->
      <!--          class="mt-[0.5rem] text-[0.88rem] text-[#606266]"-->
      <!--          style="line-height: 1.3rem"-->
      <!--        >-->
      <!--          每个块使用 10 个关键词进行检索，不消耗 tokens，但会降低检索准确性。-->
      <!--        </div>-->
      <!--      </div>-->
    </div>
    <div
      v-if="state.indexMethod.value === '高质量'"
      class="mt-[var(--czr-gap)] flex h-[2.5rem] w-full items-center gap-[0.5rem] rounded-[0.25rem] px-[0.75rem] text-[0.8rem] text-[#666666]"
      style="
        border: var(--czr-border);
        border-color: var(--czr-warning-color);
        background-color: rgba(var(--czr-warning-color-rgb), 0.1);
      "
    >
      <SvgIcon
        name="czr_tip"
        color="var(--czr-warning-color)"
      />使用高质量模式进行嵌入后，无法切换回经济模式。
    </div>
  </template>
  <template v-if="state.embedding.show">
    <div class="__czr-title_1 mb-[0.5rem]">Embedding 模型</div>
    <CzrFormColumn
      required
      class="__czr-table-form-column"
      :span="24"
      label="模型类型"
      v-model:param="state.embedding.value"
      link="select"
      :options="state.optionsEmbedding"
      :clearable="false"
    />
  </template>
  <template v-if="state.searchMethod.show">
    <div class="__czr-title_1">检索方式</div>
    <div
      class="mt-[1rem] w-full cursor-pointer rounded-[var(--czr-gap)] bg-[#ffffff]"
      style="border: var(--czr-border); border-width: 0.13rem"
      :class="{
        'search-method-active':
          state.searchMethod.value === SearchMethodType.Vector,
      }"
      @click="() => (state.searchMethod.value = SearchMethodType.Vector)"
    >
      <div class="h-full w-full px-[1.5rem] py-[1rem]">
        <div class="flex items-center">
          <img
            src="@/assets/images/model-icon-4.png"
            class="mr-[var(--czr-gap)] h-[3.25rem] w-[3.25rem]"
          />
          <div class="text-[1.25rem] font-bold text-[#2E3238]">向量检索</div>
        </div>
        <div
          class="mt-[0.5rem] text-[0.88rem] text-[#606266]"
          style="line-height: 1.3rem"
        >
          通过生成查询嵌入并查询与其向量表示最相似的文本分段
        </div>
        <template v-if="state.searchMethod.value === SearchMethodType.Vector">
          <div
            class="mt-[1rem] flex flex-col gap-[0.5rem] rounded-[0.25rem] bg-[#ffffff] p-[var(--czr-gap)] text-[1rem] font-bold text-[#2E3238]"
          >
            <div class="flex items-center gap-[0.5rem]">
              <el-switch
                size="small"
                v-model="state.searchMethod[SearchMethodType.Vector].isRerank"
                :active-value="1"
                :inactive-value="0"
              />
              Rerank 模型
              <el-tooltip
                content="重排序模型将根据候选文档列表与用户问题语义匹配度进行重新排序，从而改进语义排序的结果。"
                placement="top"
              >
                <SvgIcon name="czr_tip" size="14" />
              </el-tooltip>
            </div>
            <template
              v-if="state.searchMethod[SearchMethodType.Vector].isRerank"
            >
              <CzrFormColumn
                required
                class="__czr-table-form-column"
                :span="24"
                label-width="0px"
                v-model:param="
                  state.searchMethod[SearchMethodType.Vector].rerank
                "
                link="select"
                :options="state.optionsRerank"
                :clearable="false"
                default-error-msg="请选择Rerank模型"
              />
            </template>
            <div class="flex gap-[1rem]">
              <div class="flex-1">
                <div class="flex h-[1rem] items-center gap-[0.5rem]">
                  TOP K
                  <el-tooltip
                    content="用于筛选与用户问题相似度最高的文本片段。系统同时会根据选用模型上下文窗口大小动态调整分段数量。"
                    placement="top"
                  >
                    <SvgIcon name="czr_tip" size="14" />
                  </el-tooltip>
                </div>
                <div class="mt-[1rem]">
                  <el-slider
                    v-model="state.searchMethod[SearchMethodType.Vector].topK"
                    show-input
                    class="re-slider"
                    :min="1"
                    :max="10"
                  />
                </div>
              </div>
              <div class="flex-1">
                <div class="flex h-[1rem] items-center gap-[0.5rem]">
                  <el-switch
                    size="small"
                    v-model="
                      state.searchMethod[SearchMethodType.Vector].isScore
                    "
                    :active-value="1"
                    :inactive-value="0"
                  />
                  Score 阈值
                  <el-tooltip
                    content="重排序模型将根据候选文档列表与用户问题语义匹配度进行重新排序，从而改进语义排序的结果。"
                    placement="top"
                  >
                    <SvgIcon name="czr_tip" size="14" />
                  </el-tooltip>
                </div>
                <div class="mt-[1rem]">
                  <el-slider
                    v-model="state.searchMethod[SearchMethodType.Vector].score"
                    show-input
                    class="re-slider"
                    :max="1"
                    :min="0"
                    :step="0.1"
                    :disabled="
                      !state.searchMethod[SearchMethodType.Vector].isScore
                    "
                  />
                </div>
              </div>
            </div>
          </div>
        </template>
      </div>
    </div>
    <div
      class="mt-[1rem] w-full cursor-pointer rounded-[var(--czr-gap)] bg-[#ffffff]"
      style="border: var(--czr-border); border-width: 0.13rem"
      :class="{
        'search-method-active':
          state.searchMethod.value === SearchMethodType.Global,
      }"
      @click="() => (state.searchMethod.value = SearchMethodType.Global)"
    >
      <div class="h-full w-full px-[1.5rem] py-[1rem]">
        <div class="flex items-center">
          <img
            src="@/assets/images/model-icon-5.png"
            class="mr-[var(--czr-gap)] h-[3.25rem] w-[3.25rem]"
          />
          <div class="text-[1.25rem] font-bold text-[#2E3238]">全文检索</div>
        </div>
        <div
          class="mt-[0.5rem] text-[0.88rem] text-[#606266]"
          style="line-height: 1.3rem"
        >
          索引文档中的所有词汇，从而允许用户查询任意词汇，并返回包含这些词汇的文本片段
        </div>
        <template v-if="state.searchMethod.value === SearchMethodType.Global">
          <div
            class="mt-[1rem] flex flex-col gap-[0.5rem] rounded-[0.25rem] bg-[#ffffff] p-[var(--czr-gap)] text-[1rem] font-bold text-[#2E3238]"
          >
            <div class="flex items-center gap-[0.5rem]">
              <el-switch
                size="small"
                v-model="state.searchMethod[SearchMethodType.Global].isRerank"
                :active-value="1"
                :inactive-value="0"
              />
              Rerank 模型
              <el-tooltip
                content="用于筛选与用户问题相似度最高的文本片段。系统同时会根据选用模型上下文窗口大小动态调整分段数量。"
                placement="top"
              >
                <SvgIcon name="czr_tip" size="14" />
              </el-tooltip>
            </div>
            <template
              v-if="state.searchMethod[SearchMethodType.Global].isRerank"
            >
              <CzrFormColumn
                class="__czr-table-form-column"
                :span="24"
                label-width="0px"
                v-model:param="
                  state.searchMethod[SearchMethodType.Global].rerank
                "
                link="select"
                :options="state.optionsRerank"
                :clearable="false"
                default-error-msg="请选择Rerank模型"
              />
            </template>
            <div class="flex gap-[1rem]">
              <div class="flex-1">
                <div class="flex h-[1rem] items-center gap-[0.5rem]">
                  TOP K
                  <el-tooltip
                    content="用于筛选与用户问题相似度最高的文本片段。系统同时会根据选用模型上下文窗口大小动态调整分段数量。"
                    placement="top"
                  >
                    <SvgIcon name="czr_tip" size="14" />
                  </el-tooltip>
                </div>
                <div class="mt-[1rem]">
                  <el-slider
                    v-model="state.searchMethod[SearchMethodType.Global].topK"
                    show-input
                    class="re-slider"
                    :min="1"
                    :max="10"
                  />
                </div>
              </div>
              <div
                class="flex-1"
                v-if="state.searchMethod[SearchMethodType.Global].isRerank"
              >
                <div class="flex h-[1rem] items-center gap-[0.5rem]">
                  <el-switch
                    size="small"
                    v-model="
                      state.searchMethod[SearchMethodType.Global].isScore
                    "
                    :active-value="1"
                    :inactive-value="0"
                  />
                  Score 阈值
                  <el-tooltip
                    content="用于设置文本片段筛选的相似度阈值。"
                    placement="top"
                  >
                    <SvgIcon name="czr_tip" size="14" />
                  </el-tooltip>
                </div>
                <div class="mt-[1rem]">
                  <el-slider
                    v-model="state.searchMethod[SearchMethodType.Global].score"
                    show-input
                    class="re-slider"
                    :max="1"
                    :min="0"
                    :step="0.1"
                    :disabled="
                      !state.searchMethod[SearchMethodType.Global].isScore
                    "
                  />
                </div>
              </div>
            </div>
          </div>
        </template>
      </div>
    </div>
    <div
      class="mt-[1rem] w-full cursor-pointer rounded-[var(--czr-gap)] bg-[#ffffff]"
      style="border: var(--czr-border); border-width: 0.13rem"
      :class="{
        'search-method-active':
          state.searchMethod.value === SearchMethodType.Mix,
      }"
      @click="() => (state.searchMethod.value = SearchMethodType.Mix)"
    >
      <div class="h-full w-full px-[1.5rem] py-[1rem]">
        <div class="flex items-center">
          <img
            src="@/assets/images/model-icon-6.png"
            class="mr-[var(--czr-gap)] h-[3.25rem] w-[3.25rem]"
          />
          <div class="text-[1.25rem] font-bold text-[#2E3238]">混合检索</div>
          <img
            src="@/assets/images/model-icon-3.png"
            class="h-[1.27rem] w-[2.88rem]"
          />
        </div>
        <div
          class="mt-[0.5rem] text-[0.88rem] text-[#606266]"
          style="line-height: 1.3rem"
        >
          同时执行全文检索和向量检索，并应用重排序步骤，从两类查询结果中选择匹配用户问题的最佳结果，用户可以选择设置权重或配置重新排序模型。
        </div>
        <template v-if="state.searchMethod.value === SearchMethodType.Mix">
          <div class="mt-[1rem] flex w-full gap-[1rem]">
            <div
              class="__hover h-[8.38rem] flex-1 rounded-[var(--czr-gap)] bg-[#ffffff] px-[1.5rem] py-[1rem]"
              style="border: var(--czr-border); border-width: 0.13rem"
              :class="{
                'index-method-active':
                  state.searchMethod[SearchMethodType.Mix].indexMethod ===
                  'weightSetting',
              }"
              @click="
                () =>
                  (state.searchMethod[SearchMethodType.Mix].indexMethod =
                    'weightSetting')
              "
            >
              <div class="flex items-center">
                <img
                  src="@/assets/images/model-icon-8.png"
                  class="mr-[var(--czr-gap)] h-[3.25rem] w-[3.25rem]"
                />
                <div class="text-[1.25rem] font-bold text-[#2E3238]">
                  权重设置
                </div>
                <img
                  src="@/assets/images/model-icon-3.png"
                  class="h-[1.27rem] w-[2.88rem]"
                />
              </div>
              <div
                class="mt-[0.5rem] text-[0.88rem] text-[#606266]"
                style="line-height: 1.3rem"
              >
                通过调整分配的权重，重新排序策略确定是优先进行语义匹配还是关键字匹配。
              </div>
            </div>
            <div
              class="__hover h-[8.38rem] flex-1 rounded-[var(--czr-gap)] bg-[#ffffff] px-[1.5rem] py-[1rem]"
              style="border: var(--czr-border); border-width: 0.13rem"
              :class="{
                'index-method-active':
                  state.searchMethod[SearchMethodType.Mix].indexMethod ===
                  'rerank',
              }"
              @click="
                () =>
                  (state.searchMethod[SearchMethodType.Mix].indexMethod =
                    'rerank')
              "
            >
              <div class="flex items-center">
                <img
                  src="@/assets/images/model-icon-9.png"
                  class="mr-[var(--czr-gap)] h-[3.25rem] w-[3.25rem]"
                />
                <div class="text-[1.25rem] font-bold text-[#2E3238]">
                  Rerank 模型
                </div>
              </div>
              <div
                class="mt-[0.5rem] text-[0.88rem] text-[#606266]"
                style="line-height: 1.3rem"
              >
                重排序模型将根据候选文档列表与用户问题语义匹配度进行重新排序，从而改进语义排序的结果。
              </div>
            </div>
          </div>
          <div
            class="mt-[1rem] flex flex-col gap-[0.5rem] rounded-[0.25rem] bg-[#ffffff] p-[var(--czr-gap)] text-[1rem] font-bold text-[#2E3238]"
          >
            <template
              v-if="
                state.searchMethod[SearchMethodType.Mix].indexMethod ===
                'weightSetting'
              "
            >
              <div>
                <el-slider
                  v-model="state.searchMethod[SearchMethodType.Mix].weight"
                  :min="0"
                  :max="1"
                  :step="0.1"
                  class="weight-slider"
                />
                <div class="flex justify-between">
                  <div class="text-[var(--czr-main-color)]">
                    语义 {{ state.searchMethod[SearchMethodType.Mix].weight }}
                  </div>
                  <div class="text-[var(--czr-success-color)]">
                    {{
                      (
                        1 - state.searchMethod[SearchMethodType.Mix].weight
                      ).toFixed(1)
                    }}
                    关键词
                  </div>
                </div>
              </div>
            </template>
            <template
              v-else-if="
                state.searchMethod[SearchMethodType.Mix].indexMethod ===
                'rerank'
              "
            >
              <CzrFormColumn
                class="__czr-table-form-column"
                :span="24"
                label-width="0px"
                v-model:param="state.searchMethod[SearchMethodType.Mix].rerank"
                link="select"
                :options="state.optionsRerank"
                :clearable="false"
                default-error-msg="请选择Rerank模型"
              />
            </template>
          </div>
          <div
            class="mt-[1rem] flex flex-col gap-[0.5rem] rounded-[0.25rem] bg-[#ffffff] p-[var(--czr-gap)] text-[1rem] font-bold text-[#2E3238]"
          >
            <div class="flex gap-[1rem]">
              <div class="flex-1">
                <div class="flex h-[1rem] items-center gap-[0.5rem]">
                  TOP K
                  <el-tooltip
                    content="用于筛选与用户问题相似度最高的文本片段。系统同时会根据选用模型上下文窗口大小动态调整分段数量。"
                    placement="top"
                  >
                    <SvgIcon name="czr_tip" size="14" />
                  </el-tooltip>
                </div>
                <div class="mt-[1rem]">
                  <el-slider
                    v-model="state.searchMethod[SearchMethodType.Mix].topK"
                    show-input
                    class="re-slider"
                    :min="1"
                    :max="10"
                  />
                </div>
              </div>
              <div class="flex-1">
                <div class="flex h-[1rem] items-center gap-[0.5rem]">
                  <el-switch
                    size="small"
                    v-model="state.searchMethod[SearchMethodType.Mix].isScore"
                    :active-value="1"
                    :inactive-value="0"
                  />
                  Score 阈值
                  <el-tooltip
                    content="用于设置文本片段筛选的相似度阈值。"
                    placement="top"
                  >
                    <SvgIcon name="czr_tip" size="14" />
                  </el-tooltip>
                </div>
                <div class="mt-[1rem]">
                  <el-slider
                    v-model="state.searchMethod[SearchMethodType.Mix].score"
                    show-input
                    class="re-slider"
                    :max="1"
                    :min="0"
                    :step="0.1"
                    :disabled="
                      !state.searchMethod[SearchMethodType.Mix].isScore
                    "
                  />
                </div>
              </div>
            </div>
          </div>
        </template>
      </div>
    </div>
  </template>
</template>

<script setup lang="ts">
import {
  computed,
  getCurrentInstance,
  onMounted,
  reactive,
  ref,
  watch,
} from 'vue'
import { useDictionaryStore } from '@/stores'
import { pluginGetListByType, pluginInstanceByType } from '@/api/modules/model'
import { ElMessage } from 'element-plus'

const DictionaryStore = useDictionaryStore()
const emit = defineEmits([])
const props = defineProps({})
const { proxy }: any = getCurrentInstance()
enum SearchMethodType {
  Vector = 'VECTOR',
  Global = 'FULL_TEXT',
  Mix = 'HYBRID',
}
const state: any = reactive({
  optionsEmbedding: [],
  optionsRerank: [],
  indexMethod: {
    show: true,
    value: '高质量',
  },
  embedding: {
    show: true,
    value: '',
  },
  searchMethod: {
    show: true,
    value: SearchMethodType.Vector,
    [SearchMethodType.Vector]: {
      isRerank: 1,
      rerank: '',
      topK: 5,
      isScore: 1,
      score: 0.5,
    },
    [SearchMethodType.Global]: {
      isRerank: 1,
      rerank: '',
      topK: 5,
      isScore: 1,
      score: 0.5,
    },
    [SearchMethodType.Mix]: {
      indexMethod: 1,
      weight: 0.7,
      rerank: '',
      topK: 5,
      isScore: 1,
      score: 0.5,
    },
  },
})
const optionsEmbeddingMapCpt = computed(() => {
  const map = new Map()
  state.optionsEmbedding.forEach((v) => {
    map.set(v.value, v)
  })
  return map
})
const optionsRerankMapCpt = computed(() => {
  const map = new Map()
  state.optionsRerank.forEach((v) => {
    map.set(v.value, v)
  })
  return map
})
const reset = () => {
  state.indexMethod = {
    show: true,
    value: '高质量',
  }
  state.embedding = {
    show: true,
    value: '',
  }
  state.searchMethod = {
    show: true,
    value: SearchMethodType.Vector,
    [SearchMethodType.Vector]: {
      isRerank: 1,
      rerank: '',
      topK: 5,
      isScore: 1,
      score: 0.5,
    },
    [SearchMethodType.Global]: {
      isRerank: 1,
      rerank: '',
      topK: 5,
      isScore: 1,
      score: 0.5,
    },
    [SearchMethodType.Mix]: {
      indexMethod: 1,
      weight: 0.7,
      rerank: '',
      topK: 5,
      isScore: 1,
      score: 0.5,
    },
  }
}
const getData = () => {
  const result = {
    indexingTechnique: state.indexMethod.value,
    embeddingModelId: state.embedding.value,
    embeddingModel: optionsEmbeddingMapCpt.value.get(state.embedding.value)
      .label,
    indexConfig: {
      type: state.searchMethod.value,
    },
  }
  switch (state.searchMethod.value) {
    case SearchMethodType.Vector:
      {
        result.indexConfig.isRerank =
          state.searchMethod[SearchMethodType.Vector].isRerank
        result.indexConfig.rerankTypeId =
          state.searchMethod[SearchMethodType.Vector].rerank
        result.indexConfig.rerankType = optionsRerankMapCpt.value.get(
          state.searchMethod[SearchMethodType.Vector].rerank,
        ).label
        result.indexConfig.topK =
          state.searchMethod[SearchMethodType.Vector].topK
        result.indexConfig.isScore =
          state.searchMethod[SearchMethodType.Vector].isScore
        result.indexConfig.score =
          state.searchMethod[SearchMethodType.Vector].score
      }
      break
    case SearchMethodType.Global:
      {
        result.indexConfig.isRerank =
          state.searchMethod[SearchMethodType.Global].isRerank
        result.indexConfig.rerankTypeId =
          state.searchMethod[SearchMethodType.Global].rerank
        result.indexConfig.rerankType = optionsRerankMapCpt.value.get(
          state.searchMethod[SearchMethodType.Global].rerank,
        ).label
        result.indexConfig.topK =
          state.searchMethod[SearchMethodType.Global].topK
        result.indexConfig.isScore =
          state.searchMethod[SearchMethodType.Global].isScore
        result.indexConfig.score =
          state.searchMethod[SearchMethodType.Global].score
      }
      break
    case SearchMethodType.Mix:
      {
        result.indexConfig.weightRerank =
          state.searchMethod[SearchMethodType.Mix].indexMethod
        result.indexConfig.semantics =
          state.searchMethod[SearchMethodType.Mix].weight
        result.indexConfig.keyword =
          1 - state.searchMethod[SearchMethodType.Mix].weight
        result.indexConfig.rerankTypeId =
          state.searchMethod[SearchMethodType.Mix].rerank
        result.indexConfig.rerankType = optionsRerankMapCpt.value.get(
          state.searchMethod[SearchMethodType.Mix].rerank,
        ).label
        result.indexConfig.topK = state.searchMethod[SearchMethodType.Mix].topK
        result.indexConfig.isScore =
          state.searchMethod[SearchMethodType.Mix].isScore
        result.indexConfig.score =
          state.searchMethod[SearchMethodType.Mix].score
      }
      break
  }
  return result
}
const init = ({ indexingTechnique, embeddingModelId, indexConfig }) => {
  reset()
  state.indexMethod.value = indexingTechnique
  state.embedding.value = embeddingModelId
  state.searchMethod.value = indexConfig.type
  switch (state.searchMethod.value) {
    case SearchMethodType.Vector:
      {
        state.searchMethod[SearchMethodType.Vector].isRerank = Number(
          indexConfig.isRerank,
        )
        state.searchMethod[SearchMethodType.Vector].rerank =
          indexConfig.rerankTypeId
        state.searchMethod[SearchMethodType.Vector].topK = Number(
          indexConfig.topK,
        )
        state.searchMethod[SearchMethodType.Vector].isScore = Number(
          indexConfig.isScore,
        )
        state.searchMethod[SearchMethodType.Vector].score = Number(
          indexConfig.score,
        )
      }
      break
    case SearchMethodType.Global:
      {
        state.searchMethod[SearchMethodType.Global].isRerank = Number(
          indexConfig.isRerank,
        )
        state.searchMethod[SearchMethodType.Global].rerank =
          indexConfig.rerankTypeId
        state.searchMethod[SearchMethodType.Global].topK = Number(
          indexConfig.topK,
        )
        state.searchMethod[SearchMethodType.Global].isScore = Number(
          indexConfig.isScore,
        )
        state.searchMethod[SearchMethodType.Global].score = Number(
          indexConfig.score,
        )
      }
      break
    case SearchMethodType.Mix:
      {
        state.searchMethod[SearchMethodType.Mix].indexMethod =
          indexConfig.weightRerank
        state.searchMethod[SearchMethodType.Mix].weight = Number(
          indexConfig.semantics,
        )
        state.searchMethod[SearchMethodType.Mix].rerank =
          indexConfig.rerankTypeId
        state.searchMethod[SearchMethodType.Mix].topK = Number(indexConfig.topK)
        state.searchMethod[SearchMethodType.Mix].isScore = Number(
          indexConfig.isScore,
        )
        state.searchMethod[SearchMethodType.Mix].score = Number(
          indexConfig.score,
        )
      }
      break
  }
}
onMounted(() => {
  initDictionary()
})
defineExpose({
  reset,
  getData,
  init,
})
const initDictionary = () => {
  pluginGetListByType({ type: 'EMBEDDING' })
    .then(({ data }: any) => {
      state.optionsEmbedding = data.map((v) => {
        v.label = v.name
        v.value = v.id
        return v
      })
    })
    .catch(() => {})
  pluginGetListByType({ type: 'RERANK' })
    .then(({ data }: any) => {
      state.optionsRerank = data.map((v) => {
        v.label = v.name
        v.value = v.id
        return v
      })
    })
    .catch(() => {})
}
</script>

<style lang="scss" scoped>
.index-method-active {
  box-shadow: 0rem 0.25rem 0.63rem 0rem rgba(40, 83, 247, 0.05);
  border-color: var(--czr-main-color) !important;
  background-color: rgba(var(--czr-main-color-rgb), 0.1);
}
.search-method-active {
  box-shadow: 0rem 0.25rem 0.63rem 0rem rgba(40, 83, 247, 0.05);
  border-color: var(--czr-main-color) !important;
  background-color: rgba(var(--czr-main-color-rgb), 0.1);
  background-image: url('@/assets/images/model-icon-7.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
:deep(.re-slider) {
  flex-direction: row-reverse;
  .el-slider__runway {
    margin-left: 10px;
    margin-right: 0;
  }
}
:deep(.weight-slider) {
  .el-slider__runway {
    background-color: var(--czr-success-color);
  }
}
</style>
