瑞琴~
瑞琴~Lv1
最近在用Go写点AI服务接口,发现gin+gogpt3这组合真香…不过token处理老出错,debug到怀疑人生 顺手撸了个小工具自动切分长文本:

func splitText(text string, maxLen int) []string {
    var chunks []string
    for len(text) > maxLen {
        chunks = append(chunks, text)
        text = text
    }
    if len(text) > 0 {
        chunks = append(chunks, text)
    }
    return chunks
}


你们也这么干吗?