|
|
@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.hnac.hzims.bigmodel.business.dto.RunReportAnalyseRequest; |
|
|
|
import com.hnac.hzims.bigmodel.business.dto.RunReportAnalyseRequest; |
|
|
|
import com.hnac.hzims.bigmodel.business.feign.IAuthClient; |
|
|
|
import com.hnac.hzims.bigmodel.business.feign.IAuthClient; |
|
|
|
import com.hnac.hzims.bigmodel.business.dto.RunReportDataAnalyseDTO; |
|
|
|
|
|
|
|
import com.hnac.hzims.bigmodel.configuration.BigModelInvokeApi; |
|
|
|
import com.hnac.hzims.bigmodel.configuration.BigModelInvokeApi; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
|
|
@ -21,6 +20,7 @@ import com.hnac.hzinfo.exception.HzServiceException; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
|
|
|
import org.springblade.core.tool.jackson.JsonUtil; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
@ -29,6 +29,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.UUID; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -55,6 +56,7 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { |
|
|
|
params.put("chat_id", sessionId); |
|
|
|
params.put("chat_id", sessionId); |
|
|
|
params.put("user_id", userId); |
|
|
|
params.put("user_id", userId); |
|
|
|
params.put("query", question); |
|
|
|
params.put("query", question); |
|
|
|
|
|
|
|
params.put("q_id", UUID.randomUUID()); |
|
|
|
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); |
|
|
|
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); |
|
|
|
params.putAll(authDataIds); |
|
|
|
params.putAll(authDataIds); |
|
|
|
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), params); |
|
|
|
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), params); |
|
|
@ -73,6 +75,7 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { |
|
|
|
params.put("chat_id", sessionId); |
|
|
|
params.put("chat_id", sessionId); |
|
|
|
params.put("user_id", userId); |
|
|
|
params.put("user_id", userId); |
|
|
|
params.put("extra", extra); |
|
|
|
params.put("extra", extra); |
|
|
|
|
|
|
|
params.put("q_id", UUID.randomUUID()); |
|
|
|
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); |
|
|
|
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); |
|
|
|
params.putAll(authDataIds); |
|
|
|
params.putAll(authDataIds); |
|
|
|
log.info("调用大模型接口:{},传参为:{}", gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(params)); |
|
|
|
log.info("调用大模型接口:{},传参为:{}", gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(params)); |
|
|
@ -82,7 +85,9 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void specialAsk(QuestionDTO question) { |
|
|
|
public void specialAsk(QuestionDTO question) { |
|
|
|
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(question)); |
|
|
|
Map<String, Object> questionMap = JsonUtil.toMap(JSON.toJSONString(question)); |
|
|
|
|
|
|
|
questionMap.put("q_id", UUID.randomUUID()); |
|
|
|
|
|
|
|
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(questionMap)); |
|
|
|
sessionRedisManager.addSessionId(question.getChatId()); |
|
|
|
sessionRedisManager.addSessionId(question.getChatId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -93,6 +98,7 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { |
|
|
|
params.put("user_id", userId); |
|
|
|
params.put("user_id", userId); |
|
|
|
params.put("query", question); |
|
|
|
params.put("query", question); |
|
|
|
params.put("knowledge", knowledge); |
|
|
|
params.put("knowledge", knowledge); |
|
|
|
|
|
|
|
params.put("q_id", UUID.randomUUID()); |
|
|
|
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); |
|
|
|
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); |
|
|
|
params.putAll(authDataIds); |
|
|
|
params.putAll(authDataIds); |
|
|
|
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), params); |
|
|
|
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), params); |
|
|
@ -101,13 +107,17 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void knowledgeAsk(QuestionDTO question) { |
|
|
|
public void knowledgeAsk(QuestionDTO question) { |
|
|
|
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), JSON.toJSONString(question)); |
|
|
|
Map<String, Object> questionMap = JsonUtil.toMap(JSON.toJSONString(question)); |
|
|
|
|
|
|
|
questionMap.put("q_id", UUID.randomUUID()); |
|
|
|
|
|
|
|
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), JSON.toJSONString(questionMap)); |
|
|
|
sessionRedisManager.addSessionId(question.getChatId()); |
|
|
|
sessionRedisManager.addSessionId(question.getChatId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void analyseAsk(QuestionDTO question) { |
|
|
|
public void analyseAsk(QuestionDTO question) { |
|
|
|
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAnalyseAsk(), JSON.toJSONString(question)); |
|
|
|
Map<String, Object> questionMap = JsonUtil.toMap(JSON.toJSONString(question)); |
|
|
|
|
|
|
|
questionMap.put("q_id", UUID.randomUUID()); |
|
|
|
|
|
|
|
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAnalyseAsk(), JSON.toJSONString(questionMap)); |
|
|
|
sessionRedisManager.addSessionId(question.getChatId()); |
|
|
|
sessionRedisManager.addSessionId(question.getChatId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -182,9 +192,9 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List hotQuestions() { |
|
|
|
public List hotQuestions() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getHotQuestion(), null, new TypeReference<List<String>>(){}); |
|
|
|
return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getHotQuestion(), null, new TypeReference<List<String>>() { |
|
|
|
} |
|
|
|
}); |
|
|
|
catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("An error occurred", e); |
|
|
|
log.error("An error occurred", e); |
|
|
|
return Lists.newArrayList(); |
|
|
|
return Lists.newArrayList(); |
|
|
|
} |
|
|
|
} |
|
|
@ -194,7 +204,8 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { |
|
|
|
public List<AnswerVO> getAnswerBySessionIds(String sessionIds) { |
|
|
|
public List<AnswerVO> getAnswerBySessionIds(String sessionIds) { |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("chat_ids", Func.toStrList(",", sessionIds).toArray()); |
|
|
|
params.put("chat_ids", Func.toStrList(",", sessionIds).toArray()); |
|
|
|
return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantStatus(), params, new TypeReference<List<AnswerVO>>(){}); |
|
|
|
return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantStatus(), params, new TypeReference<List<AnswerVO>>() { |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Map<String, String[]> getAuthDataIds(String userId) { |
|
|
|
private Map<String, String[]> getAuthDataIds(String userId) { |
|
|
|