mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-13 04:33:42 +08:00
feat: 支持开关指定内置插件
This commit is contained in:
32
app/plugins/cn.ts
Normal file
32
app/plugins/cn.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { BuiltinPlugin } from "./typing";
|
||||
|
||||
export const CN_PLUGINS: BuiltinPlugin[] = [
|
||||
{
|
||||
name: "搜索引擎",
|
||||
toolName: "web-search",
|
||||
lang: "cn",
|
||||
description: "搜索引擎的网络搜索功能工具。",
|
||||
builtin: true,
|
||||
createdAt: 1693744292000,
|
||||
enable: true,
|
||||
},
|
||||
{
|
||||
name: "计算器",
|
||||
toolName: "calculator",
|
||||
lang: "cn",
|
||||
description: "计算器是一个用于计算数学表达式的工具。",
|
||||
builtin: true,
|
||||
createdAt: 1693744292000,
|
||||
enable: true,
|
||||
},
|
||||
{
|
||||
name: "网页浏览器",
|
||||
toolName: "web-browser",
|
||||
lang: "cn",
|
||||
description:
|
||||
"一个用于与网页进行交互的工具,可以从网页中提取信息或总结其内容。",
|
||||
builtin: true,
|
||||
createdAt: 1693744292000,
|
||||
enable: true,
|
||||
},
|
||||
];
|
||||
33
app/plugins/en.ts
Normal file
33
app/plugins/en.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { BuiltinPlugin } from "./typing";
|
||||
|
||||
export const EN_PLUGINS: BuiltinPlugin[] = [
|
||||
{
|
||||
name: "WebSearch",
|
||||
toolName: "web-search",
|
||||
lang: "en",
|
||||
description: "Web search function tool for search engines.",
|
||||
builtin: true,
|
||||
createdAt: 1693744292000,
|
||||
enable: true,
|
||||
},
|
||||
{
|
||||
name: "Calculator",
|
||||
toolName: "calculator",
|
||||
lang: "en",
|
||||
description:
|
||||
"The Calculator class is a tool used to evaluate mathematical expressions. It extends the base Tool class.",
|
||||
builtin: true,
|
||||
createdAt: 1693744292000,
|
||||
enable: true,
|
||||
},
|
||||
{
|
||||
name: "WebBrowser",
|
||||
toolName: "web-browser",
|
||||
lang: "en",
|
||||
description:
|
||||
"A class designed to interact with web pages, either to extract information from them or to summarize their content.",
|
||||
builtin: true,
|
||||
createdAt: 1693744292000,
|
||||
enable: true,
|
||||
},
|
||||
];
|
||||
27
app/plugins/index.ts
Normal file
27
app/plugins/index.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Plugin } from "../store/plugin";
|
||||
import { CN_PLUGINS } from "./cn";
|
||||
import { EN_PLUGINS } from "./en";
|
||||
|
||||
import { type BuiltinPlugin } from "./typing";
|
||||
export { type BuiltinPlugin } from "./typing";
|
||||
|
||||
export const BUILTIN_PLUGIN_ID = 100000;
|
||||
|
||||
export const BUILTIN_PLUGIN_STORE = {
|
||||
buildinId: BUILTIN_PLUGIN_ID,
|
||||
plugins: {} as Record<string, BuiltinPlugin>,
|
||||
get(id?: string) {
|
||||
if (!id) return undefined;
|
||||
return this.plugins[id] as Plugin | undefined;
|
||||
},
|
||||
add(m: BuiltinPlugin) {
|
||||
const plugin = { ...m, id: this.buildinId++, builtin: true };
|
||||
this.plugins[plugin.id] = plugin;
|
||||
return plugin;
|
||||
},
|
||||
};
|
||||
|
||||
export const BUILTIN_PLUGINS: BuiltinPlugin[] = [
|
||||
...CN_PLUGINS,
|
||||
...EN_PLUGINS,
|
||||
].map((m) => BUILTIN_PLUGIN_STORE.add(m));
|
||||
5
app/plugins/typing.ts
Normal file
5
app/plugins/typing.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { type Plugin } from "../store/plugin";
|
||||
|
||||
export type BuiltinPlugin = Omit<Plugin, "id"> & {
|
||||
builtin: Boolean;
|
||||
};
|
||||
Reference in New Issue
Block a user