|
|
|
@ -23,6 +23,7 @@ import cn.teammodel.service.ChatMessageService;
|
|
|
|
|
import cn.teammodel.utils.FileUtil;
|
|
|
|
|
import cn.teammodel.utils.RepositoryUtil;
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.alibaba.fastjson2.TypeReference;
|
|
|
|
|
import com.azure.cosmos.models.CosmosPatchOperations;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -313,13 +314,25 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
|
//验证获取模型数据 异常问题
|
|
|
|
|
File file = null;
|
|
|
|
|
try {
|
|
|
|
|
chatModels = readResourceFile("Json/ChatModel.json");
|
|
|
|
|
String fileText = FileUtil.getFileText("Json/ChatModel.json");
|
|
|
|
|
//转换问题
|
|
|
|
|
try {
|
|
|
|
|
//String strData01 = JSON.toJSONString(fileText);
|
|
|
|
|
//获取聊天字段中的数据
|
|
|
|
|
Object str = JSON.parseObject(fileText).get("chatModel");
|
|
|
|
|
String strData1 = JSON.toJSONString(str);
|
|
|
|
|
//转换方式
|
|
|
|
|
chatModels = JSON.parseObject(strData1, new TypeReference<List<ChatModelDto>>() { });
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "类型转换失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//chatModels = readResourceFile("Json/ChatModel.json");
|
|
|
|
|
//String str = readResourceFile("Json/ChatModel.json");
|
|
|
|
|
//file = new File(ClassLoader.getSystemResource("Json/ChatModel.json").getPath()); //相对路径获取文件信息
|
|
|
|
|
|
|
|
|
|
//File file = new File("src/main/resources/Json/ChatModel.json"); //绝对路径获取文件信息
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "读取文件" + Arrays.toString(e.getStackTrace()));
|
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "读取文件" + Arrays.toString(e.getStackTrace()) + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
/*try {
|
|
|
|
|
//chatModel = readerMethod(file);
|
|
|
|
@ -511,8 +524,7 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
|
//转换问题
|
|
|
|
|
try {
|
|
|
|
|
//转换方式
|
|
|
|
|
chatModelDtos = JSON.parseObject(strData2, new TypeReference<List<ChatModelDto>>() {
|
|
|
|
|
});
|
|
|
|
|
chatModelDtos = JSON.parseObject(strData2, new TypeReference<List<ChatModelDto>>() {});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "类型转换失败");
|
|
|
|
|
}
|
|
|
|
|