docs: update README to include support for Gemini multimodal output and add relevant images

fix: ensure nil check for content text in token counting function
This commit is contained in:
Laisky.Cai
2025-03-17 03:37:06 +00:00
parent 000f092023
commit 4d9a4f5c85
2 changed files with 14 additions and 1 deletions

View File

@@ -103,7 +103,9 @@ func CountTokenMessages(ctx context.Context,
for _, content := range contents {
switch content.Type {
case model.ContentTypeText:
tokenNum += getTokenNum(tokenEncoder, content.Text)
if content.Text != nil {
tokenNum += getTokenNum(tokenEncoder, *content.Text)
}
case model.ContentTypeImageURL:
imageTokens, err := countImageTokens(
content.ImageURL.Url,