diff --git a/pkg/service/cast/tag.go b/pkg/service/cast/tag.go index 2dfa6f3..5cd9956 100644 --- a/pkg/service/cast/tag.go +++ b/pkg/service/cast/tag.go @@ -326,6 +326,13 @@ func GenerateAutoHashtags(ctx context.Context, post string, max int32, position, return nil, nil, false, errors.New("自动生成标签失败") } + if resp.Post == "" { + return nil, nil, false, errors.New("自动生成标签返回的帖子内容为空") + } + + // 去掉自动标签返回的帖子内容多余的引号 + resp.Post = utils.CleanAutoHashtagsQuote(resp.Post) + // 提取生成后的标签 afterTags := utils.ExtractTags(resp.Post) zap.L().Info("GenerateAutoHashtags afterTags", zap.Strings("afterTags", afterTags)) diff --git a/pkg/utils/string.go b/pkg/utils/string.go index 2924c28..e680913 100644 --- a/pkg/utils/string.go +++ b/pkg/utils/string.go @@ -41,3 +41,13 @@ func ExtractTags(s string) []string { return tags } + +// 去掉自动标签里面多余的引号 +func CleanAutoHashtagsQuote(input string) string { + if input == "" { + return "" + } + cleaned := strings.ReplaceAll(input, "\\\"", "") + cleaned = strings.ReplaceAll(cleaned, "\"", "") + return cleaned +}