mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-15 19:21:08 +00:00
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
|
import { applyMistralModelCompat } from "./api.js";
|
|
import { mistralMediaUnderstandingProvider } from "./media-understanding-provider.js";
|
|
import { applyMistralConfig, MISTRAL_DEFAULT_MODEL_REF } from "./onboard.js";
|
|
import { buildMistralProvider } from "./provider-catalog.js";
|
|
import { contributeMistralResolvedModelCompat } from "./provider-compat.js";
|
|
|
|
const PROVIDER_ID = "mistral";
|
|
export function buildMistralReplayPolicy() {
|
|
return {
|
|
sanitizeToolCallIds: true,
|
|
toolCallIdMode: "strict9" as const,
|
|
};
|
|
}
|
|
|
|
export default defineSingleProviderPluginEntry({
|
|
id: PROVIDER_ID,
|
|
name: "Mistral Provider",
|
|
description: "Bundled Mistral provider plugin",
|
|
provider: {
|
|
label: "Mistral",
|
|
docsPath: "/providers/models",
|
|
auth: [
|
|
{
|
|
methodId: "api-key",
|
|
label: "Mistral API key",
|
|
hint: "API key",
|
|
optionKey: "mistralApiKey",
|
|
flagName: "--mistral-api-key",
|
|
envVar: "MISTRAL_API_KEY",
|
|
promptMessage: "Enter Mistral API key",
|
|
defaultModel: MISTRAL_DEFAULT_MODEL_REF,
|
|
applyConfig: (cfg) => applyMistralConfig(cfg),
|
|
wizard: {
|
|
groupLabel: "Mistral AI",
|
|
},
|
|
},
|
|
],
|
|
catalog: {
|
|
buildProvider: buildMistralProvider,
|
|
allowExplicitBaseUrl: true,
|
|
},
|
|
matchesContextOverflowError: ({ errorMessage }) =>
|
|
/\bmistral\b.*(?:input.*too long|token limit.*exceeded)/i.test(errorMessage),
|
|
normalizeResolvedModel: ({ model }) => applyMistralModelCompat(model),
|
|
contributeResolvedModelCompat: ({ modelId, model }) =>
|
|
contributeMistralResolvedModelCompat({ modelId, model }),
|
|
buildReplayPolicy: () => buildMistralReplayPolicy(),
|
|
},
|
|
register(api) {
|
|
api.registerMediaUnderstandingProvider(mistralMediaUnderstandingProvider);
|
|
},
|
|
});
|