mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 04:47:03 -06:00
fix: validate lmstudio discovered context lengths
This commit is contained in:
@@ -3,6 +3,7 @@ import { readProviderJsonArrayFieldResponse } from "openclaw/plugin-sdk/provider
|
||||
import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
||||
import { SELF_HOSTED_DEFAULT_COST } from "openclaw/plugin-sdk/provider-setup";
|
||||
import { fetchWithSsrFGuard, type SsrFPolicy } from "openclaw/plugin-sdk/ssrf-runtime";
|
||||
import { asPositiveSafeInteger } from "openclaw/plugin-sdk/string-coerce-runtime";
|
||||
import { LMSTUDIO_DEFAULT_LOAD_CONTEXT_LENGTH } from "./defaults.js";
|
||||
import {
|
||||
buildLmstudioModelName,
|
||||
@@ -214,18 +215,8 @@ export async function ensureLmstudioModelLoaded(params: {
|
||||
}
|
||||
const matchingModel = preflight.models.find((entry) => entry.key?.trim() === modelKey);
|
||||
const loadedContextWindow = matchingModel ? resolveLoadedContextWindow(matchingModel) : null;
|
||||
const advertisedContextLimit =
|
||||
matchingModel?.max_context_length !== undefined &&
|
||||
Number.isFinite(matchingModel.max_context_length) &&
|
||||
matchingModel.max_context_length > 0
|
||||
? Math.floor(matchingModel.max_context_length)
|
||||
: null;
|
||||
const requestedContextLength =
|
||||
params.requestedContextLength !== undefined &&
|
||||
Number.isFinite(params.requestedContextLength) &&
|
||||
params.requestedContextLength > 0
|
||||
? Math.floor(params.requestedContextLength)
|
||||
: null;
|
||||
const advertisedContextLimit = asPositiveSafeInteger(matchingModel?.max_context_length) ?? null;
|
||||
const requestedContextLength = asPositiveSafeInteger(params.requestedContextLength) ?? null;
|
||||
const contextLengthForLoad =
|
||||
advertisedContextLimit === null
|
||||
? (requestedContextLength ?? LMSTUDIO_DEFAULT_LOAD_CONTEXT_LENGTH)
|
||||
|
||||
Reference in New Issue
Block a user