mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-29 17:10:20 +09:00
feat: plugin filtering
This commit is contained in:
parent
a8e19a81ff
commit
a810ebea36
@ -76,6 +76,10 @@
|
||||
.plugin-info {
|
||||
font-size: 12px;
|
||||
}
|
||||
.plugin-runtime-warning {
|
||||
font-size: 12px;
|
||||
color: #f86c6c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,140 +44,7 @@ import { FileName, Path } from "../constant";
|
||||
import { BUILTIN_PLUGIN_STORE } from "../plugins";
|
||||
import { nanoid } from "nanoid";
|
||||
import { getISOLang, getLang } from "../locales";
|
||||
|
||||
// export function PluginConfig(props: {
|
||||
// plugin: Plugin;
|
||||
// updateMask: Updater<Plugin>;
|
||||
// extraListItems?: JSX.Element;
|
||||
// readonly?: boolean;
|
||||
// shouldSyncFromGlobal?: boolean;
|
||||
// }) {
|
||||
// const [showPicker, setShowPicker] = useState(false);
|
||||
|
||||
// const updateConfig = (updater: (config: ModelConfig) => void) => {
|
||||
// if (props.readonly) return;
|
||||
|
||||
// // const config = { ...props.mask.modelConfig };
|
||||
// // updater(config);
|
||||
// props.updateMask((mask) => {
|
||||
// // mask.modelConfig = config;
|
||||
// // // if user changed current session mask, it will disable auto sync
|
||||
// // mask.syncGlobalConfig = false;
|
||||
// });
|
||||
// };
|
||||
|
||||
// const globalConfig = useAppConfig();
|
||||
|
||||
// return (
|
||||
// <>
|
||||
// <ContextPrompts
|
||||
// context={props.mask.context}
|
||||
// updateContext={(updater) => {
|
||||
// const context = props.mask.context.slice();
|
||||
// updater(context);
|
||||
// props.updateMask((mask) => (mask.context = context));
|
||||
// }}
|
||||
// />
|
||||
|
||||
// <List>
|
||||
// <ListItem title={Locale.Mask.Config.Avatar}>
|
||||
// <Popover
|
||||
// content={
|
||||
// <AvatarPicker
|
||||
// onEmojiClick={(emoji) => {
|
||||
// props.updateMask((mask) => (mask.avatar = emoji));
|
||||
// setShowPicker(false);
|
||||
// }}
|
||||
// ></AvatarPicker>
|
||||
// }
|
||||
// open={showPicker}
|
||||
// onClose={() => setShowPicker(false)}
|
||||
// >
|
||||
// <div
|
||||
// onClick={() => setShowPicker(true)}
|
||||
// style={{ cursor: "pointer" }}
|
||||
// >
|
||||
// </div>
|
||||
// </Popover>
|
||||
// </ListItem>
|
||||
// <ListItem title={Locale.Mask.Config.Name}>
|
||||
// <input
|
||||
// type="text"
|
||||
// value={props.mask.name}
|
||||
// onInput={(e) =>
|
||||
// props.updateMask((mask) => {
|
||||
// mask.name = e.currentTarget.value;
|
||||
// })
|
||||
// }
|
||||
// ></input>
|
||||
// </ListItem>
|
||||
// <ListItem
|
||||
// title={Locale.Mask.Config.HideContext.Title}
|
||||
// subTitle={Locale.Mask.Config.HideContext.SubTitle}
|
||||
// >
|
||||
// <input
|
||||
// type="checkbox"
|
||||
// checked={props.mask.hideContext}
|
||||
// onChange={(e) => {
|
||||
// props.updateMask((mask) => {
|
||||
// mask.hideContext = e.currentTarget.checked;
|
||||
// });
|
||||
// }}
|
||||
// ></input>
|
||||
// </ListItem>
|
||||
|
||||
// {!props.shouldSyncFromGlobal ? (
|
||||
// <ListItem
|
||||
// title={Locale.Mask.Config.Share.Title}
|
||||
// subTitle={Locale.Mask.Config.Share.SubTitle}
|
||||
// >
|
||||
// <IconButton
|
||||
// icon={<CopyIcon />}
|
||||
// text={Locale.Mask.Config.Share.Action}
|
||||
// onClick={copyMaskLink}
|
||||
// />
|
||||
// </ListItem>
|
||||
// ) : null}
|
||||
|
||||
// {props.shouldSyncFromGlobal ? (
|
||||
// <ListItem
|
||||
// title={Locale.Mask.Config.Sync.Title}
|
||||
// subTitle={Locale.Mask.Config.Sync.SubTitle}
|
||||
// >
|
||||
// <input
|
||||
// type="checkbox"
|
||||
// checked={props.mask.syncGlobalConfig}
|
||||
// onChange={async (e) => {
|
||||
// const checked = e.currentTarget.checked;
|
||||
// if (
|
||||
// checked &&
|
||||
// (await showConfirm(Locale.Mask.Config.Sync.Confirm))
|
||||
// ) {
|
||||
// props.updateMask((mask) => {
|
||||
// mask.syncGlobalConfig = checked;
|
||||
// mask.modelConfig = { ...globalConfig.modelConfig };
|
||||
// });
|
||||
// } else if (!checked) {
|
||||
// props.updateMask((mask) => {
|
||||
// mask.syncGlobalConfig = checked;
|
||||
// });
|
||||
// }
|
||||
// }}
|
||||
// ></input>
|
||||
// </ListItem>
|
||||
// ) : null}
|
||||
// </List>
|
||||
|
||||
// <List>
|
||||
// <ModelConfigList
|
||||
// modelConfig={{ ...props.mask.modelConfig }}
|
||||
// updateConfig={updateConfig}
|
||||
// />
|
||||
// {props.extraListItems}
|
||||
// </List>
|
||||
// </>
|
||||
// );
|
||||
// }
|
||||
import { getServerSideConfig } from "../config/server";
|
||||
|
||||
function ContextPromptItem(props: {
|
||||
prompt: ChatMessage;
|
||||
@ -351,6 +218,8 @@ export function PluginPage() {
|
||||
});
|
||||
};
|
||||
|
||||
const serverConfig = getServerSideConfig();
|
||||
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
<div className={styles["plugin-page"]}>
|
||||
@ -371,22 +240,7 @@ export function PluginPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="window-actions">
|
||||
{/* <div className="window-action-button">
|
||||
<IconButton
|
||||
icon={<DownloadIcon />}
|
||||
bordered
|
||||
onClick={downloadAll}
|
||||
/>
|
||||
</div>
|
||||
<div className="window-action-button">
|
||||
<IconButton
|
||||
icon={<UploadIcon />}
|
||||
bordered
|
||||
onClick={() => importFromFile()}
|
||||
/>
|
||||
</div> */}
|
||||
</div>
|
||||
<div className="window-actions"></div>
|
||||
</div>
|
||||
|
||||
<div className={styles["plugin-page-body"]}>
|
||||
@ -398,17 +252,6 @@ export function PluginPage() {
|
||||
autoFocus
|
||||
onInput={(e) => onSearch(e.currentTarget.value)}
|
||||
/>
|
||||
|
||||
{/* <IconButton
|
||||
className={styles["mask-create"]}
|
||||
icon={<AddIcon />}
|
||||
text={Locale.Mask.Page.Create}
|
||||
bordered
|
||||
onClick={() => {
|
||||
const createdMask = pluginStore.create();
|
||||
setEditingMaskId(createdMask.id);
|
||||
}}
|
||||
/> */}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@ -417,6 +260,11 @@ export function PluginPage() {
|
||||
<div className={styles["plugin-header"]}>
|
||||
<div className={styles["plugin-title"]}>
|
||||
<div className={styles["plugin-name"]}>{m.name}</div>
|
||||
{m.onlyNodeRuntime && serverConfig.isVercel && (
|
||||
<div className={styles["plugin-runtime-warning"]}>
|
||||
{Locale.Plugin.RuntimeWarning}
|
||||
</div>
|
||||
)}
|
||||
{/* 描述 */}
|
||||
<div className={styles["plugin-info"] + " one-line"}>
|
||||
{`${m.description}`}
|
||||
@ -426,35 +274,12 @@ export function PluginPage() {
|
||||
<div className={styles["plugin-actions"]}>
|
||||
<input
|
||||
type="checkbox"
|
||||
disabled={m.onlyNodeRuntime && serverConfig.isVercel}
|
||||
checked={m.enable}
|
||||
onChange={(e) => {
|
||||
updatePluginEnableStatus(m.id, e.currentTarget.checked);
|
||||
}}
|
||||
></input>
|
||||
{/* {m.builtin ? (
|
||||
<IconButton
|
||||
icon={<EyeIcon />}
|
||||
text={Locale.Mask.Item.View}
|
||||
onClick={() => setEditingMaskId(m.id)}
|
||||
/>
|
||||
) : (
|
||||
<IconButton
|
||||
icon={<EditIcon />}
|
||||
text={Locale.Mask.Item.Edit}
|
||||
onClick={() => setEditingMaskId(m.id)}
|
||||
/>
|
||||
)}
|
||||
{!m.builtin && (
|
||||
<IconButton
|
||||
icon={<DeleteIcon />}
|
||||
text={Locale.Mask.Item.Delete}
|
||||
onClick={async () => {
|
||||
if (await showConfirm(Locale.Mask.Item.DeleteConfirm)) {
|
||||
maskStore.delete(m.id);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)} */}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
@ -481,15 +306,7 @@ export function PluginPage() {
|
||||
}
|
||||
/>,
|
||||
]}
|
||||
>
|
||||
{/* <PluginConfig
|
||||
plugin={editingPlugin}
|
||||
updatePlugin={(updater) =>
|
||||
pluginStore.update(editingPluginId!, updater)
|
||||
}
|
||||
readonly={editingPlugin.builtin}
|
||||
/> */}
|
||||
</Modal>
|
||||
></Modal>
|
||||
</div>
|
||||
)}
|
||||
</ErrorBoundary>
|
||||
|
@ -403,6 +403,7 @@ const cn = {
|
||||
Download: "下载预设",
|
||||
Clone: "克隆预设",
|
||||
},
|
||||
RuntimeWarning: "仅在非Vercel环境部署时可用",
|
||||
},
|
||||
FineTuned: {
|
||||
Sysmessage: "你是一个助手",
|
||||
|
@ -409,6 +409,7 @@ const en: LocaleType = {
|
||||
Download: "Download",
|
||||
Clone: "Clone",
|
||||
},
|
||||
RuntimeWarning: "Only available when deployed in a non-Vercel environment.",
|
||||
},
|
||||
FineTuned: {
|
||||
Sysmessage: "You are an assistant that",
|
||||
|
@ -9,6 +9,7 @@ export const CN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1693744292000,
|
||||
enable: true,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "计算器",
|
||||
@ -18,6 +19,7 @@ export const CN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1693744292000,
|
||||
enable: true,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "网页浏览器",
|
||||
@ -28,6 +30,7 @@ export const CN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1693744292000,
|
||||
enable: true,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "维基百科",
|
||||
@ -37,6 +40,7 @@ export const CN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1694235989000,
|
||||
enable: false,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "DALL·E",
|
||||
@ -47,6 +51,7 @@ export const CN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1694703673000,
|
||||
enable: false,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "Stable Diffusion",
|
||||
@ -57,6 +62,7 @@ export const CN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1688899480510,
|
||||
enable: false,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "Arxiv",
|
||||
@ -66,5 +72,16 @@ export const CN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1699265115000,
|
||||
enable: false,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "PDF浏览器",
|
||||
toolName: "pdf-browser",
|
||||
lang: "cn",
|
||||
description: "可以从pdf文件的url中提取信息或总结其内容。",
|
||||
builtin: true,
|
||||
createdAt: 1700907315000,
|
||||
enable: false,
|
||||
onlyNodeRuntime: true,
|
||||
},
|
||||
];
|
||||
|
@ -9,6 +9,7 @@ export const EN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1693744292000,
|
||||
enable: true,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "Calculator",
|
||||
@ -19,6 +20,7 @@ export const EN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1693744292000,
|
||||
enable: true,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "WebBrowser",
|
||||
@ -29,6 +31,7 @@ export const EN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1693744292000,
|
||||
enable: true,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "Wikipedia",
|
||||
@ -39,6 +42,7 @@ export const EN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1694235989000,
|
||||
enable: false,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "DALL·E",
|
||||
@ -49,6 +53,7 @@ export const EN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1694703673000,
|
||||
enable: false,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "Stable Diffusion",
|
||||
@ -59,6 +64,7 @@ export const EN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1688899480510,
|
||||
enable: false,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "Arxiv",
|
||||
@ -68,5 +74,17 @@ export const EN_PLUGINS: BuiltinPlugin[] = [
|
||||
builtin: true,
|
||||
createdAt: 1699265115000,
|
||||
enable: false,
|
||||
onlyNodeRuntime: false,
|
||||
},
|
||||
{
|
||||
name: "PDFBrowser",
|
||||
toolName: "pdf-browser",
|
||||
lang: "en",
|
||||
description:
|
||||
"A class designed to interact with pdf file, extract information from the URL of a PDF file or summarize its content.",
|
||||
builtin: true,
|
||||
createdAt: 1700907315000,
|
||||
enable: false,
|
||||
onlyNodeRuntime: true,
|
||||
},
|
||||
];
|
||||
|
@ -16,6 +16,7 @@ export type Plugin = {
|
||||
description: string;
|
||||
builtin: boolean;
|
||||
enable: boolean;
|
||||
onlyNodeRuntime: boolean;
|
||||
};
|
||||
|
||||
export const DEFAULT_PLUGIN_STATE = {
|
||||
@ -43,7 +44,7 @@ export const createEmptyPlugin = () =>
|
||||
builtin: false,
|
||||
createdAt: Date.now(),
|
||||
enable: true,
|
||||
} as Plugin);
|
||||
}) as Plugin;
|
||||
|
||||
export const usePluginStore = create<PluginStore>()(
|
||||
persist(
|
||||
@ -99,7 +100,7 @@ export const usePluginStore = create<PluginStore>()(
|
||||
(m) =>
|
||||
({
|
||||
...m,
|
||||
} as Plugin),
|
||||
}) as Plugin,
|
||||
);
|
||||
const pluginStatuses = get().pluginStatuses;
|
||||
return userPlugins.concat(buildinPlugins).map((e) => {
|
||||
|
Loading…
Reference in New Issue
Block a user