feat(prompt): enhance context and intent classification in templates

- Updated context template to include runtime metadata such as current time and week, improving contextual awareness in user queries.
- Enhanced rewrite template with critical instructions for intent classification, ensuring that rewritten questions preserve essential entities and keywords.
- Refined intent classification logic to prioritize user intents more effectively, improving the accuracy of responses based on user queries.
- Added examples to clarify expected input and output formats for intent classification, enhancing usability for developers.
This commit is contained in:
wizardchen
2026-03-26 16:45:51 +08:00
committed by lyingbug
parent 27d4525ba9
commit 72dfb9ce75
44 changed files with 451 additions and 135 deletions
+13 -4
View File
@@ -26,8 +26,16 @@ type loggerResponseBodyWriter struct {
}
// Write 重写Write方法,同时写入buffer和原始writer
// 限制buffer大小,避免SSE等流式响应导致内存无限增长
func (r loggerResponseBodyWriter) Write(b []byte) (int, error) {
r.body.Write(b)
if r.body.Len() < maxBodySize {
remaining := maxBodySize - r.body.Len()
if len(b) <= remaining {
r.body.Write(b)
} else {
r.body.Write(b[:remaining])
}
}
return r.ResponseWriter.Write(b)
}
@@ -182,12 +190,13 @@ func Logger() gin.HandlerFunc {
// 读取响应体
responseBodyStr := ""
if responseBody.Len() > 0 {
// 检查Content-Type,只记录JSON类型
contentType := c.Writer.Header().Get("Content-Type")
if strings.Contains(contentType, "application/json") ||
if strings.Contains(contentType, "text/event-stream") {
responseBodyStr = "[SSE流式响应,已跳过]"
} else if strings.Contains(contentType, "application/json") ||
strings.Contains(contentType, "text/") {
bodyBytes := responseBody.Bytes()
if len(bodyBytes) > maxBodySize {
if len(bodyBytes) >= maxBodySize {
responseBodyStr = string(bodyBytes[:maxBodySize]) + "... [内容过长,已截断]"
} else {
responseBodyStr = string(bodyBytes)