mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-04 06:52:47 +00:00
🩹 fix: Scoped Token-Config Fallback and Sequential Visibility for Usage Events
This commit is contained in:
parent
7489c2be8c
commit
84436aa688
2 changed files with 14 additions and 4 deletions
|
|
@ -30,8 +30,11 @@ async function tokenConfigController(req, res) {
|
|||
endpointTokenConfigs[name] = endpointConfig.tokenConfig;
|
||||
continue;
|
||||
}
|
||||
/** The models-config fetch path stores under the plain endpoint name;
|
||||
* chat initialization stores under the user-scoped key — accept either */
|
||||
const tokenKey = getTokenConfigKey(endpointConfig, name, req.user.id);
|
||||
const cached = await cache.get(tokenKey);
|
||||
const cached =
|
||||
(await cache.get(tokenKey)) ?? (tokenKey !== name ? await cache.get(name) : undefined);
|
||||
if (cached) {
|
||||
endpointTokenConfigs[name] = cached;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -464,12 +464,19 @@ function getDefaultHandlers({
|
|||
if (GraphEvents.ON_CONTEXT_USAGE) {
|
||||
handlers[GraphEvents.ON_CONTEXT_USAGE] = {
|
||||
/**
|
||||
* Forward per-model-call context usage snapshots to the client.
|
||||
* Forward per-model-call context usage snapshots to the client,
|
||||
* honoring the same sequential-agent visibility gate as deltas.
|
||||
* @param {string} event - The event name.
|
||||
* @param {StreamEventData} data - The event data.
|
||||
* @param {GraphRunnableConfig['configurable']} [metadata] The runnable metadata.
|
||||
*/
|
||||
handle: async (event, data) => {
|
||||
await emitEvent(res, streamId, { event, data });
|
||||
handle: async (event, data, metadata) => {
|
||||
if (
|
||||
checkIfLastAgent(metadata?.last_agent_id, metadata?.langgraph_node) ||
|
||||
!metadata?.hide_sequential_outputs
|
||||
) {
|
||||
await emitEvent(res, streamId, { event, data });
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue