mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-18 00:16:37 +08:00
fix: close #218
This commit is contained in:
parent
77e7d11151
commit
a3ccc92f55
@ -196,22 +196,8 @@ func CountTokenMessages(messages []dto.Message, model string, checkSensitive boo
|
|||||||
if model == "glm-4v" {
|
if model == "glm-4v" {
|
||||||
imageTokenNum = 1047
|
imageTokenNum = 1047
|
||||||
} else {
|
} else {
|
||||||
if str, ok := m.ImageUrl.(string); ok {
|
imageUrl := m.ImageUrl.(dto.MessageImageUrl)
|
||||||
imageTokenNum, err = getImageToken(&dto.MessageImageUrl{Url: str, Detail: "auto"})
|
|
||||||
} else {
|
|
||||||
imageUrlMap := m.ImageUrl.(map[string]interface{})
|
|
||||||
detail, ok := imageUrlMap["detail"]
|
|
||||||
if ok {
|
|
||||||
imageUrlMap["detail"] = detail.(string)
|
|
||||||
} else {
|
|
||||||
imageUrlMap["detail"] = "auto"
|
|
||||||
}
|
|
||||||
imageUrl := dto.MessageImageUrl{
|
|
||||||
Url: imageUrlMap["url"].(string),
|
|
||||||
Detail: imageUrlMap["detail"].(string),
|
|
||||||
}
|
|
||||||
imageTokenNum, err = getImageToken(&imageUrl)
|
imageTokenNum, err = getImageToken(&imageUrl)
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err, false
|
return 0, err, false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user