|
| 1 | +import type { ProviderThinkingProfile } from "openclaw/plugin-sdk/plugin-entry"; |
1 | 2 | import { readConfiguredProviderCatalogEntries } from "openclaw/plugin-sdk/provider-catalog-shared"; |
2 | 3 | import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry"; |
3 | 4 | import { buildProviderReplayFamilyHooks } from "openclaw/plugin-sdk/provider-model-shared"; |
| 5 | +import { isDeepSeekV4ModelId } from "./models.js"; |
4 | 6 | import { applyDeepSeekConfig, DEEPSEEK_DEFAULT_MODEL_REF } from "./onboard.js"; |
5 | 7 | import { buildDeepSeekProvider } from "./provider-catalog.js"; |
6 | 8 | import { createDeepSeekV4ThinkingWrapper } from "./stream.js"; |
7 | 9 |
|
8 | 10 | const PROVIDER_ID = "deepseek"; |
| 11 | +const V4_THINKING_LEVEL_IDS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"] as const; |
| 12 | + |
| 13 | +function buildDeepSeekV4ThinkingLevel(id: (typeof V4_THINKING_LEVEL_IDS)[number]) { |
| 14 | + return { id }; |
| 15 | +} |
| 16 | + |
| 17 | +const DEEPSEEK_V4_THINKING_PROFILE = { |
| 18 | + levels: V4_THINKING_LEVEL_IDS.map(buildDeepSeekV4ThinkingLevel), |
| 19 | + defaultLevel: "high", |
| 20 | +} satisfies ProviderThinkingProfile; |
| 21 | + |
| 22 | +function resolveDeepSeekV4ThinkingProfile(modelId: string): ProviderThinkingProfile | undefined { |
| 23 | + return isDeepSeekV4ModelId(modelId) ? DEEPSEEK_V4_THINKING_PROFILE : undefined; |
| 24 | +} |
9 | 25 |
|
10 | 26 | export default defineSingleProviderPluginEntry({ |
11 | 27 | id: PROVIDER_ID, |
@@ -46,9 +62,7 @@ export default defineSingleProviderPluginEntry({ |
46 | 62 | /\bdeepseek\b.*(?:input.*too long|context.*exceed)/i.test(errorMessage), |
47 | 63 | ...buildProviderReplayFamilyHooks({ family: "openai-compatible" }), |
48 | 64 | wrapStreamFn: (ctx) => createDeepSeekV4ThinkingWrapper(ctx.streamFn, ctx.thinkingLevel), |
49 | | - isModernModelRef: ({ modelId }) => { |
50 | | - const lower = modelId.toLowerCase(); |
51 | | - return lower === "deepseek-v4-flash" || lower === "deepseek-v4-pro"; |
52 | | - }, |
| 65 | + resolveThinkingProfile: ({ modelId }) => resolveDeepSeekV4ThinkingProfile(modelId), |
| 66 | + isModernModelRef: ({ modelId }) => Boolean(resolveDeepSeekV4ThinkingProfile(modelId)), |
53 | 67 | }, |
54 | 68 | }); |
0 commit comments