mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-07 08:25:23 +02:00
🕐 fix: Use client timezone for special variable date formatting
`replaceSpecialVars` uses `dayjs()` which defaults to the server's
timezone (UTC in Docker), causing `{{current_datetime}}` and
`{{current_date}}` to always show +00:00 regardless of the user's
location. This is inconsistent with `append_current_datetime` for
assistants which already handles client timezone via `clientTimestamp`.
Add dayjs timezone plugin support and a `timezone` parameter to
`replaceSpecialVars`. The client sends its IANA timezone string
(`Intl.DateTimeFormat().resolvedOptions().timeZone`) alongside the
existing `clientTimestamp`, and the agent initialization flow passes
it through to produce timezone-aware date formatting.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f277b32030
commit
736960e0a4
6 changed files with 86 additions and 4 deletions
|
|
@ -403,6 +403,7 @@ export async function initializeAgent(
|
|||
agent.instructions = replaceSpecialVars({
|
||||
text: agent.instructions,
|
||||
user: req.user ? (req.user as unknown as TUser) : null,
|
||||
timezone: req.body?.clientTimezone,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export type RequestBody = {
|
|||
model?: string;
|
||||
key?: string;
|
||||
endpointOption?: Partial<TEndpointOption>;
|
||||
clientTimezone?: string;
|
||||
};
|
||||
|
||||
export type ServerRequest = Request<unknown, unknown, RequestBody> & {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue