mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 21:00:44 +00:00
Merged via squash.
Prepared head SHA: ef561a59de
Co-authored-by: ai-hpc <183861985+ai-hpc@users.noreply.github.com>
Co-authored-by: hxy91819 <8814856+hxy91819@users.noreply.github.com>
Reviewed-by: @hxy91819
69 lines
2.7 KiB
TypeScript
69 lines
2.7 KiB
TypeScript
import type { ProviderThinkingProfile } from "openclaw/plugin-sdk/plugin-entry";
|
|
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 { isDeepSeekV4ModelId } from "./models.js";
|
|
import { applyDeepSeekConfig, DEEPSEEK_DEFAULT_MODEL_REF } from "./onboard.js";
|
|
import { buildDeepSeekProvider } from "./provider-catalog.js";
|
|
import { createDeepSeekV4ThinkingWrapper } from "./stream.js";
|
|
|
|
const PROVIDER_ID = "deepseek";
|
|
const V4_THINKING_LEVEL_IDS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"] as const;
|
|
|
|
function buildDeepSeekV4ThinkingLevel(id: (typeof V4_THINKING_LEVEL_IDS)[number]) {
|
|
return { id };
|
|
}
|
|
|
|
const DEEPSEEK_V4_THINKING_PROFILE = {
|
|
levels: V4_THINKING_LEVEL_IDS.map(buildDeepSeekV4ThinkingLevel),
|
|
defaultLevel: "high",
|
|
} satisfies ProviderThinkingProfile;
|
|
|
|
function resolveDeepSeekV4ThinkingProfile(modelId: string): ProviderThinkingProfile | undefined {
|
|
return isDeepSeekV4ModelId(modelId) ? DEEPSEEK_V4_THINKING_PROFILE : undefined;
|
|
}
|
|
|
|
export default defineSingleProviderPluginEntry({
|
|
id: PROVIDER_ID,
|
|
name: "DeepSeek Provider",
|
|
description: "Bundled DeepSeek provider plugin",
|
|
provider: {
|
|
label: "DeepSeek",
|
|
docsPath: "/providers/deepseek",
|
|
auth: [
|
|
{
|
|
methodId: "api-key",
|
|
label: "DeepSeek API key",
|
|
hint: "API key",
|
|
optionKey: "deepseekApiKey",
|
|
flagName: "--deepseek-api-key",
|
|
envVar: "DEEPSEEK_API_KEY",
|
|
promptMessage: "Enter DeepSeek API key",
|
|
defaultModel: DEEPSEEK_DEFAULT_MODEL_REF,
|
|
applyConfig: (cfg) => applyDeepSeekConfig(cfg),
|
|
wizard: {
|
|
choiceId: "deepseek-api-key",
|
|
choiceLabel: "DeepSeek API key",
|
|
groupId: "deepseek",
|
|
groupLabel: "DeepSeek",
|
|
groupHint: "API key",
|
|
},
|
|
},
|
|
],
|
|
catalog: {
|
|
buildProvider: buildDeepSeekProvider,
|
|
},
|
|
augmentModelCatalog: ({ config }) =>
|
|
readConfiguredProviderCatalogEntries({
|
|
config,
|
|
providerId: PROVIDER_ID,
|
|
}),
|
|
matchesContextOverflowError: ({ errorMessage }) =>
|
|
/\bdeepseek\b.*(?:input.*too long|context.*exceed)/i.test(errorMessage),
|
|
...buildProviderReplayFamilyHooks({ family: "openai-compatible" }),
|
|
wrapStreamFn: (ctx) => createDeepSeekV4ThinkingWrapper(ctx.streamFn, ctx.thinkingLevel),
|
|
resolveThinkingProfile: ({ modelId }) => resolveDeepSeekV4ThinkingProfile(modelId),
|
|
isModernModelRef: ({ modelId }) => Boolean(resolveDeepSeekV4ThinkingProfile(modelId)),
|
|
},
|
|
});
|