|
|
@@ -112,8 +112,19 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
SseEmitter sseEmitter = new SseEmitter(0L);
|
|
|
String url = bigModelConfig.getBaseurl() + bigModelConfig.getSse().replace("{id}",sseParams.getAppId());
|
|
|
JSONObject json = new JSONObject();
|
|
|
+ List<PromptObject> list = sseParams.getPrompt();
|
|
|
+ for (PromptObject vo : list){
|
|
|
+ String str = vo.getContent();
|
|
|
+ int index = str.indexOf(DATA_STR);
|
|
|
+ if( index != -1){
|
|
|
+ String result = str.substring(0, index);
|
|
|
+ log.info("-----"+result+"----");
|
|
|
+ vo.setContent(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
json.put("prompt",sseParams.getPrompt());
|
|
|
json.put("knowledge_ids",sseParams.getKnowledge_ids());
|
|
|
+ log.info("++++++++++++"+sseParams.getPrompt()+"+++++++++++");
|
|
|
RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8") , json.toJSONString());
|
|
|
|
|
|
Request request = buildPostRequest(url,requestBody);
|
|
|
@@ -437,29 +448,31 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
.model(json.getString("model"))
|
|
|
.iconColor(json.getString("icon_color"))
|
|
|
.iconType(json.getString("icon_type"))
|
|
|
- .paramDesc(json.getString("param_desc"))
|
|
|
- .maxToken(json.getInteger("max_token"))
|
|
|
.build();
|
|
|
applicationList.add(bmApplication);
|
|
|
}
|
|
|
}else{
|
|
|
// 默认一个
|
|
|
- String uuid = IdUtils.simpleUUID();
|
|
|
- BmApplication bmApplication = BmApplication.builder()
|
|
|
- .appId(uuid)
|
|
|
- .name("default")
|
|
|
- .desc("default")
|
|
|
- .prompt("frist")
|
|
|
- .topP("0.1")
|
|
|
- .temperature("0.05")
|
|
|
- .knowledgeIds("["+uuid+"]")
|
|
|
- .sliceCount(4)
|
|
|
- .model(MODEL)
|
|
|
- .iconColor("blue")
|
|
|
- .iconType("robot_assist")
|
|
|
- .build();
|
|
|
- bmApplicationMapper.insertApplication(bmApplication);
|
|
|
- applicationList.add(bmApplication);
|
|
|
+ BmApplication params = BmApplication.builder().appId("1801951241421525588").build();
|
|
|
+ List<BmApplication> list = bmApplicationMapper.selectApplicationList(params);
|
|
|
+ if(list.size() == 0){
|
|
|
+// String uuid = IdUtils.simpleUUID();
|
|
|
+ BmApplication bmApplication = BmApplication.builder()
|
|
|
+ .appId("1801951241421525588")
|
|
|
+ .name("default")
|
|
|
+ .desc("default")
|
|
|
+ .prompt("frist")
|
|
|
+ .topP("0.1")
|
|
|
+ .temperature("0.05")
|
|
|
+ .knowledgeIds("[]")
|
|
|
+ .sliceCount(4)
|
|
|
+ .model(MODEL)
|
|
|
+ .iconColor("blue")
|
|
|
+ .iconType("robot_assist")
|
|
|
+ .build();
|
|
|
+ bmApplicationMapper.insertApplication(bmApplication);
|
|
|
+ applicationList.add(bmApplication);
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
log.error("智谱 获取应用列表失败:", response);
|
|
|
@@ -473,6 +486,7 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
@Override
|
|
|
public List<BmKnowledge> getKnowledgeList() {
|
|
|
String url = bigModelConfig.getBaseurl() + bigModelConfig.getKnowledge();
|
|
|
+
|
|
|
Request request = buildGetRequest(url);
|
|
|
OkHttpClient client = buildOkHttpClient();
|
|
|
List<BmKnowledge> knowledgeList = new ArrayList<>();
|
|
|
@@ -559,10 +573,10 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
}
|
|
|
|
|
|
if(id == null){
|
|
|
- String uuid = IdUtils.fastSimpleUUID();
|
|
|
- dialogReqDTO.setId(uuid);
|
|
|
+ //String uuid = IdUtils.fastSimpleUUID();
|
|
|
+ //dialogReqDTO.setId(uuid);
|
|
|
dialogMapper.insertDialog(dialogReqDTO);
|
|
|
- dialogId = uuid;
|
|
|
+ dialogId = dialogReqDTO.getId();
|
|
|
}else{
|
|
|
dialogId = dialogReqDTO.getId();
|
|
|
}
|
|
|
@@ -571,8 +585,8 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
dto.setDialogId(dialogId);
|
|
|
String detailId = dialogMapper.selectDialogDetailById(dto.getId());
|
|
|
if(detailId == null) {
|
|
|
- String detailUuid = IdUtils.fastSimpleUUID();
|
|
|
- dto.setId(detailUuid);
|
|
|
+ //String detailUuid = IdUtils.fastSimpleUUID();
|
|
|
+ //dto.setId(dto.getId());
|
|
|
dialogMapper.insertDialogDetail(dto);
|
|
|
}
|
|
|
}
|
|
|
@@ -591,7 +605,7 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
// 对比两个时间相差多少天
|
|
|
long daysBetween = ChronoUnit.DAYS.between(today, entry.getKey());
|
|
|
Map<String, Object> m = new HashMap();
|
|
|
- m.put("key", System.currentTimeMillis());
|
|
|
+ m.put("key", System.nanoTime());
|
|
|
m.put("type", "group");
|
|
|
if(daysBetween == 0l){
|
|
|
m.put("label", TODAY);
|
|
|
@@ -786,6 +800,7 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
resultList.addAll(listFromArray);
|
|
|
}
|
|
|
}
|
|
|
+ break;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
@@ -1100,7 +1115,7 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject uploadDocument(MultipartFile[] file, DocumentParams documentParams, String knowledgeId) {
|
|
|
+ public JSONObject uploadDocument(MultipartFile[] file, String knowledgeId) {
|
|
|
String url = bigModelConfig.getBaseurl() + bigModelConfig.getDocument() + "/upload_document/" + knowledgeId;
|
|
|
|
|
|
MultipartBody.Builder builder = new MultipartBody.Builder().setType(MultipartBody.FORM);
|
|
|
@@ -1194,7 +1209,7 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
.documentId(documentId)
|
|
|
.sentenceSize(String.valueOf(documentParams.getSentence_size()))
|
|
|
.knowledgeType(documentParams.getKnowledge_type())
|
|
|
- .wordNum(documentParams.getWord_num_limit() == null ? null : Integer.valueOf(documentParams.getWord_num_limit()))
|
|
|
+ .customSeparator(String.valueOf(documentParams.getCustom_separator()))
|
|
|
.build();
|
|
|
bmDocumentMapper.updateDocument(bm);
|
|
|
}
|
|
|
@@ -1208,26 +1223,39 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONArray documentList(DocumentParams documentParams) {
|
|
|
- String url = bigModelConfig.getBaseurl() + bigModelConfig.getDocument();
|
|
|
- if(com.takai.common.utils.StringUtils.isNotEmpty(documentParams.getKnowledge_id())){
|
|
|
- url += "?knowledge_id=" + documentParams.getKnowledge_id();
|
|
|
- }
|
|
|
- if (documentParams.getPage() >= 1) {
|
|
|
- url += "&page=" + documentParams.getPage();
|
|
|
- }
|
|
|
- if (documentParams.getSize() >= 10) {
|
|
|
- url += "&size=" + documentParams.getSize();
|
|
|
- }
|
|
|
+ public JSONObject documentList(DocumentParams documentParams) {
|
|
|
+ String url = bigModelConfig.getBaseurl() + bigModelConfig.getDocument() + "?knowledge_id=" + documentParams.getKnowledge_id()
|
|
|
+ + "&page=" + documentParams.getPage() +"&size=" + documentParams.getSize();
|
|
|
Request request = buildGetRequest(url);
|
|
|
OkHttpClient client = buildOkHttpClient();
|
|
|
try {
|
|
|
Response response = client.newCall(request).execute();
|
|
|
if(response.isSuccessful()){
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
JSONObject obj = JSON.parseObject(response.body().string());
|
|
|
- JSONObject dataObj = obj.getJSONObject("data");
|
|
|
- JSONArray array = dataObj.getJSONArray("list");
|
|
|
- return array;
|
|
|
+ if("200".equals(String.valueOf(obj.get("code")))){
|
|
|
+ JSONObject dataObj = obj.getJSONObject("data");
|
|
|
+ Integer total = dataObj.getInteger("total");
|
|
|
+ JSONArray array = dataObj.getJSONArray("list");
|
|
|
+ BmDocument param = BmDocument.builder().knowledgeId(documentParams.getKnowledge_id()).build();
|
|
|
+ List<BmDocument> list = bmDocumentMapper.selectDocumentList(param);
|
|
|
+ if(array != null && array.size() > 0){
|
|
|
+ for(int i=0; i<array.size(); i++){
|
|
|
+ JSONObject resultObj = array.getJSONObject(i);
|
|
|
+ for (BmDocument vo: list){
|
|
|
+ if(resultObj.getString("id").equals(vo.getDocumentId())){
|
|
|
+ resultObj.put("create_time", vo.getCreateTime());
|
|
|
+ resultObj.put("create_by", vo.getCreateBy());
|
|
|
+ resultObj.put("update_time", vo.getUpdateTime());
|
|
|
+ resultObj.put("update_by", vo.getUpdateBy());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ jsonObject.put("total", total);
|
|
|
+ jsonObject.put("list", array);
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
log.info("获取知识列表失败", e);
|
|
|
@@ -1388,7 +1416,31 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
|
|
|
@Override
|
|
|
public JSONObject createApplication(ApplicationParams params) {
|
|
|
+ //默认参数
|
|
|
+ params.setIcon_color("blue");
|
|
|
+ params.setIcon_type("robot_assist");
|
|
|
String url = bigModelConfig.getBaseurl() + bigModelConfig.getApplication();
|
|
|
+ if(params != null && Objects.nonNull(params.getKnowledge_info().getRerank_status()) && params.getKnowledge_info().getRerank_status() == 1){
|
|
|
+ List<IndexType> reankList = new ArrayList();
|
|
|
+ for(int i=0; i<params.getKnowledge_ids().size(); i++){
|
|
|
+ IndexType type = new IndexType();
|
|
|
+ type.setIndex_type_id(i);
|
|
|
+ type.setKnowledge_id(params.getKnowledge_ids().get(i));
|
|
|
+ reankList.add(type);
|
|
|
+ }
|
|
|
+ params.getKnowledge_info().setRerank_index_type_list(reankList);
|
|
|
+ }
|
|
|
+ if(params != null && Objects.nonNull(params.getKnowledge_info().getRecall_method()) &&
|
|
|
+ ("embedding".equals(params.getKnowledge_info().getRecall_method()) || "mixed".equals(params.getKnowledge_info().getRecall_method()))){
|
|
|
+ List<IndexType> recallList = new ArrayList();
|
|
|
+ for(int i=0; i<params.getKnowledge_ids().size(); i++){
|
|
|
+ IndexType type = new IndexType();
|
|
|
+ type.setIndex_type_id(i);
|
|
|
+ type.setKnowledge_id(params.getKnowledge_ids().get(i));
|
|
|
+ recallList.add(type);
|
|
|
+ }
|
|
|
+ params.getKnowledge_info().setRecall_index_type_list(recallList);
|
|
|
+ }
|
|
|
JSONObject jsonObject = JSONObject.from(params);
|
|
|
RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8") , jsonObject.toJSONString());
|
|
|
Request request = buildPostRequest(url, requestBody);
|
|
|
@@ -1426,6 +1478,27 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
@Override
|
|
|
public JSONObject updateApplication(ApplicationParams params, String appId) {
|
|
|
String url = bigModelConfig.getBaseurl() + bigModelConfig.getApplication() + "/" + appId;
|
|
|
+ if(params != null && Objects.nonNull(params.getKnowledge_info().getRerank_status()) && params.getKnowledge_info().getRerank_status() == 1){
|
|
|
+ List<IndexType> reankList = new ArrayList();
|
|
|
+ for(int i=0; i<params.getKnowledge_ids().size(); i++){
|
|
|
+ IndexType type = new IndexType();
|
|
|
+ type.setIndex_type_id(i);
|
|
|
+ type.setKnowledge_id(params.getKnowledge_ids().get(i));
|
|
|
+ reankList.add(type);
|
|
|
+ }
|
|
|
+ params.getKnowledge_info().setRerank_index_type_list(reankList);
|
|
|
+ }
|
|
|
+ if(params != null && Objects.nonNull(params.getKnowledge_info().getRecall_method()) &&
|
|
|
+ ("embedding".equals(params.getKnowledge_info().getRecall_method()) || "mixed".equals(params.getKnowledge_info().getRecall_method()))){
|
|
|
+ List<IndexType> recallList = new ArrayList();
|
|
|
+ for(int i=0; i<params.getKnowledge_ids().size(); i++){
|
|
|
+ IndexType type = new IndexType();
|
|
|
+ type.setIndex_type_id(i);
|
|
|
+ type.setKnowledge_id(params.getKnowledge_ids().get(i));
|
|
|
+ recallList.add(type);
|
|
|
+ }
|
|
|
+ params.getKnowledge_info().setRecall_index_type_list(recallList);
|
|
|
+ }
|
|
|
JSONObject json = JSONObject.from(params);
|
|
|
RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8") , json.toJSONString());
|
|
|
Request request = buildPutRequest(url, requestBody);
|
|
|
@@ -1441,24 +1514,29 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
//调用列表接口将应用数据写入数据库
|
|
|
getValidAppList();
|
|
|
//预设问题写入数据库
|
|
|
+ questionMapper.delQuestionByAppId(appId);
|
|
|
List<QuestionInfo> list = params.getQuestionList();
|
|
|
if(!list.isEmpty() && list.size() > 0){
|
|
|
for(QuestionInfo vo : list){
|
|
|
+ // 新增预设问题
|
|
|
+ String uuid = IdUtils.simpleUUID();
|
|
|
+ Question question = Question.builder().id(uuid).question(vo.getQuestion()).appId(appId).build();
|
|
|
+ questionMapper.insertQuestion(question);
|
|
|
//删除预设问题
|
|
|
- if(com.takai.common.utils.StringUtils.isNotEmpty(vo.getDelFlag()) && "1".equals(vo.getDelFlag())){
|
|
|
- questionMapper.delQuestion(vo.getId());
|
|
|
- }else{
|
|
|
- if(com.takai.common.utils.StringUtils.isNotEmpty(vo.getId())){
|
|
|
- // 更新预设问题
|
|
|
- Question question = Question.builder().question(vo.getQuestion()).build();
|
|
|
- questionMapper.updateQuestion(question);
|
|
|
- }else{
|
|
|
- // 新增预设问题
|
|
|
- String uuid = IdUtils.simpleUUID();
|
|
|
- Question question = Question.builder().id(uuid).question(vo.getQuestion()).appId(appId).build();
|
|
|
- questionMapper.insertQuestion(question);
|
|
|
- }
|
|
|
- }
|
|
|
+// if(com.takai.common.utils.StringUtils.isNotEmpty(vo.getDelFlag()) && "1".equals(vo.getDelFlag())){
|
|
|
+// questionMapper.delQuestion(vo.getId());
|
|
|
+// }else{
|
|
|
+// if(com.takai.common.utils.StringUtils.isNotEmpty(vo.getId())){
|
|
|
+// // 更新预设问题
|
|
|
+// Question question = Question.builder().question(vo.getQuestion()).build();
|
|
|
+// questionMapper.updateQuestion(question);
|
|
|
+// }else{
|
|
|
+// // 新增预设问题
|
|
|
+// String uuid = IdUtils.simpleUUID();
|
|
|
+// Question question = Question.builder().id(uuid).question(vo.getQuestion()).appId(appId).build();
|
|
|
+// questionMapper.insertQuestion(question);
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1487,7 +1565,37 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
String result = response.body().string();
|
|
|
JSONObject object = JSON.parseObject(result);
|
|
|
if(object != null){
|
|
|
- return object.getJSONObject("data");
|
|
|
+ JSONObject obj = object.getJSONObject("data");
|
|
|
+ JSONArray array = obj.getJSONArray("list");
|
|
|
+ if(array != null && array.size() > 0){
|
|
|
+ List<ResultApplication> applicationList = new ArrayList();
|
|
|
+ for(int i=0; i<array.size(); i++){
|
|
|
+ BmApplication params = BmApplication.builder().appId(array.getJSONObject(i).getString("id")).build();
|
|
|
+ BmApplication vo = bmApplicationMapper.selectTargetApplication(params);
|
|
|
+ JSONObject json = array.getJSONObject(i);
|
|
|
+ ResultApplication bkApplication = new ResultApplication();
|
|
|
+ bkApplication.setAppId(json.getString("id"));
|
|
|
+ bkApplication.setName(json.getString("name"));
|
|
|
+ bkApplication.setModel(json.getString("model"));
|
|
|
+ bkApplication.setDesc(json.getString("desc"));
|
|
|
+ bkApplication.setPrompt(json.getString("prompt"));
|
|
|
+ bkApplication.setTopP(json.getString("top_p"));
|
|
|
+ bkApplication.setTemperature(String.valueOf(json.getInteger("temperature")));
|
|
|
+ bkApplication.setKnowledgeIds(json.getString("Knowledge_ids"));
|
|
|
+ bkApplication.setSliceCount(json.getInteger("slice_count"));
|
|
|
+ bkApplication.setIconColor(json.getString("icon_color"));
|
|
|
+ bkApplication.setIconType(json.getString("icon_type"));
|
|
|
+ bkApplication.setCreateBy(vo == null ? null : vo.getCreateBy());
|
|
|
+ bkApplication.setCreateTime(vo == null ? null : vo.getCreateTime());
|
|
|
+ bkApplication.setUpdateBy(vo == null ? null : vo.getUpdateBy());
|
|
|
+ bkApplication.setUpdateTime(vo == null ? null : vo.getUpdateTime());
|
|
|
+ applicationList.add(bkApplication);
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("list", applicationList);
|
|
|
+ jsonObject.put("total", obj.get("total"));
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
@@ -1498,7 +1606,7 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
|
|
|
@Override
|
|
|
public JSONObject selectApplication(String appId) {
|
|
|
- String url = bigModelConfig.getBaseurl() + bigModelConfig.getApplication() + "/" + appId;
|
|
|
+ String url = "https://open.bigmodel.cn/api/llm-application" + bigModelConfig.getApplication() + "/" + appId;
|
|
|
Request request = buildGetRequest(url);
|
|
|
OkHttpClient client = buildOkHttpClient();
|
|
|
try {
|
|
|
@@ -1510,8 +1618,12 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
String code = String.valueOf(object.get("code"));
|
|
|
if("200".equals(code)){
|
|
|
JSONObject obj = new JSONObject();
|
|
|
- List<Question> list = questionMapper.getQuestionList(appId);
|
|
|
- obj.put("detail", object.getJSONObject("data"));
|
|
|
+// BmApplication params = BmApplication.builder().appId(appId).build();
|
|
|
+// BmApplication vo = bmApplicationMapper.selectTargetApplication(params);
|
|
|
+ List<QuestionDTO> list = questionMapper.getQuestionList(appId);
|
|
|
+ JSONObject json = object.getJSONObject("data");
|
|
|
+// json.put("max_token", vo.getMaxToken());
|
|
|
+ obj.put("detail", json);
|
|
|
obj.put("questionlist", list);
|
|
|
return obj;
|
|
|
}
|
|
|
@@ -1547,6 +1659,110 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<QuestionDTO> selectQuestionByAppId(String appId) {
|
|
|
+ List<QuestionDTO> List= questionMapper.getQuestionList(appId);
|
|
|
+ return List;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> queryKnowledgeList(Integer page, Integer size) {
|
|
|
+ String url = bigModelConfig.getBaseurl() + bigModelConfig.getKnowledge() + "?page=" + page + "&size=" + size;
|
|
|
+ Request request = buildGetRequest(url);
|
|
|
+ OkHttpClient client = buildOkHttpClient();
|
|
|
+ try {
|
|
|
+ Response response = client.newCall(request).execute();
|
|
|
+ if(response.isSuccessful()) {
|
|
|
+ String body = response.body().string();
|
|
|
+ log.info("分页查询知识库返回:" + body);
|
|
|
+ JSONObject jsonObj = JSON.parseObject(body);
|
|
|
+ JSONObject obj = jsonObj.getJSONObject("data");
|
|
|
+ Integer total = obj.getInteger("total");
|
|
|
+ JSONArray array = obj.getJSONArray("list");
|
|
|
+ List<ResultKnowledge> knowledgeList = new ArrayList();
|
|
|
+ if(array != null && array.size() > 0){
|
|
|
+ for(int i=0; i<array.size(); i++){
|
|
|
+ BmKnowledge params = BmKnowledge.builder().knowledgeId(array.getJSONObject(i).getString("id")).build();
|
|
|
+ BmKnowledge vo = bmKnowledgeMapper.selectTargetKnowledge(params);
|
|
|
+ JSONObject json = array.getJSONObject(i);
|
|
|
+ ResultKnowledge bmKnowledge = new ResultKnowledge();
|
|
|
+ bmKnowledge.setKnowledgeId(json.getString("id"));
|
|
|
+ bmKnowledge.setName(json.getString("name"));
|
|
|
+ bmKnowledge.setDescription(json.getString("description"));
|
|
|
+ bmKnowledge.setIcon(json.getString("icon"));
|
|
|
+ bmKnowledge.setBackground(json.getString("background"));
|
|
|
+ bmKnowledge.setEmbeddingId(json.getInteger("embedding_id"));
|
|
|
+ bmKnowledge.setWordNum(json.getInteger("word_num"));
|
|
|
+ bmKnowledge.setLength(json.getInteger("length"));
|
|
|
+ bmKnowledge.setDocumentSize(json.getInteger("document_size"));
|
|
|
+ bmKnowledge.setCreateBy(vo == null ? null : vo.getCreateBy());
|
|
|
+ bmKnowledge.setCreateTime(vo == null ? null : vo.getCreateTime());
|
|
|
+ bmKnowledge.setUpdateBy(vo == null ? null : vo.getUpdateBy());
|
|
|
+ bmKnowledge.setUpdateTime(vo == null ? null : vo.getUpdateTime());
|
|
|
+ knowledgeList.add(bmKnowledge);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, Object> map = new HashMap();
|
|
|
+ map.put("list", knowledgeList);
|
|
|
+ map.put("total", total);
|
|
|
+ return map;
|
|
|
+ } else {
|
|
|
+ log.error("智谱 获取分页知识库失败:" , response);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("智谱 获取分页知识库失败:", e);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getEmbedding() {
|
|
|
+ String url = bigModelConfig.getBaseurl() + "/embedding";
|
|
|
+ Request request = buildGetRequest(url);
|
|
|
+ OkHttpClient client = buildOkHttpClient();
|
|
|
+ try {
|
|
|
+ Response response = client.newCall(request).execute();
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ String body = response.body().string();
|
|
|
+ log.info("向量模型列表返回:" + body);
|
|
|
+ JSONObject jsonObj = JSON.parseObject(body);
|
|
|
+ JSONObject obj = jsonObj.getJSONObject("data");
|
|
|
+ Integer total = obj.getInteger("total");
|
|
|
+ JSONArray array = obj.getJSONArray("list");
|
|
|
+ Map<String, Object> map = new HashMap();
|
|
|
+ map.put("list", array);
|
|
|
+ map.put("total", total);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ } catch(Exception e){
|
|
|
+ log.error("智谱 获取向量模型列表失败:", e);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject getModelList() {
|
|
|
+ String url = bigModelConfig.getModelList();
|
|
|
+ Request request = buildGetRequest(url);
|
|
|
+ OkHttpClient client = buildOkHttpClient();
|
|
|
+ try {
|
|
|
+ Response response = client.newCall(request).execute();
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ String body = response.body().string();
|
|
|
+ log.info("模型列表返回:" + body);
|
|
|
+ return JSON.parseObject(body);
|
|
|
+ }
|
|
|
+ } catch(Exception e){
|
|
|
+ log.error("智谱 获取向量模型列表失败:", e);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DialogRespDTO> selectDialogListByAppId(String appId) {
|
|
|
+ return dialogMapper.selectDialogListByAppId(appId);
|
|
|
+ }
|
|
|
+
|
|
|
private Request buildGetRequest(String url) {
|
|
|
return new Request.Builder()
|
|
|
.addHeader("accept", "*/*")
|