Administrator
2 days ago fe70ca5db711b458714bfbe4a6eda6cf7d8a0421
src/main/java/cc/mrbird/febs/ai/service/impl/AiServiceImpl.java
@@ -13,7 +13,10 @@
import cc.mrbird.febs.ai.service.AiProductRoleService;
import cc.mrbird.febs.ai.service.AiService;
import cc.mrbird.febs.ai.service.AiTalkItemService;
import cc.mrbird.febs.ai.strategy.enumerates.LlmStrategyContextEnum;
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.mall.entity.DataDictionaryCustom;
import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
@@ -74,6 +77,7 @@
    private final AiProductRoleService aiProductRoleService;
    private final ObjectMapper objectMapper;
    private final AiTalkItemService aiTalkItemService;
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
    @Value("${ai.service.ak}")
    private String ak;
@@ -109,6 +113,32 @@
        if (service != null) {
            service.shutdownExecutor();
        }
    }
    @Override
    public Integer getSystemSetAiType() {
        Integer type = 2;
        DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                LlmStrategyContextEnum.LLM_STRATEGY.getCode(),
                LlmStrategyContextEnum.LLM_STRATEGY.getCode()
        );
        if (dataDictionaryCustom != null) {
            type = Integer.parseInt(dataDictionaryCustom.getValue());
        }
        return type;
    }
    @Override
    public String getSystemSetLTAiPrompt() {
        String prompt = "请将问题转换为中文,并给出一个最详细的答案。";
        DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                LlmStrategyContextEnum.LLM_LING_TONG_PROMPT.getCode(),
                LlmStrategyContextEnum.LLM_LING_TONG_PROMPT.getCode()
        );
        if (dataDictionaryCustom != null) {
            prompt = dataDictionaryCustom.getValue();
        }
        return prompt;
    }
    @Override
@@ -437,7 +467,7 @@
        final ChatMessage systemMessage = ChatMessage.builder()
                .role(ChatMessageRole.SYSTEM)
                .content("你是豆包,是由字节跳动开发的 AI 人工智能助手")
                .content("你是豆包,是由字节跳动开发的 AI 人工智能助手,请使用中文回复")
                .build();
        messages.add(systemMessage);