Skip to content

Commit 6ff6be2

Browse files
committed
Enhance error handling in HandleAnthropicErrorCodes by adding a new token count exceeded message and ensuring case-insensitive checks for existing messages.
1 parent 1ea8b3e commit 6ff6be2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

anthropic-client/src/main/scala/io/cequence/openaiscala/anthropic/service/HandleAnthropicErrorCodes.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ trait HandleAnthropicErrorCodes extends WSClient {
1212

1313
private val TokenCountExceededMessages = Set(
1414
"input length and `max_tokens` exceed context limit",
15-
"prompt is too long"
15+
"prompt is too long",
16+
"input is too long for requested model" // bedrock
1617
)
1718

1819
override protected def handleErrorCodes(
@@ -24,7 +25,7 @@ trait HandleAnthropicErrorCodes extends WSClient {
2425

2526
case 400 => {
2627
// Check if the error message indicates token count exceeded
27-
if (TokenCountExceededMessages.exists(message.contains)) {
28+
if (TokenCountExceededMessages.exists(message.toLowerCase().contains)) {
2829
throw new AnthropicScalaTokenCountExceededException(errorMessage)
2930
} else {
3031
// 400 - invalid_request_error: There was an issue with the format or content of your request.

0 commit comments

Comments
 (0)