mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 12:26:38 -06:00
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
// Mistral plugin module implements memory embedding adapter behavior.
|
|
import {
|
|
embeddingProviderOwnsDestination,
|
|
isMissingEmbeddingApiKeyError,
|
|
sanitizeEmbeddingCacheHeaders,
|
|
type MemoryEmbeddingProviderAdapter,
|
|
} from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
|
import {
|
|
createMistralEmbeddingProvider,
|
|
DEFAULT_MISTRAL_EMBEDDING_MODEL,
|
|
} from "./embedding-provider.js";
|
|
import { MISTRAL_BASE_URL } from "./model-definitions.js";
|
|
|
|
const EXCLUDED_EMBEDDING_HEADERS = ["authorization", "content-type", "x-api-key", "api-key"];
|
|
|
|
export const mistralMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter = {
|
|
id: "mistral",
|
|
defaultModel: DEFAULT_MISTRAL_EMBEDDING_MODEL,
|
|
transport: "remote",
|
|
authProviderId: "mistral",
|
|
autoSelectPriority: 50,
|
|
allowExplicitWhenConfiguredAuto: true,
|
|
shouldContinueAutoSelection: isMissingEmbeddingApiKeyError,
|
|
create: async (options) => {
|
|
const { provider, client } = await createMistralEmbeddingProvider({
|
|
...options,
|
|
provider: "mistral",
|
|
fallback: "none",
|
|
});
|
|
const headers = sanitizeEmbeddingCacheHeaders(client.headers, EXCLUDED_EMBEDDING_HEADERS);
|
|
const usesDefaultIdentity =
|
|
headers.length === 0 &&
|
|
embeddingProviderOwnsDestination({
|
|
baseUrl: client.baseUrl,
|
|
providerBaseUrl: MISTRAL_BASE_URL,
|
|
});
|
|
return {
|
|
provider,
|
|
runtime: {
|
|
id: "mistral",
|
|
cacheKeyData: {
|
|
provider: "mistral",
|
|
model: client.model,
|
|
...(usesDefaultIdentity ? {} : { baseUrl: client.baseUrl, headers }),
|
|
},
|
|
},
|
|
};
|
|
},
|
|
};
|