package com.pavis.admin.aigc.service.impl;

import cn.hutool.core.util.StrUtil;
import com.pavis.admin.aigc.core.llm.provider.EmbeddingProvider;
import com.pavis.admin.aigc.mapper.DocMapper;
import com.pavis.admin.aigc.model.entity.DocDO;
import com.pavis.admin.aigc.service.KnowledgeService;
import dev.langchain4j.data.segment.TextSegment;
import dev.langchain4j.store.embedding.EmbeddingStore;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import org.springframework.transaction.annotation.Transactional;
import top.continew.starter.extension.crud.service.BaseServiceImpl;
import com.pavis.admin.aigc.mapper.EmbedStoreMapper;
import com.pavis.admin.aigc.model.entity.EmbedStoreDO;
import com.pavis.admin.aigc.model.query.EmbedStoreQuery;
import com.pavis.admin.aigc.model.req.EmbedStoreReq;
import com.pavis.admin.aigc.model.resp.EmbedStoreDetailResp;
import com.pavis.admin.aigc.model.resp.EmbedStoreResp;
import com.pavis.admin.aigc.service.EmbedStoreService;

import java.util.List;

/**
 * 向量存储配置业务实现
 *
 * @author semi
 * @since 2025/05/26 17:28
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class EmbedStoreServiceImpl extends BaseServiceImpl<EmbedStoreMapper, EmbedStoreDO, EmbedStoreResp, EmbedStoreDetailResp, EmbedStoreQuery, EmbedStoreReq> implements EmbedStoreService {


    @Override
    public List<EmbedStoreResp> selEmbedStore() {
        return baseMapper.selEmbedStore();
    }

    // @Override
    // @Transactional
    // public void clearDocSlices(String docsId) {
    //     if (StrUtil.isBlank(docsId)) {
    //         return;
    //     }
    //     // remove from embedding store
    //     List<String> vectorIds = aigcKnowledgeService.listSliceVectorIdsOfDoc(docsId);
    //     if (vectorIds.isEmpty()) {
    //         return;
    //     }
    //     DocDO docs = docMapper.selectById(docsId);
    //     EmbeddingStore<TextSegment> embeddingStore = embeddingProvider.getEmbeddingStore(docs.getKnowledgeId());
    //     embeddingStore.removeAll(vectorIds);
    //     // remove from docSlice
    //     aigcKnowledgeService.removeSlicesOfDoc(docsId);
    // }

}