过滤并只保留汉字内容
(content string)
| 90 | |
| 91 | // 过滤并只保留汉字内容 |
| 92 | func filterChineseContent(content string) string { |
| 93 | // 使用正则表达式匹配汉字 |
| 94 | var chineseContent strings.Builder |
| 95 | for _, r := range content { |
| 96 | // 检查字符是否为汉字 |
| 97 | if unicode.Is(unicode.Scripts["Han"], r) { |
| 98 | chineseContent.WriteRune(r) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // 返回过滤后的汉字内容 |
| 103 | return chineseContent.String() |
| 104 | } |
| 105 | |
| 106 | func getAndValidateTextRequest(c *gin.Context, relayInfo *relaycommon.RelayInfo) (*dto.GeneralOpenAIRequest, error) { |
| 107 | textRequest := &dto.GeneralOpenAIRequest{} |
no outgoing calls
no test coverage detected