fix: text filed check for 4v request (#1634)

This commit is contained in:
Ghostz 2024-07-13 14:57:08 +08:00 committed by GitHub
parent 6ad169975f
commit 65acb94f45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -97,7 +97,11 @@ func CountTokenMessages(messages []model.Message, model string) int {
m := it.(map[string]any)
switch m["type"] {
case "text":
tokenNum += getTokenNum(tokenEncoder, m["text"].(string))
if textValue, ok := m["text"]; ok {
if textString, ok := textValue.(string); ok {
tokenNum += getTokenNum(tokenEncoder, textString)
}
}
case "image_url":
imageUrl, ok := m["image_url"].(map[string]any)
if ok {