Spaces:
Sleeping
Sleeping
File size: 1,070 Bytes
7d06702 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
package utils
import (
"github.com/gin-gonic/gin"
"math/rand"
)
func MappingModel(model string) string {
var modelMapping = map[string]string{
"gpt-3.5-turbo": "text-davinci-002-render-sha",
"gpt-3.5-turbo-16k": "text-davinci-002-render-sha",
"gpt-3.5-turbo-16k-0613": "text-davinci-002-render-sha",
"gpt-3.5-turbo-0301": "text-davinci-002-render-sha",
"gpt-3.5-turbo-0613": "text-davinci-002-render-sha",
"gpt-3.5-turbo-1106": "text-davinci-002-render-sha",
}
if model == "" {
return "text-davinci-002-render-sha"
}
if v, ok := modelMapping[model]; ok {
return v
}
return "text-davinci-002-render-sha"
}
func GenerateID(length int) string {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
id := "chatcmpl-"
for i := 0; i < length; i++ {
id += string(charset[rand.Intn(len(charset))])
}
return id
}
func ErrorResp(c *gin.Context, code int, msg interface{}, err interface{}) {
c.AbortWithStatusJSON(code, gin.H{
"code": code,
"msg": msg,
"error": err,
})
return
}
|