@core-ai/anthropic 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -45,7 +45,7 @@ function wrapAnthropicError(error, provider = "anthropic") {
|
|
|
45
45
|
const statusCode = error instanceof APIError ? error.status : getHttpStatusCode(error, ["status"]);
|
|
46
46
|
const providerMessage = getAnthropicErrorMessage(error);
|
|
47
47
|
const errorType = getAnthropicErrorType(error);
|
|
48
|
-
const options = { statusCode, cause: error };
|
|
48
|
+
const options = { statusCode, code: errorType, cause: error };
|
|
49
49
|
const contextLength = getContextLengthDetails(providerMessage, errorType);
|
|
50
50
|
if (contextLength) {
|
|
51
51
|
return new ContextLengthExceededError(message, provider, {
|
|
@@ -62,11 +62,14 @@ function wrapAnthropicError(error, provider = "anthropic") {
|
|
|
62
62
|
retryAfterSeconds: getRetryAfterSecondsFromError(error)
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
if (isUnavailableStatus(error) || isTransientUnavailableStatus(statusCode)) {
|
|
65
|
+
if (isUnavailableStatus(error) || isTransientUnavailableStatus(statusCode) || isAnthropicServerError(errorType)) {
|
|
66
66
|
return new ServiceUnavailableError(message, provider, options);
|
|
67
67
|
}
|
|
68
68
|
return new ProviderError(message, provider, options);
|
|
69
69
|
}
|
|
70
|
+
function isAnthropicServerError(errorType) {
|
|
71
|
+
return errorType === "api_error" || errorType === "timeout_error";
|
|
72
|
+
}
|
|
70
73
|
function isAnthropicAbortError(error) {
|
|
71
74
|
return error instanceof APIUserAbortError || isAbortErrorByName(error);
|
|
72
75
|
}
|
|
@@ -1081,7 +1084,10 @@ function createAnthropicChatModel(client, modelId, modelOptions = {}) {
|
|
|
1081
1084
|
options.signal
|
|
1082
1085
|
)
|
|
1083
1086
|
),
|
|
1084
|
-
{
|
|
1087
|
+
{
|
|
1088
|
+
signal: options.signal,
|
|
1089
|
+
mapError: (error) => wrapAnthropicError(error, provider)
|
|
1090
|
+
}
|
|
1085
1091
|
);
|
|
1086
1092
|
}
|
|
1087
1093
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@core-ai/anthropic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Anthropic provider package for @core-ai/core-ai",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Omnifact (https://omnifact.ai)",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@anthropic-ai/sdk": "^0.110.0",
|
|
48
|
-
"@core-ai/core-ai": "^0.
|
|
48
|
+
"@core-ai/core-ai": "^0.23.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"zod": "^4.0.0"
|