aws / aws/aws-sdk-java-v2

Document input not supported for token counting

Offen
#6,370 2 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
feature-request service:bedrock-runtime
Vorherrschende Sprache
Java
Sterne
2.6k
Forks
1k
Ø Merge
2 T. 9 Std.
Gemergte PRs (30 T.)
51

Beschreibung

### Describe the bug

There is very little information about the new token counting feature for Bedrock. It seems to work for basic text, which is cute, but the difficult part is documents, and it doesn't work for any kind of documents. I know that Claude 4 supports token counting, at least through their API, but Bedrock is throwing an exception.

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Expected Behavior

I expect token counting to work for Claude 4, including documents such as txt, md, doc, docx, csv, xls, xlsx, pdf.

### Current Behavior

Exception for any document: "Document input not supported for token counting".

### Reproduction Steps

```groovy
bedrockRuntimeClient.countTokens({
it.modelId('anthropic.claude-sonnet-4-20250514-v1:0')
it.input({
it.converse {
it.messages([
Message.builder()
.content([
ContentBlock.fromDocument({
it.name('document')
it.source {
it.text('text')
}
})
])
.role(ConversationRole.USER)
.build()
])
}
})
}).inputTokens()
```

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### AWS Java SDK version used

2.32.29

### JDK version used

11

### Operating System and version

MacOS 15.0.1

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start by reproducing the failure at bedrockRuntimeClient.countTokens with a Converse input containing ContentBlock.fromDocument, using the reported SDK and JDK versions. Trace the Bedrock token-counting request handling for document content and compare the service/API behavior for Claude 4. Done means document inputs no longer raise the reported exception and return inputTokens for the supported formats listed.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
aws, java
Bereich
api, cloud
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.