mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 05:52:10 +00:00
* 🖼️ fix: Apply an Agent's Configured Image Detail The Agent Builder exposes an Image Detail slider and saves it to `model_parameters.imageDetail`, but nothing ever read it back: `encodeAndFormat` resolves the level from `req.body.imageDetail`, which the agents route never populates, so every image was encoded as `detail: "auto"`. Providers that reject `auto` — MiniMax's OpenAI-compatible API among them — fail every image upload through an agent, and the setting that would fix it has no effect. The root cause is a classification error rather than a missing argument. `extractLibreChatParams` splits LibreChat's own settings out of an agent's model parameters, and its key set is derived from the `librechat` group in `parameterSettings`. `imageDetail` sat in `baseDefinitions` instead, so it was neither extracted for LibreChat's use nor stripped from the options handed to the provider. It is now grouped with `resendFiles` and the other LibreChat-level parameters, which gives it the same path those already take: extracted during agent initialization, carried on the initialized agent, passed to the client, and read by `encodeAndFormat`. `AgentClient.getSaveOptions` already expected `options.imageDetail` — nothing had ever populated it. The request body still wins where it is set, so the classic endpoints keep resolving detail from conversation settings exactly as before. Fixes #15359 * 🔤 fix: Type Image Detail as Its Enum, Not a Bare String `TConversation.imageDetail` is the `ImageDetail` enum, so the extractor's return type and the initialized agent's field are now declared as that enum rather than widened to `string`, and the tests pass enum members instead of raw literals. Caught by CI's type check, which I had run before adding the tests and not after — jest compiles the specs through babel, so the suite stayed green over a type error.
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import { librechat } from 'librechat-data-provider';
|
|
import type { DynamicSettingProps, ImageDetail } from 'librechat-data-provider';
|
|
|
|
type LibreChatKeys = keyof typeof librechat;
|
|
|
|
type LibreChatParams = {
|
|
modelOptions: Omit<NonNullable<DynamicSettingProps['conversation']>, LibreChatKeys>;
|
|
resendFiles: boolean;
|
|
promptPrefix?: string | null;
|
|
maxContextTokens?: number;
|
|
fileTokenLimit?: number;
|
|
modelLabel?: string | null;
|
|
imageDetail?: ImageDetail;
|
|
};
|
|
|
|
/**
|
|
* Separates LibreChat-specific parameters from model options
|
|
* @param options - The combined options object
|
|
*/
|
|
export function extractLibreChatParams(
|
|
options?: DynamicSettingProps['conversation'],
|
|
): LibreChatParams {
|
|
if (!options) {
|
|
return {
|
|
modelOptions: {} as Omit<NonNullable<DynamicSettingProps['conversation']>, LibreChatKeys>,
|
|
resendFiles: librechat.resendFiles.default as boolean,
|
|
};
|
|
}
|
|
|
|
const modelOptions = { ...options };
|
|
|
|
const resendFiles =
|
|
(delete modelOptions.resendFiles, options.resendFiles) ??
|
|
(librechat.resendFiles.default as boolean);
|
|
const promptPrefix = (delete modelOptions.promptPrefix, options.promptPrefix);
|
|
const maxContextTokens = (delete modelOptions.maxContextTokens, options.maxContextTokens);
|
|
const fileTokenLimit = (delete modelOptions.fileTokenLimit, options.fileTokenLimit);
|
|
const modelLabel = (delete modelOptions.modelLabel, options.modelLabel);
|
|
const imageDetail = (delete modelOptions.imageDetail, options.imageDetail);
|
|
|
|
return {
|
|
modelOptions: modelOptions as Omit<
|
|
NonNullable<DynamicSettingProps['conversation']>,
|
|
LibreChatKeys
|
|
>,
|
|
maxContextTokens,
|
|
fileTokenLimit,
|
|
promptPrefix,
|
|
resendFiles,
|
|
modelLabel,
|
|
imageDetail,
|
|
};
|
|
}
|