mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-07-02 02:22:55 +08:00
refactor: generic provider effort handling
This commit is contained in:
@@ -91,29 +91,35 @@ const readCodexPriority = (value: unknown): number => (
|
||||
typeof value === 'number' && Number.isFinite(value) ? value : Number.MAX_SAFE_INTEGER
|
||||
);
|
||||
|
||||
const mapCodexModel = (model: CodexCachedModel): ProviderModelOption => ({
|
||||
value: model.slug as string,
|
||||
label: readOptionalString(model.display_name) ?? (model.slug as string),
|
||||
description: readOptionalString(model.description),
|
||||
effort: Array.isArray(model.supported_reasoning_levels) && model.supported_reasoning_levels.length > 0
|
||||
? {
|
||||
default: readOptionalString(model.default_reasoning_level) ?? undefined,
|
||||
values: model.supported_reasoning_levels
|
||||
.map((level) => {
|
||||
const value = readOptionalString(level?.effort);
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
const mapCodexModel = (model: CodexCachedModel): ProviderModelOption => {
|
||||
const effortValues = Array.isArray(model.supported_reasoning_levels)
|
||||
? model.supported_reasoning_levels
|
||||
.map((level) => {
|
||||
const value = readOptionalString(level?.effort);
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
value,
|
||||
description: readOptionalString(level?.description),
|
||||
};
|
||||
})
|
||||
.filter((level): level is NonNullable<typeof level> => Boolean(level)),
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
return {
|
||||
value,
|
||||
description: readOptionalString(level?.description),
|
||||
};
|
||||
})
|
||||
.filter((level): level is NonNullable<typeof level> => Boolean(level))
|
||||
: [];
|
||||
|
||||
return {
|
||||
value: model.slug as string,
|
||||
label: readOptionalString(model.display_name) ?? (model.slug as string),
|
||||
description: readOptionalString(model.description),
|
||||
effort: effortValues.length > 0
|
||||
? {
|
||||
default: readOptionalString(model.default_reasoning_level) ?? undefined,
|
||||
values: effortValues,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
};
|
||||
|
||||
const buildCodexModelsDefinition = (models: CodexCachedModel[]): ProviderModelsDefinition => {
|
||||
const sortedModels = [...models]
|
||||
|
||||
@@ -21,6 +21,8 @@ type ProviderCapabilities = {
|
||||
supportsPermissionRequests: boolean;
|
||||
/** Whether the token-usage endpoint has data for this provider. */
|
||||
supportsTokenUsage: boolean;
|
||||
/** Whether the provider runtime can accept model-level reasoning effort. */
|
||||
supportsEffort: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -38,6 +40,7 @@ const PROVIDER_CAPABILITIES: Record<LLMProvider, ProviderCapabilities> = {
|
||||
supportsAbort: true,
|
||||
supportsPermissionRequests: true,
|
||||
supportsTokenUsage: true,
|
||||
supportsEffort: true,
|
||||
},
|
||||
cursor: {
|
||||
provider: 'cursor',
|
||||
@@ -47,6 +50,7 @@ const PROVIDER_CAPABILITIES: Record<LLMProvider, ProviderCapabilities> = {
|
||||
supportsAbort: true,
|
||||
supportsPermissionRequests: false,
|
||||
supportsTokenUsage: false,
|
||||
supportsEffort: false,
|
||||
},
|
||||
codex: {
|
||||
provider: 'codex',
|
||||
@@ -56,6 +60,7 @@ const PROVIDER_CAPABILITIES: Record<LLMProvider, ProviderCapabilities> = {
|
||||
supportsAbort: true,
|
||||
supportsPermissionRequests: false,
|
||||
supportsTokenUsage: true,
|
||||
supportsEffort: true,
|
||||
},
|
||||
gemini: {
|
||||
provider: 'gemini',
|
||||
@@ -65,6 +70,7 @@ const PROVIDER_CAPABILITIES: Record<LLMProvider, ProviderCapabilities> = {
|
||||
supportsAbort: true,
|
||||
supportsPermissionRequests: false,
|
||||
supportsTokenUsage: true,
|
||||
supportsEffort: false,
|
||||
},
|
||||
opencode: {
|
||||
provider: 'opencode',
|
||||
@@ -74,6 +80,7 @@ const PROVIDER_CAPABILITIES: Record<LLMProvider, ProviderCapabilities> = {
|
||||
supportsAbort: true,
|
||||
supportsPermissionRequests: false,
|
||||
supportsTokenUsage: true,
|
||||
supportsEffort: false,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user