| | |
| | | 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; |
| | |
| | | private final AiProductRoleService aiProductRoleService; |
| | | private final ObjectMapper objectMapper; |
| | | private final AiTalkItemService aiTalkItemService; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | @Value("${ai.service.ak}") |
| | | private String ak; |
| | |
| | | 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 |
| | |
| | | |
| | | final ChatMessage systemMessage = ChatMessage.builder() |
| | | .role(ChatMessageRole.SYSTEM) |
| | | .content("你是豆包,是由字节跳动开发的 AI 人工智能助手") |
| | | .content("你是豆包,是由字节跳动开发的 AI 人工智能助手,请使用中文回复") |
| | | .build(); |
| | | messages.add(systemMessage); |
| | | |