mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 09:41:37 +00:00
54 lines
2.3 KiB
TypeScript
54 lines
2.3 KiB
TypeScript
// Deepseek plugin entrypoint registers its OpenClaw integration.
|
|
import { readConfiguredProviderCatalogEntries } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
|
import { buildProviderReplayFamilyHooks } from "openclaw/plugin-sdk/provider-model-shared";
|
|
import { buildProviderToolCompatFamilyHooks } from "openclaw/plugin-sdk/provider-tools";
|
|
import { fetchDeepSeekUsage } from "openclaw/plugin-sdk/provider-usage";
|
|
import { applyDeepSeekConfig } from "./onboard.js";
|
|
import manifest from "./openclaw.plugin.json" with { type: "json" };
|
|
import { buildDeepSeekProvider } from "./provider-catalog.js";
|
|
import { createDeepSeekV4ThinkingWrapper } from "./stream.js";
|
|
import { resolveDeepSeekV4ThinkingProfile } from "./thinking.js";
|
|
|
|
const PROVIDER_ID = "deepseek";
|
|
|
|
export default defineSingleProviderPluginEntry({
|
|
id: PROVIDER_ID,
|
|
name: "DeepSeek Provider",
|
|
description: "Bundled DeepSeek provider plugin",
|
|
manifest,
|
|
provider: {
|
|
label: "DeepSeek",
|
|
docsPath: "/providers/deepseek",
|
|
manifestAuth: { applyConfig: applyDeepSeekConfig },
|
|
catalog: {
|
|
buildProvider: buildDeepSeekProvider,
|
|
buildStaticProvider: buildDeepSeekProvider,
|
|
liveModelDiscovery: true,
|
|
},
|
|
augmentModelCatalog: ({ config }) =>
|
|
readConfiguredProviderCatalogEntries({
|
|
config,
|
|
providerId: PROVIDER_ID,
|
|
}),
|
|
matchesContextOverflowError: ({ errorMessage }) =>
|
|
/\bdeepseek\b.*(?:input.*too long|context.*exceed)/i.test(errorMessage),
|
|
...buildProviderReplayFamilyHooks({
|
|
family: "openai-compatible",
|
|
dropReasoningFromHistory: false,
|
|
}),
|
|
...buildProviderToolCompatFamilyHooks("deepseek"),
|
|
wrapStreamFn: (ctx) => createDeepSeekV4ThinkingWrapper(ctx.streamFn, ctx.thinkingLevel),
|
|
resolveThinkingProfile: ({ modelId }) => resolveDeepSeekV4ThinkingProfile(modelId),
|
|
isModernModelRef: ({ modelId }) => Boolean(resolveDeepSeekV4ThinkingProfile(modelId)),
|
|
resolveUsageAuth: async (ctx) => {
|
|
const apiKey = ctx.resolveApiKeyFromConfigAndStore({
|
|
envDirect: [ctx.env.DEEPSEEK_API_KEY],
|
|
});
|
|
return apiKey ? { token: apiKey } : null;
|
|
},
|
|
fetchUsageSnapshot: async (ctx) =>
|
|
await fetchDeepSeekUsage(ctx.token, ctx.timeoutMs, ctx.fetchFn),
|
|
},
|
|
});
|