Merge branch 'feature-userinfo-daiyb' into dev
This commit is contained in:
commit
a130bc03c8
@ -8,6 +8,7 @@ import (
|
||||
"fonchain-fiee/pkg/model/login"
|
||||
modelQwen "fonchain-fiee/pkg/model/qwen"
|
||||
"fonchain-fiee/pkg/service"
|
||||
"fonchain-fiee/pkg/utils"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
@ -217,6 +218,8 @@ func OneText(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
resultAll.Title, resultAll.Content = extractTitleAndContent(req.Prompt)
|
||||
resultAll.Title = utils.TruncateString(resultAll.Title, 100)
|
||||
resultAll.Content = utils.TruncateString(resultAll.Content, 200)
|
||||
for _, v := range result.Output.Results {
|
||||
resultAll.Result = append(resultAll.Result, struct {
|
||||
Url string `json:"url"`
|
||||
@ -384,6 +387,8 @@ func MoreText(ctx *gin.Context) {
|
||||
}
|
||||
resultAll.Content = contentRes.content
|
||||
|
||||
resultAll.Title = utils.TruncateString(resultAll.Title, 100)
|
||||
resultAll.Content = utils.TruncateString(resultAll.Content, 200)
|
||||
// 处理图片结果
|
||||
if imageRes.err != nil {
|
||||
service.Error(ctx, fmt.Errorf("生成图片失败: %v", imageRes.err))
|
||||
|
||||
@ -7,3 +7,14 @@ func CleanString(s string) string {
|
||||
fields := strings.Fields(s)
|
||||
return strings.Join(fields, "")
|
||||
}
|
||||
|
||||
func TruncateString(s string, maxLen int) string {
|
||||
if maxLen <= 0 {
|
||||
return ""
|
||||
}
|
||||
runes := []rune(s)
|
||||
if len(runes) <= maxLen {
|
||||
return s
|
||||
}
|
||||
return string(runes[:maxLen])
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user