From 4d9a4f5c85706e1f7de777646399cf0449e0a464 Mon Sep 17 00:00:00 2001 From: "Laisky.Cai" Date: Mon, 17 Mar 2025 03:37:06 +0000 Subject: [PATCH] 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 --- README.md | 11 +++++++++++ relay/adaptor/openai/token.go | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bd53c336..d4ac5096 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Also welcome to register and use my deployed one-api gateway, which supports var - [Reasoning Format - thinking](#reasoning-format---thinking) - [Support AWS cross-region inferences](#support-aws-cross-region-inferences) - [Support OpenAI web search models](#support-openai-web-search-models) + - [Support gemini multimodal output #2197](#support-gemini-multimodal-output-2197) - [Bug fix](#bug-fix) ## Turtorial @@ -223,6 +224,16 @@ Supports two URL parameters: `thinking` and `reasoning_format`. support `gpt-4o-search-preview` & `gpt-4o-mini-search-preview` +![](https://s3.laisky.com/uploads/2025/03/openai-websearch-models-1.png) + +![](https://s3.laisky.com/uploads/2025/03/openai-websearch-models-2.png) + +### Support gemini multimodal output #2197 + +- [feature: support gemini multimodal output #2197](https://github.com/songquanpeng/one-api/pull/2197) + +![](https://s3.laisky.com/uploads/2025/03/gemini-multimodal.png) + ## Bug fix - [BUGFIX: Several issues when updating tokens #1933](https://github.com/songquanpeng/one-api/pull/1933) diff --git a/relay/adaptor/openai/token.go b/relay/adaptor/openai/token.go index 9e6a647b..fba3f198 100644 --- a/relay/adaptor/openai/token.go +++ b/relay/adaptor/openai/token.go @@ -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,