代码优化

This commit is contained in:
thinkgem
2025-05-15 11:06:50 +08:00
parent 1b21375e1c
commit 375fbbe375
3 changed files with 14 additions and 2 deletions

View File

@@ -92,7 +92,7 @@ public class WebClientThinkConfig {
}
String reasoningContent = (String) delta.get("reasoning_content");
String content = (String) delta.get("content");
if (StringUtils.isNotBlank(reasoningContent)) {
if (StringUtils.isNotBlank(reasoningContent) && StringUtils.isBlank(content)) {
if (!thinkingFlag.get()) {
thinkingFlag.set(true);
delta.put("content", "<think>\n" + reasoningContent);
@@ -102,7 +102,7 @@ public class WebClientThinkConfig {
} else {
if (thinkingFlag.get()) {
thinkingFlag.set(false);
delta.put("content", "</think>" + (content == null ? "" : content));
delta.put("content", "</think>\n" + (content == null ? "" : content));
}
}
}

View File

@@ -5,10 +5,19 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties("spring.ai")
public class CmsAiProperties {
/**
* 是否启用 Tool calling 工具调用
*/
private Boolean toolCalls = false;
/**
* 默认系统提示词
*/
private String defaultSystem = "";
/**
* 默认问题模板格式
*/
private String defaultPromptTemplate = "";
public Boolean getToolCalls() {

View File

@@ -59,6 +59,9 @@ public class CmsAiChatService extends BaseService {
* @author ThinkGem
*/
public List<Message> getChatMessage(String conversationId) {
if (StringUtils.isBlank(conversationId)) {
return List.of();
}
return chatMemory.get(conversationId);
}