mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-30 23:28:52 +01:00
🔧 refactor: Display name logic in Parallel Responses (#11149)
- Removed the use of `getResponseSender` for computing display names in both `Agent.js` and `loadAddedAgent.js`. - Implemented fallback logic to derive display names from `modelLabel`, `modelSpec.label`, and `endpointConfig.modelDisplayLabel`. - Enhanced comments for clarity on the new display name resolution process. - Updated `useChatFunctions` and `createDualMessageContent` to accommodate changes in sender logic, ensuring consistent handling of ephemeral agents across the application.
This commit is contained in:
parent
c7469ce884
commit
dcda6a249c
4 changed files with 46 additions and 29 deletions
|
|
@ -4,7 +4,6 @@ const {
|
|||
Tools,
|
||||
Constants,
|
||||
isAgentsEndpoint,
|
||||
getResponseSender,
|
||||
isEphemeralAgentId,
|
||||
appendAgentIdSuffix,
|
||||
encodeEphemeralAgentId,
|
||||
|
|
@ -81,7 +80,7 @@ const loadAddedAgent = async ({ req, conversation, primaryAgent }) => {
|
|||
// If both primary and added agents are ephemeral, duplicate tools from primary agent
|
||||
const primaryIsEphemeral = primaryAgent && isEphemeralAgentId(primaryAgent.id);
|
||||
if (primaryIsEphemeral && Array.isArray(primaryAgent.tools)) {
|
||||
// Get display name using getResponseSender
|
||||
// Get endpoint config and model spec for display name fallbacks
|
||||
const appConfig = req.config;
|
||||
let endpointConfig = appConfig?.endpoints?.[endpoint];
|
||||
if (!isAgentsEndpoint(endpoint) && !endpointConfig) {
|
||||
|
|
@ -92,10 +91,13 @@ const loadAddedAgent = async ({ req, conversation, primaryAgent }) => {
|
|||
}
|
||||
}
|
||||
|
||||
const sender = getResponseSender({
|
||||
modelLabel: rest.modelLabel,
|
||||
modelDisplayLabel: endpointConfig?.modelDisplayLabel,
|
||||
});
|
||||
// Look up model spec for label fallback
|
||||
const modelSpecs = appConfig?.modelSpecs?.list;
|
||||
const modelSpec = spec != null && spec !== '' ? modelSpecs?.find((s) => s.name === spec) : null;
|
||||
|
||||
// For ephemeral agents, use modelLabel if provided, then model spec's label,
|
||||
// then modelDisplayLabel from endpoint config, otherwise empty string to show model name
|
||||
const sender = rest.modelLabel ?? modelSpec?.label ?? endpointConfig?.modelDisplayLabel ?? '';
|
||||
|
||||
const ephemeralId = encodeEphemeralAgentId({ endpoint, model, sender, index: 1 });
|
||||
|
||||
|
|
@ -175,7 +177,7 @@ const loadAddedAgent = async ({ req, conversation, primaryAgent }) => {
|
|||
}
|
||||
}
|
||||
|
||||
// Get endpoint config for modelDisplayLabel (same pattern as initialize.js)
|
||||
// Get endpoint config for modelDisplayLabel fallback
|
||||
const appConfig = req.config;
|
||||
let endpointConfig = appConfig?.endpoints?.[endpoint];
|
||||
if (!isAgentsEndpoint(endpoint) && !endpointConfig) {
|
||||
|
|
@ -186,11 +188,9 @@ const loadAddedAgent = async ({ req, conversation, primaryAgent }) => {
|
|||
}
|
||||
}
|
||||
|
||||
// Compute display name using getResponseSender (same logic used for main agent)
|
||||
const sender = getResponseSender({
|
||||
modelLabel: rest.modelLabel,
|
||||
modelDisplayLabel: endpointConfig?.modelDisplayLabel,
|
||||
});
|
||||
// For ephemeral agents, use modelLabel if provided, then model spec's label,
|
||||
// then modelDisplayLabel from endpoint config, otherwise empty string to show model name
|
||||
const sender = rest.modelLabel ?? modelSpec?.label ?? endpointConfig?.modelDisplayLabel ?? '';
|
||||
|
||||
/** Encoded ephemeral agent ID with endpoint, model, sender, and index=1 to distinguish from primary */
|
||||
const ephemeralId = encodeEphemeralAgentId({ endpoint, model, sender, index: 1 });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue