@core-ai/mistral 0.22.0 → 0.24.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 +10 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -671,6 +671,7 @@ import {
|
|
|
671
671
|
ContextLengthExceededError,
|
|
672
672
|
ModelOverloadedError,
|
|
673
673
|
ProviderError,
|
|
674
|
+
ProviderQuotaExceededError,
|
|
674
675
|
RateLimitError,
|
|
675
676
|
ServiceUnavailableError,
|
|
676
677
|
asRecord,
|
|
@@ -695,7 +696,7 @@ function wrapMistralError(error) {
|
|
|
695
696
|
const message = getErrorMessage(error);
|
|
696
697
|
const statusCode = error instanceof MistralError ? error.statusCode : getHttpStatusCode(error, ["statusCode", "status"]);
|
|
697
698
|
const body = parseErrorBody(error);
|
|
698
|
-
const options = { statusCode, cause: error };
|
|
699
|
+
const options = { statusCode, code: body?.type, cause: error };
|
|
699
700
|
const contextLength = getContextLengthDetails(body, message);
|
|
700
701
|
if (contextLength) {
|
|
701
702
|
return new ContextLengthExceededError(message, "mistral", {
|
|
@@ -703,6 +704,9 @@ function wrapMistralError(error) {
|
|
|
703
704
|
...contextLength
|
|
704
705
|
});
|
|
705
706
|
}
|
|
707
|
+
if (statusCode === 402) {
|
|
708
|
+
return new ProviderQuotaExceededError(message, "mistral", options);
|
|
709
|
+
}
|
|
706
710
|
if (indicatesMistralOverload(message, statusCode)) {
|
|
707
711
|
return new ModelOverloadedError(message, "mistral", options);
|
|
708
712
|
}
|
|
@@ -730,7 +734,7 @@ function indicatesMistralOverload(text, statusCode) {
|
|
|
730
734
|
if (statusCode !== void 0 && !OVERLOAD_MESSAGE_ELIGIBLE_STATUS_CODES.has(statusCode)) {
|
|
731
735
|
return false;
|
|
732
736
|
}
|
|
733
|
-
return /\boverloaded\b/i.test(text);
|
|
737
|
+
return /\boverloaded\b/i.test(text) || /service tier capacity exceeded/i.test(text);
|
|
734
738
|
}
|
|
735
739
|
function getContextLengthDetails(body, message) {
|
|
736
740
|
const errorMessage = resolveMistralMessageText(body?.message ?? message);
|
|
@@ -851,7 +855,10 @@ function createMistralChatModel(client, modelId) {
|
|
|
851
855
|
})
|
|
852
856
|
)
|
|
853
857
|
),
|
|
854
|
-
{
|
|
858
|
+
{
|
|
859
|
+
signal: options.signal,
|
|
860
|
+
mapError: wrapMistralError
|
|
861
|
+
}
|
|
855
862
|
);
|
|
856
863
|
}
|
|
857
864
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@core-ai/mistral",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Mistral provider package for @core-ai/core-ai",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Omnifact (https://omnifact.ai)",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"test:watch": "vitest"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@core-ai/core-ai": "^0.
|
|
46
|
+
"@core-ai/core-ai": "^0.24.0",
|
|
47
47
|
"@mistralai/mistralai": "^2.4.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|