| | |
| | | import cc.mrbird.febs.ai.res.ai.AiResponse; |
| | | import cc.mrbird.febs.ai.res.ai.RadarDataItem; |
| | | import cc.mrbird.febs.ai.res.ai.Report; |
| | | import cc.mrbird.febs.ai.res.memberTalk.ApiMemberTalkStreamVo; |
| | | import cc.mrbird.febs.ai.res.memberTalk.ApiMemberTalkStreamVoOld; |
| | | import cc.mrbird.febs.ai.service.AiProductRoleService; |
| | | import cc.mrbird.febs.ai.service.AiService; |
| | | import cc.mrbird.febs.ai.service.AiTalkItemService; |
| | |
| | | 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 |
| | |
| | | } |
| | | |
| | | |
| | | ApiMemberTalkStreamVo apiMemberTalkStreamVo = new ApiMemberTalkStreamVo(); |
| | | ApiMemberTalkStreamVoOld apiMemberTalkStreamVoOld = new ApiMemberTalkStreamVoOld(); |
| | | // 判断是否触发深度思考,触发则打印模型输出的思维链内容 |
| | | ChatMessage message = choice.getMessage(); |
| | | if (message.getReasoningContent()!= null &&!message.getReasoningContent().isEmpty()) { |
| | | apiMemberTalkStreamVo.setReasoningContent(message.getReasoningContent()); |
| | | apiMemberTalkStreamVoOld.setReasoningContent(message.getReasoningContent()); |
| | | // System.out.print(message.getReasoningContent()); |
| | | } |
| | | |
| | | String content = message.getContent() == null ? "" : message.getContent().toString(); |
| | | apiMemberTalkStreamVo.setContent(content); |
| | | apiMemberTalkStreamVoOld.setContent(content); |
| | | System.out.print(content); |
| | | return new FebsResponse().success().data(apiMemberTalkStreamVo); |
| | | return new FebsResponse().success().data(apiMemberTalkStreamVoOld); |
| | | }) |
| | | .onErrorResume(throwable -> { |
| | | log.error("流式调用AI服务失败,问题输入: {}", question, throwable); |
| | |
| | | |
| | | final ChatMessage systemMessage = ChatMessage.builder() |
| | | .role(ChatMessageRole.SYSTEM) |
| | | .content("你是豆包,是由字节跳动开发的 AI 人工智能助手") |
| | | .content("你是豆包,是由字节跳动开发的 AI 人工智能助手,请使用中文回复") |
| | | .build(); |
| | | messages.add(systemMessage); |
| | | |
| | |
| | | } |
| | | |
| | | ChatMessage message = choice.getMessage(); |
| | | ApiMemberTalkStreamVo apiMemberTalkStreamVo = new ApiMemberTalkStreamVo(); |
| | | ApiMemberTalkStreamVoOld apiMemberTalkStreamVoOld = new ApiMemberTalkStreamVoOld(); |
| | | |
| | | // 处理 reasoning content |
| | | String reasoningContent = message.getReasoningContent(); |
| | | if (StrUtil.isNotEmpty(reasoningContent)) { |
| | | apiMemberTalkStreamVo.setReasoningContent(reasoningContent); |
| | | apiMemberTalkStreamVoOld.setReasoningContent(reasoningContent); |
| | | log.debug("Reasoning Content: {}", reasoningContent); |
| | | } |
| | | |
| | |
| | | if (message.getContent() != null) { |
| | | content = message.getContent().toString(); |
| | | } |
| | | apiMemberTalkStreamVo.setContent(content); |
| | | apiMemberTalkStreamVoOld.setContent(content); |
| | | System.out.print(content); |
| | | log.debug("Content: {}", content); |
| | | |
| | | return new FebsResponse().success().data(apiMemberTalkStreamVo); |
| | | return new FebsResponse().success().data(apiMemberTalkStreamVoOld); |
| | | }) |
| | | .onErrorResume(throwable -> { |
| | | log.error("流式调用AI服务失败,问题输入: {}", question, throwable); |