|
|
@@ -8,6 +8,7 @@ import com.takai.ai.domain.TakaiSysOss;
|
|
|
import com.takai.ai.domain.dto.*;
|
|
|
import com.takai.ai.domain.entity.*;
|
|
|
import com.takai.ai.mapper.*;
|
|
|
+import com.takai.ai.service.IMinioConfigService;
|
|
|
import com.takai.ai.service.ITakaiAiService;
|
|
|
import com.takai.ai.utils.*;
|
|
|
import com.takai.common.annotation.DataSource;
|
|
|
@@ -129,6 +130,9 @@ public class TakaiAiServiceImpl implements ITakaiAiService {
|
|
|
@Autowired
|
|
|
private TakaiFileInfoMapper fileInfoMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private Base64DecodeUtil base64DecodeUtil;
|
|
|
+
|
|
|
public static final String START_SIGN = "【";
|
|
|
public static final String END_SIGN = "】";
|
|
|
public static final String SYMBOL = "【示意图序号";
|
|
|
@@ -138,6 +142,9 @@ public class TakaiAiServiceImpl implements ITakaiAiService {
|
|
|
public static final String TODAY = "今日";
|
|
|
|
|
|
public static final String BEFOR = "日前";
|
|
|
+
|
|
|
+ private final String OSS_URL= "https://minio.jkec.info:9000";
|
|
|
+
|
|
|
@Autowired
|
|
|
private SysProjectMapper sysProjectMapper;
|
|
|
|
|
|
@@ -198,6 +205,8 @@ public class TakaiAiServiceImpl implements ITakaiAiService {
|
|
|
//重新设置knowledgeIds为数组
|
|
|
json.put("knowledgeIds",idList);
|
|
|
String query = null;
|
|
|
+ decodeMessage(sseParams.getMessages());
|
|
|
+ decodeMessage(sseParams.getPrompt());
|
|
|
if(sseParams.getMessages() != null && !sseParams.getMessages().isEmpty() ) {
|
|
|
query = sseParams.getMessages().get(sseParams.getMessages().size() - 1).getContent();
|
|
|
} else {
|
|
|
@@ -255,7 +264,8 @@ public class TakaiAiServiceImpl implements ITakaiAiService {
|
|
|
String url = redisCache.getCacheObject(key);
|
|
|
if (org.springframework.util.StringUtils.hasText(url)) {
|
|
|
if(url.contains("https://10.1.28.14:9000")){
|
|
|
- url = url.replace("https://10.1.28.14:9000", "https://minio.jkec.info:9000");
|
|
|
+ //url = url.replace("https://10.1.28.14:9000", "https://minio.jkec.info:9000");
|
|
|
+ url = url.replace("https://10.1.28.14:9000", OSS_URL);
|
|
|
}
|
|
|
//匹配markdown图片格式
|
|
|
// symbolData = symbolData.replace(key, "");
|
|
|
@@ -273,7 +283,9 @@ public class TakaiAiServiceImpl implements ITakaiAiService {
|
|
|
newData = symbolData;
|
|
|
symbolData = "";
|
|
|
}
|
|
|
- newData = newData.replace(key, " ");
|
|
|
+ if(!StringUtils.isEmpty(url)) {
|
|
|
+ newData = newData.replace(key, " ");
|
|
|
+ }
|
|
|
} else {
|
|
|
newData = symbolData;
|
|
|
symbolData = "";
|
|
|
@@ -361,6 +373,15 @@ public class TakaiAiServiceImpl implements ITakaiAiService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ private void decodeMessage(List<TakaiPromptInfo> messages) {
|
|
|
+ if(messages == null || messages.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (TakaiPromptInfo message : messages) {
|
|
|
+ message.setContent(base64DecodeUtil.decodeIfNeeded(message.getContent()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<String> asyncCompletions(TakaiCompletionsParams params) {
|
|
|
List<String> list = new ArrayList<>();
|
|
|
@@ -369,6 +390,7 @@ public class TakaiAiServiceImpl implements ITakaiAiService {
|
|
|
TakaiPromptInfo info = new TakaiPromptInfo();
|
|
|
info.setContent(deepseekConfig.getPrompt());
|
|
|
info.setRole("user");
|
|
|
+ decodeMessage(params.getMessages());
|
|
|
params.getMessages().add(info);
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
@@ -378,7 +400,9 @@ public class TakaiAiServiceImpl implements ITakaiAiService {
|
|
|
JSONObject result = getasyncCompletions(jsonObject);
|
|
|
if (result != null && result.getInteger("code") == 200) {
|
|
|
JSONArray array = result.getJSONArray("data");
|
|
|
- list.addAll(array.toJavaList(String.class));
|
|
|
+ if(array != null){
|
|
|
+ list.addAll(array.toJavaList(String.class));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return list;
|
|
|
@@ -446,6 +470,7 @@ public class TakaiAiServiceImpl implements ITakaiAiService {
|
|
|
|
|
|
for (TakaiDialogDetailReqDTO dto : dialogReqDTO.getMessages()) {
|
|
|
dto.setDialogId(dialogId);
|
|
|
+ dto.setContent(base64DecodeUtil.decodeIfNeeded(dto.getContent()));
|
|
|
TakaiDialogRespDTO detail = takaiDialogMapper.selectDialogDetailById(dto.getId());
|
|
|
if (detail == null) {
|
|
|
if (dto.getSliceInfo() != null) dto.setSliceJson(JSON.toJSONString(dto.getSliceInfo()));
|
|
|
@@ -761,12 +786,34 @@ public class TakaiAiServiceImpl implements ITakaiAiService {
|
|
|
|
|
|
@Override
|
|
|
public List<TakaiDocument> documentList(TakaiDocumentParams documentParams) {
|
|
|
- return takaiDocumentMapper.selectDocumentList(TakaiDocument.builder().knowledgeId(documentParams.getKnowledge_id()).build());
|
|
|
+ List<TakaiDocument> documentList = takaiDocumentMapper.selectDocumentList(TakaiDocument.builder().knowledgeId(documentParams.getKnowledge_id()).build());
|
|
|
+ replaceOssUrl(documentList);
|
|
|
+ return documentList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void replaceOssUrl(List<TakaiDocument> documentList) {
|
|
|
+ if(documentList == null || documentList.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for(TakaiDocument document : documentList) {
|
|
|
+ replaceDocUrl(document);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void replaceDocUrl(TakaiDocument document) {
|
|
|
+ if(document == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String url = document.getUrl();
|
|
|
+ url = url.replace("https://10.1.28.14:9000", OSS_URL);
|
|
|
+ document.setUrl(url);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public TakaiDocument documentDetail(String documentId) {
|
|
|
- return takaiDocumentMapper.selectTargetDocument(TakaiDocument.builder().documentId(documentId).build());
|
|
|
+ TakaiDocument doc = takaiDocumentMapper.selectTargetDocument(TakaiDocument.builder().documentId(documentId).build());
|
|
|
+ replaceDocUrl(doc);
|
|
|
+ return doc;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -845,6 +892,7 @@ public class TakaiAiServiceImpl implements ITakaiAiService {
|
|
|
.typeId(params.getTypeId())
|
|
|
.visible(params.getVisible())
|
|
|
.isDeepThink(params.getIsDeepThink())
|
|
|
+ .sort(params.getSort())
|
|
|
.build();
|
|
|
//关联项目
|
|
|
if(params.getAppProId() != null){
|
|
|
@@ -926,6 +974,7 @@ public class TakaiAiServiceImpl implements ITakaiAiService {
|
|
|
.typeId(params.getTypeId())
|
|
|
.isDeepThink(params.getIsDeepThink())
|
|
|
.visible(params.getVisible())
|
|
|
+ .sort(params.getSort())
|
|
|
.build();
|
|
|
//关联项目
|
|
|
if(params.getAppProId() != null){
|