Jelajahi Sumber

Merge branch 'master_nsh' into debug

xyxie 4 hari lalu
induk
melakukan
fba2b9db81
1 mengubah file dengan 13 tambahan dan 1 penghapusan
  1. 13 1
      services/feCalendar_ai.go

+ 13 - 1
services/feCalendar_ai.go

@@ -12,6 +12,7 @@ import (
 	"eta/eta_api/utils/llm/eta_llm"
 	"fmt"
 	"net/http"
+	"strings"
 	"time"
 )
 
@@ -137,7 +138,18 @@ func GetFeCalendarAiArticle(req *fe_calendar.FeCalendarAiArticleGenerateReq, mat
 		}
 	}
 LOOP_END:
-   
+
+	// 过滤掉<think>块内容
+	if thinkStart := strings.Index(text, "<think>"); thinkStart != -1 {
+		if thinkEnd := strings.Index(text, "</think>"); thinkEnd != -1 {
+			// 提取<think>之前和</think>之后的内容
+			text = text[:thinkStart] + text[thinkEnd+len("</think>"):]
+		}
+	}
+
+	// 去除可能存在的多余空行
+	text = strings.TrimSpace(text)
+
 	// 获取品种信息
 	// permissionItem, err := models.GetChartPermissionById(req.ChartPermissionId)
 	// if err != nil {