mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
add buttons to custom model menu items
This commit is contained in:
parent
6d757ff91f
commit
191118b90b
4 changed files with 41 additions and 8 deletions
|
|
@ -2,11 +2,14 @@ import React from 'react';
|
||||||
import RenameIcon from '../svg/RenameIcon';
|
import RenameIcon from '../svg/RenameIcon';
|
||||||
import CheckMark from '../svg/CheckMark';
|
import CheckMark from '../svg/CheckMark';
|
||||||
|
|
||||||
export default function RenameButton({ renaming, renameHandler, onRename }) {
|
export default function RenameButton({ renaming, renameHandler, onRename, twcss }) {
|
||||||
const handler = renaming ? onRename : renameHandler;
|
const handler = renaming ? onRename : renameHandler;
|
||||||
|
const classProp = { className: "p-1 hover:text-white" };
|
||||||
|
if (twcss) {
|
||||||
|
classProp.className = twcss;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<button className="p-1 hover:text-white" onClick={handler}>
|
<button {...classProp} onClick={handler}>
|
||||||
{renaming ? <CheckMark /> : <RenameIcon />}
|
{renaming ? <CheckMark /> : <RenameIcon />}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ export default function ModelDialog({ mutate, modelMap, setModelSave, handleSave
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [chatGptLabel, setChatGptLabel] = useState('');
|
const [chatGptLabel, setChatGptLabel] = useState('');
|
||||||
const [promptPrefix, setPromptPrefix] = useState('');
|
const [promptPrefix, setPromptPrefix] = useState('');
|
||||||
|
|
||||||
const [saveText, setSaveText] = useState('Save');
|
const [saveText, setSaveText] = useState('Save');
|
||||||
const [required, setRequired] = useState(false);
|
const [required, setRequired] = useState(false);
|
||||||
const inputRef = useRef(null);
|
const inputRef = useRef(null);
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,20 @@
|
||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import { useSelector } from 'react-redux';
|
||||||
import { DropdownMenuRadioItem } from '../ui/DropdownMenu.tsx';
|
import { DropdownMenuRadioItem } from '../ui/DropdownMenu.tsx';
|
||||||
import { DialogTrigger } from '../ui/Dialog.tsx';
|
import { DialogTrigger } from '../ui/Dialog.tsx';
|
||||||
|
import RenameButton from '../Conversations/RenameButton';
|
||||||
|
import TrashIcon from '../svg/TrashIcon';
|
||||||
|
|
||||||
export default function ModelItem({ modelName, value }) {
|
export default function ModelItem({ modelName, value }) {
|
||||||
|
const { initial } = useSelector((state) => state.models);
|
||||||
|
const [isHovering, setIsHovering] = useState(false);
|
||||||
|
|
||||||
if (value === 'chatgptCustom') {
|
if (value === 'chatgptCustom') {
|
||||||
return (
|
return (
|
||||||
<DialogTrigger className="w-full">
|
<DialogTrigger className="w-full">
|
||||||
<DropdownMenuRadioItem
|
<DropdownMenuRadioItem
|
||||||
value={value}
|
value={value}
|
||||||
className="dark:font-semibold dark:hover:bg-gray-800 dark:text-gray-100"
|
className="dark:font-semibold dark:text-gray-100 dark:hover:bg-gray-800"
|
||||||
>
|
>
|
||||||
{modelName}
|
{modelName}
|
||||||
<sup>$</sup>
|
<sup>$</sup>
|
||||||
|
|
@ -17,13 +23,39 @@ export default function ModelItem({ modelName, value }) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleMouseOver = () => {
|
||||||
|
setIsHovering(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMouseOut = () => {
|
||||||
|
setIsHovering(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttonClass = {
|
||||||
|
className:
|
||||||
|
'rounded-md m-0 text-gray-400 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'
|
||||||
|
};
|
||||||
|
|
||||||
|
const showButtons = isHovering && !initial[value];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenuRadioItem
|
<DropdownMenuRadioItem
|
||||||
value={value}
|
value={value}
|
||||||
className="dark:font-semibold dark:hover:bg-gray-800 dark:text-gray-100"
|
className="dark:font-semibold dark:text-gray-100 dark:hover:bg-gray-800"
|
||||||
|
onMouseOver={handleMouseOver}
|
||||||
|
onMouseOut={handleMouseOut}
|
||||||
>
|
>
|
||||||
{modelName}
|
{modelName}
|
||||||
{value === 'chatgpt' && <sup>$</sup>}
|
{value === 'chatgpt' && <sup>$</sup>}
|
||||||
|
|
||||||
|
{showButtons && (
|
||||||
|
<>
|
||||||
|
<RenameButton twcss={`ml-auto mr-2 ${buttonClass.className}`} />
|
||||||
|
<button {...buttonClass}>
|
||||||
|
<TrashIcon />
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</DropdownMenuRadioItem>
|
</DropdownMenuRadioItem>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import { Dialog } from '../ui/Dialog.tsx';
|
||||||
export default function ModelMenu() {
|
export default function ModelMenu() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [modelSave, setModelSave] = useState(false);
|
const [modelSave, setModelSave] = useState(false);
|
||||||
// const [dialogOpen, setDialogOpen] = useState(false);
|
|
||||||
const { model, customModel } = useSelector((state) => state.submit);
|
const { model, customModel } = useSelector((state) => state.submit);
|
||||||
const { models, modelMap, initial } = useSelector((state) => state.models);
|
const { models, modelMap, initial } = useSelector((state) => state.models);
|
||||||
const { trigger } = manualSWR(`http://localhost:3080/api/customGpts`, 'get', (res) => {
|
const { trigger } = manualSWR(`http://localhost:3080/api/customGpts`, 'get', (res) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue