mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-13 14:08:51 +01:00
⌚ feat: Add Current Datetime to Assistants (v1/v2) (#4952)
* Feature: Added ability to send current date and time to v1 and v2 assistants * remove date_feature.patch * fix: rename append_today_date to append_current_datetime * feat: Refactor time handling in chatV1 and chatV2, add date and time utility functions * fix: Add warning log and response for missing run values in abortRun middleware --------- Co-authored-by: Max Sanna <max@maxsanna.com>
This commit is contained in:
parent
b5c9144127
commit
1dbe6ee75d
38 changed files with 378 additions and 67 deletions
|
|
@ -0,0 +1,76 @@
|
|||
import { Control, Controller, UseFormSetValue, UseFormGetValues } from 'react-hook-form';
|
||||
import { CircleHelpIcon } from '~/components/svg';
|
||||
import { useLocalize } from '~/hooks';
|
||||
import {
|
||||
HoverCard,
|
||||
HoverCardContent,
|
||||
HoverCardPortal,
|
||||
HoverCardTrigger,
|
||||
Checkbox,
|
||||
} from '~/components/ui';
|
||||
import { ESide } from '~/common';
|
||||
import type { AssistantForm } from '~/common';
|
||||
|
||||
interface AppendDateCheckboxProps {
|
||||
control: Control<AssistantForm>;
|
||||
setValue: UseFormSetValue<AssistantForm>;
|
||||
getValues: UseFormGetValues<AssistantForm>;
|
||||
}
|
||||
|
||||
export default function AppendDateCheckbox({ control, setValue }: AppendDateCheckboxProps) {
|
||||
const localize = useLocalize();
|
||||
|
||||
const handleChange = (checked: boolean) => {
|
||||
setValue('append_current_datetime', checked, {
|
||||
shouldDirty: true,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="mb-6">
|
||||
<HoverCard openDelay={50}>
|
||||
<div className="flex items-center">
|
||||
<Controller
|
||||
name="append_current_datetime"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Checkbox
|
||||
{...field}
|
||||
id="append_current_datetime"
|
||||
checked={field.value}
|
||||
onCheckedChange={handleChange}
|
||||
className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"
|
||||
value={field.value.toString()}
|
||||
aria-labelledby="append-date-label"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<div className="flex items-center space-x-2">
|
||||
<label
|
||||
id="append-date-label"
|
||||
htmlFor="append_current_datetime"
|
||||
className="form-check-label text-token-text-primary w-full cursor-pointer"
|
||||
>
|
||||
{localize('com_assistants_append_date')}
|
||||
</label>
|
||||
<HoverCardTrigger>
|
||||
<CircleHelpIcon
|
||||
className="h-5 w-5 text-gray-500"
|
||||
aria-label={localize('com_assistants_append_date_tooltip')}
|
||||
/>
|
||||
</HoverCardTrigger>
|
||||
</div>
|
||||
<HoverCardPortal>
|
||||
<HoverCardContent side={ESide.Top} className="w-80">
|
||||
<div className="space-y-2">
|
||||
<p className="text-sm text-gray-600 dark:text-gray-300">
|
||||
{localize('com_assistants_append_date_tooltip')}
|
||||
</p>
|
||||
</div>
|
||||
</HoverCardContent>
|
||||
</HoverCardPortal>
|
||||
</div>
|
||||
</HoverCard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue