feat: add /tokenize for chat completion on aws bedrock converse api#2404
Open
hustxiayang wants to merge 3 commits into
Open
feat: add /tokenize for chat completion on aws bedrock converse api#2404hustxiayang wants to merge 3 commits into
hustxiayang wants to merge 3 commits into
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Contributor
Author
|
/gemini review |
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Contributor
|
@gemini review |
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Contributor
Author
|
/retest |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2404 +/- ##
==========================================
- Coverage 84.85% 84.84% -0.01%
==========================================
Files 154 156 +2
Lines 22405 22508 +103
==========================================
+ Hits 19011 19097 +86
- Misses 2238 2245 +7
- Partials 1156 1166 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Adds /tokenize support for AWS Bedrock via the Converse-style CountTokens API (AWSBedrock schema), reusing awsbedrock.CountTokensResponse. Completion prompts are converted to chat messages. Also fixes two loop-variable address-of patterns flagged in review. Registers the schema in the tokenize endpoint spec. Signed-off-by: yxia216 <yxia216@bloomberg.net>
hustxiayang
force-pushed
the
tokenize-bedrock
branch
from
July 21, 2026 20:02
c5e3ab1 to
91b491d
Compare
hustxiayang
marked this pull request as draft
July 21, 2026 20:48
Signed-off-by: yxia216 <yxia216@bloomberg.net>
hustxiayang
marked this pull request as ready for review
July 22, 2026 01:28
aabchoo
reviewed
Jul 22, 2026
|
|
||
| // openAIToolsToBedrockToolConfig converts openai ChatCompletion tools (and optional | ||
| // tool_choice) into an aws bedrock tool configuration. toolChoice may be nil. | ||
| func openAIToolsToBedrockToolConfig(tools []openai.Tool, toolChoice *openai.ChatCompletionToolChoiceUnion, model string, |
Contributor
There was a problem hiding this comment.
could you please introduce tests for this file?
aabchoo
reviewed
Jul 22, 2026
| // only. This is provider-agnostic (unlike the Anthropic-specific path) because the Converse | ||
| // translator also serves Amazon Nova, Meta Llama, etc. | ||
| // See: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_CountTokens.html | ||
| for _, prefix := range []string{"us-gov.", "us.", "eu.", "apac.", "global."} { |
Comment on lines
+643
to
+644
| type CountTokensConverseInput struct { | ||
| Messages []*Message `json:"messages"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add
/tokenizesupport for chat completion on AWS Bedrock Converse API CountTokens API. This is a split from #1650 as planned.