@core-ai/mistral 0.23.0 → 0.25.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 +23 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
safeParseJsonObject,
|
|
18
18
|
ValidationError,
|
|
19
19
|
validateInputModalities,
|
|
20
|
+
validateToolSchemaStrictness,
|
|
20
21
|
zodSchemaToJsonSchema
|
|
21
22
|
} from "@core-ai/core-ai";
|
|
22
23
|
|
|
@@ -58,7 +59,8 @@ import {
|
|
|
58
59
|
MULTIMODAL_INPUT_MODALITIES,
|
|
59
60
|
stripModelDateSuffix,
|
|
60
61
|
TEXT_ONLY_MODALITIES,
|
|
61
|
-
UNKNOWN_MODEL
|
|
62
|
+
UNKNOWN_MODEL,
|
|
63
|
+
UNSUPPORTED_TOOL_SCHEMA_STRICTNESS
|
|
62
64
|
} from "@core-ai/core-ai";
|
|
63
65
|
var MISTRAL_VERSION_SUFFIX_PATTERN = /-(?:latest|\d{4})$/;
|
|
64
66
|
function createCapabilities(modalities) {
|
|
@@ -69,7 +71,13 @@ function createCapabilities(modalities) {
|
|
|
69
71
|
restrictsSamplingParams: false,
|
|
70
72
|
supportedToolChoices: ["auto", "none", "required", "tool"]
|
|
71
73
|
},
|
|
72
|
-
modalities
|
|
74
|
+
modalities,
|
|
75
|
+
tools: {
|
|
76
|
+
// Mistral's SDK exposes a `strict` field on functions, but the API
|
|
77
|
+
// does not document grammar-enforced adherence — keep unsupported
|
|
78
|
+
// until enforcement is verified (follow-up candidate).
|
|
79
|
+
strictSchemas: UNSUPPORTED_TOOL_SCHEMA_STRICTNESS
|
|
80
|
+
}
|
|
73
81
|
};
|
|
74
82
|
}
|
|
75
83
|
var VISION_CAPABILITIES = createCapabilities(MULTIMODAL_INPUT_MODALITIES);
|
|
@@ -307,6 +315,14 @@ function createRequestBase(modelId, options, adapterOptions) {
|
|
|
307
315
|
modelId,
|
|
308
316
|
providerId
|
|
309
317
|
});
|
|
318
|
+
if (options.tools) {
|
|
319
|
+
validateToolSchemaStrictness({
|
|
320
|
+
tools: options.tools,
|
|
321
|
+
capabilities,
|
|
322
|
+
providerId,
|
|
323
|
+
modelId
|
|
324
|
+
});
|
|
325
|
+
}
|
|
310
326
|
return {
|
|
311
327
|
model: modelId,
|
|
312
328
|
messages: convertMessages(options.messages, {
|
|
@@ -671,6 +687,7 @@ import {
|
|
|
671
687
|
ContextLengthExceededError,
|
|
672
688
|
ModelOverloadedError,
|
|
673
689
|
ProviderError,
|
|
690
|
+
ProviderQuotaExceededError,
|
|
674
691
|
RateLimitError,
|
|
675
692
|
ServiceUnavailableError,
|
|
676
693
|
asRecord,
|
|
@@ -703,6 +720,9 @@ function wrapMistralError(error) {
|
|
|
703
720
|
...contextLength
|
|
704
721
|
});
|
|
705
722
|
}
|
|
723
|
+
if (statusCode === 402) {
|
|
724
|
+
return new ProviderQuotaExceededError(message, "mistral", options);
|
|
725
|
+
}
|
|
706
726
|
if (indicatesMistralOverload(message, statusCode)) {
|
|
707
727
|
return new ModelOverloadedError(message, "mistral", options);
|
|
708
728
|
}
|
|
@@ -730,7 +750,7 @@ function indicatesMistralOverload(text, statusCode) {
|
|
|
730
750
|
if (statusCode !== void 0 && !OVERLOAD_MESSAGE_ELIGIBLE_STATUS_CODES.has(statusCode)) {
|
|
731
751
|
return false;
|
|
732
752
|
}
|
|
733
|
-
return /\boverloaded\b/i.test(text);
|
|
753
|
+
return /\boverloaded\b/i.test(text) || /service tier capacity exceeded/i.test(text);
|
|
734
754
|
}
|
|
735
755
|
function getContextLengthDetails(body, message) {
|
|
736
756
|
const errorMessage = resolveMistralMessageText(body?.message ?? message);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@core-ai/mistral",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.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.25.0",
|
|
47
47
|
"@mistralai/mistralai": "^2.4.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|