mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-07 00:15:23 +02:00
fix: persist modelLabel to DB and derive from spec as fallback
All chat (including bedrock specs) goes through /api/agents/chat/:endpoint. The buildOptions middleware nests conversation settings inside model_parameters, then the AgentClient constructor was never given modelLabel — so getSaveOptions() always returned modelLabel: undefined, which was stripped by removeNullishValues. The field was never saved to the database, so every page refresh lost it. Two fixes: 1. api/server/services/Endpoints/agents/initialize.js (backend — the real bug) Pass modelLabel from model_parameters to the AgentClient constructor, so it gets persisted to the conversation in MongoDB. 2. client/src/hooks/Conversations/useGetSender.ts (frontend — defensive fallback) When a loaded conversation has a spec but no modelLabel (older conversations that were saved before this fix), derive the display label from the spec configuration instead of falling back to "AWS Bedrock". Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5b31bb720d
commit
4d93a55975
2 changed files with 10 additions and 3 deletions
|
|
@ -441,6 +441,7 @@ const initializeClient = async ({ req, res, signal, endpointOption }) => {
|
|||
endpointType: endpointOption.endpointType,
|
||||
resendFiles: primaryConfig.resendFiles ?? true,
|
||||
maxContextTokens: primaryConfig.maxContextTokens,
|
||||
modelLabel: endpointOption.model_parameters?.modelLabel,
|
||||
endpoint: isEphemeralAgentId(primaryConfig.id) ? primaryConfig.endpoint : EModelEndpoint.agents,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,21 @@
|
|||
import { useCallback } from 'react';
|
||||
import { getResponseSender } from 'librechat-data-provider';
|
||||
import type { TEndpointOption, TEndpointsConfig } from 'librechat-data-provider';
|
||||
import { useGetEndpointsQuery } from '~/data-provider';
|
||||
import { useGetEndpointsQuery, useGetStartupConfig } from '~/data-provider';
|
||||
|
||||
export default function useGetSender() {
|
||||
const { data: endpointsConfig = {} as TEndpointsConfig } = useGetEndpointsQuery();
|
||||
const { data: startupConfig } = useGetStartupConfig();
|
||||
return useCallback(
|
||||
(endpointOption: TEndpointOption) => {
|
||||
const { modelDisplayLabel } = endpointsConfig?.[endpointOption.endpoint ?? ''] ?? {};
|
||||
return getResponseSender({ ...endpointOption, modelDisplayLabel });
|
||||
let { modelLabel } = endpointOption;
|
||||
if (!modelLabel && endpointOption.spec) {
|
||||
const spec = startupConfig?.modelSpecs?.list?.find((s) => s.name === endpointOption.spec);
|
||||
modelLabel = spec?.preset?.modelLabel ?? spec?.label ?? null;
|
||||
}
|
||||
return getResponseSender({ ...endpointOption, modelLabel, modelDisplayLabel });
|
||||
},
|
||||
[endpointsConfig],
|
||||
[endpointsConfig, startupConfig],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue