|
@@ -591,9 +591,13 @@ public class ChatController {
|
|
|
|
|
|
|
|
// 构建完整来源引用
|
|
// 构建完整来源引用
|
|
|
StringBuilder sourceBuilder = new StringBuilder();
|
|
StringBuilder sourceBuilder = new StringBuilder();
|
|
|
- if (!sourceVersion.isEmpty()) sourceBuilder.append(sourceVersion);
|
|
|
|
|
|
|
+ if (!sourceVersion.isEmpty()) {
|
|
|
|
|
+ sourceBuilder.append(sourceVersion);
|
|
|
|
|
+ }
|
|
|
if (!sourceVolume.isEmpty()) {
|
|
if (!sourceVolume.isEmpty()) {
|
|
|
- if (!sourceBuilder.isEmpty()) sourceBuilder.append(" ");
|
|
|
|
|
|
|
+ if (!sourceBuilder.isEmpty()) {
|
|
|
|
|
+ sourceBuilder.append(" ");
|
|
|
|
|
+ }
|
|
|
sourceBuilder.append(sourceVolume);
|
|
sourceBuilder.append(sourceVolume);
|
|
|
}
|
|
}
|
|
|
String fullSource = sourceBuilder.toString();
|
|
String fullSource = sourceBuilder.toString();
|
|
@@ -614,7 +618,9 @@ public class ChatController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private String extractDrugName(String content) {
|
|
private String extractDrugName(String content) {
|
|
|
- if (content == null) return "";
|
|
|
|
|
|
|
+ if (content == null) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
int start = content.indexOf("【");
|
|
int start = content.indexOf("【");
|
|
|
int end = content.indexOf(" - ");
|
|
int end = content.indexOf(" - ");
|
|
|
if (start >= 0 && end > start) {
|
|
if (start >= 0 && end > start) {
|
|
@@ -625,9 +631,13 @@ public class ChatController {
|
|
|
|
|
|
|
|
/** 从 content 文本中提取真实 section(兜底"正文") */
|
|
/** 从 content 文本中提取真实 section(兜底"正文") */
|
|
|
private String realSection(String content, String storedSection) {
|
|
private String realSection(String content, String storedSection) {
|
|
|
- if (!"正文".equals(storedSection) || content == null) return storedSection;
|
|
|
|
|
|
|
+ if (!"正文".equals(storedSection) || content == null) {
|
|
|
|
|
+ return storedSection;
|
|
|
|
|
+ }
|
|
|
int sep = content.indexOf(" - ");
|
|
int sep = content.indexOf(" - ");
|
|
|
- if (sep < 0) return storedSection;
|
|
|
|
|
|
|
+ if (sep < 0) {
|
|
|
|
|
+ return storedSection;
|
|
|
|
|
+ }
|
|
|
int end = content.indexOf("】", sep);
|
|
int end = content.indexOf("】", sep);
|
|
|
if (end > sep) {
|
|
if (end > sep) {
|
|
|
return content.substring(sep + 3, end).trim();
|
|
return content.substring(sep + 3, end).trim();
|
|
@@ -636,7 +646,9 @@ public class ChatController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private String cleanAnswer(String text) {
|
|
private String cleanAnswer(String text) {
|
|
|
- if (text == null) return "";
|
|
|
|
|
|
|
+ if (text == null) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
// 去除多余空白行(保留单个换行),修复 Qwen 常见格式问题
|
|
// 去除多余空白行(保留单个换行),修复 Qwen 常见格式问题
|
|
|
return text
|
|
return text
|
|
|
.replace("\r\n", "\n")
|
|
.replace("\r\n", "\n")
|