File size: 1,273 Bytes
f0743f4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | import { CopyPlus } from 'lucide-react';
import { useToastContext, Button } from '@librechat/client';
import { useDuplicateAgentMutation } from '~/data-provider';
import { isEphemeralAgent } from '~/common';
import { useLocalize } from '~/hooks';
export default function DuplicateAgent({ agent_id }: { agent_id: string }) {
const localize = useLocalize();
const { showToast } = useToastContext();
const duplicateAgent = useDuplicateAgentMutation({
onSuccess: () => {
showToast({
message: localize('com_ui_agent_duplicated'),
status: 'success',
});
},
onError: (error) => {
console.error(error);
showToast({
message: localize('com_ui_agent_duplicate_error'),
status: 'error',
});
},
});
if (isEphemeralAgent(agent_id)) {
return null;
}
const handleDuplicate = () => {
duplicateAgent.mutate({ agent_id });
};
return (
<Button
size="sm"
variant="outline"
aria-label={localize('com_ui_duplicate') + ' ' + localize('com_ui_agent')}
type="button"
onClick={handleDuplicate}
>
<div className="flex w-full items-center justify-center gap-2 text-primary">
<CopyPlus className="size-4" />
</div>
</Button>
);
}
|