aws / aws/aws-sdk-java-v2

Document input not supported for token counting

Aperta
#6,370 2 commenti 2 reazioni 0 assegnatari Vedi su GitHub
feature-request service:bedrock-runtime
Lingua principale
Java
Stelle
2.6k
Fork
1k
Merge medio
2g 9h
PR unite (30g)
51

Descrizione

### 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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, java
Ambito
api, cloud
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.