Repository navigation
Is provider: BEDROCK meant to return Anthropic's Messages shape instead of the real AWS Converse API shape?
#2757
ContextI'm testing Kuadrant's IssueMocking Repro expectation: {
"httpRequest": { "method": "POST", "path": "/model/amazon.titan-text-express-v1/converse" },
"httpLlmResponse": {
"provider": "BEDROCK",
"model": "amazon.titan-text-express-v1",
"completion": { "text": "mocked response", "usage": { "inputTokens": 5, "outputTokens": 5 } }
}
}Response received: {
"id": "msg_305fe52e4ae04909bc51bab8",
"type": "message",
"role": "assistant",
"content": [ { "type": "text", "text": "mocked response" } ],
"stop_reason": "end_turn",
"usage": { "input_tokens": 5, "output_tokens": 5 }
}This also lines up with the 7.5.0 release notes for Question Is this intentional? If so, could the docs be updated to say |
Replies: 4 comments
|
From the code, the Anthropic shape is what the codec is designed to return right now. The docs table is what's out of step. private final AnthropicCodec delegate = new AnthropicCodec();
...
public HttpResponse encode(Completion completion, String model) {
return delegate.encode(completion, model);
}So you get For testing the Kuadrant {
"httpRequest": { "method": "POST", "path": "/model/amazon.titan-text-express-v1/converse" },
"httpResponse": {
"statusCode": 200,
"headers": { "content-type": ["application/json"] },
"body": {
"type": "JSON",
"json": {
"output": { "message": { "role": "assistant", "content": [ { "text": "mocked response" } ] } },
"stopReason": "end_turn",
"usage": { "inputTokens": 5, "outputTokens": 5, "totalTokens": 10 },
"metrics": { "latencyMs": 100 }
}
}
}
}That gives you full control over |
|
Thanks for the clear repro, and thanks @tk1475 for the accurate diagnosis. This isn't intended. The docs promise the Bedrock Converse API for {
"output": { "message": { "role": "assistant", "content": [ { "text": "..." } ] } },
"stopReason": "end_turn",
"usage": { "inputTokens": 5, "outputTokens": 5, "totalTokens": 10 },
"metrics": { "latencyMs": 100 }
}I'll treat this as a bug. The fix is to give For testing your We expect to cut a new release within the next 5 days, once we finish tuning a few final performance points, and the Converse fix will be in it. |
|
The fix for this is now on With It will be in the next release. |
|
Thanks for the quick fix! Looking forward to the next release that includes this. In the meantime, I've worked around it in our testsuite by hand-crafting the Converse-shaped response body via a plain |
The fix for this is now on
masterin afeada5f1.With
provider: BEDROCK, a mock on/model/{model}/conversenow returns the real Converse envelope:output.message.content[],stopReason,usage.inputTokens/outputTokens/totalTokensandmetrics. Your exact expectation from above returnsusage.totalTokens: 10, so Kuadrant's default/usage/totalTokenspointer resolves./model/{model}/converse-streamreturns ConverseStream events (messageStart,contentBlockDelta,messageStop,metadata) in AWS event-stream framing./invokeand/invoke-with-response-streamkeep returning the InvokeModel body as before. Converse requests are now also understood by the conversation matchers.It will be in the next…