Skip to content

Commit f32dd69

Browse files
authored
Merge pull request #7 from ConnectAI-E/feature/plugin-artifact
Feature/plugin artifact
2 parents b590d08 + 80b8f95 commit f32dd69

File tree

8 files changed

+42
-43
lines changed

8 files changed

+42
-43
lines changed

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ For enterprise inquiries, please contact: **[email protected]**
9191
- [x] Desktop App with tauri
9292
- [x] Self-host Model: Fully compatible with [RWKV-Runner](https://github.com/josStorer/RWKV-Runner), as well as server deployment of [LocalAI](https://github.com/go-skynet/LocalAI): llama/gpt4all/rwkv/vicuna/koala/gpt4all-j/cerebras/falcon/dolly etc.
9393
- [x] Artifacts: Easily preview, copy and share generated content/webpages through a separate window [#5092](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/pull/5092)
94-
- [x] Plugins: support artifacts, network search, calculator, any other apis etc. [#165](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/165) [#5353](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/5353)
95-
- [x] artifacts
94+
- [x] Plugins: support network search, calculator, any other apis etc. [#165](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/165) [#5353](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/5353)
9695
- [x] network search, calculator, any other apis etc. [#165](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/165) [#5353](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/5353)
9796
- [ ] local knowledge base
9897

@@ -129,8 +128,7 @@ For enterprise inquiries, please contact: **[email protected]**
129128
- [x] 使用 tauri 打包桌面应用
130129
- [x] 支持自部署的大语言模型:开箱即用 [RWKV-Runner](https://github.com/josStorer/RWKV-Runner) ,服务端部署 [LocalAI 项目](https://github.com/go-skynet/LocalAI) llama / gpt4all / rwkv / vicuna / koala / gpt4all-j / cerebras / falcon / dolly 等等,或者使用 [api-for-open-llm](https://github.com/xusenlinzy/api-for-open-llm)
131130
- [x] Artifacts: 通过独立窗口,轻松预览、复制和分享生成的内容/可交互网页 [#5092](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/pull/5092)
132-
- [x] 插件机制,支持 artifacts,联网搜索、计算器、调用其他平台 api [#165](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/165) [#5353](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/5353)
133-
- [x] artifacts
131+
- [x] 插件机制,支持`联网搜索``计算器`、调用其他平台 api [#165](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/165) [#5353](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/5353)
134132
- [x] 支持联网搜索、计算器、调用其他平台 api [#165](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/165) [#5353](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/5353)
135133
- [ ] 本地知识库
136134

app/components/chat.tsx

+12-25
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ import {
9898
REQUEST_TIMEOUT_MS,
9999
UNFINISHED_INPUT,
100100
ServiceProvider,
101-
ArtifactsPlugin,
102101
} from "../constant";
103102
import { Avatar } from "./emoji";
104103
import { ContextPrompts, MaskAvatar, MaskConfig } from "./mask";
@@ -727,38 +726,26 @@ export function ChatActions(props: {
727726
/>
728727
)}
729728

730-
<ChatAction
731-
onClick={() => setShowPluginSelector(true)}
732-
text={Locale.Plugin.Name}
733-
icon={<PluginIcon />}
734-
/>
735-
{showPluginSelector && (
729+
{showPlugins(currentProviderName, currentModel) && (
730+
<ChatAction
731+
onClick={() => setShowPluginSelector(true)}
732+
text={Locale.Plugin.Name}
733+
icon={<PluginIcon />}
734+
/>
735+
)}
736+
{showPluginSelector && showPlugins(currentProviderName, currentModel) && (
736737
<Selector
737738
multiple
738739
defaultSelectedValue={chatStore.currentSession().mask?.plugin}
739-
items={[
740-
{
741-
title: Locale.Plugin.Artifacts,
742-
value: ArtifactsPlugin.Artifacts as string,
743-
},
744-
].concat(
745-
showPlugins(currentProviderName, currentModel)
746-
? pluginStore.getAll().map((item) => ({
747-
// @ts-ignore
748-
title: `${item?.title}@${item?.version}`,
749-
// @ts-ignore
750-
value: item?.id,
751-
}))
752-
: [],
753-
)}
740+
items={pluginStore.getAll().map((item) => ({
741+
title: `${item?.title}@${item?.version}`,
742+
value: item?.id,
743+
}))}
754744
onClose={() => setShowPluginSelector(false)}
755745
onSelection={(s) => {
756746
chatStore.updateCurrentSession((session) => {
757747
session.mask.plugin = s as string[];
758748
});
759-
if (s.includes(ArtifactsPlugin.Artifacts)) {
760-
showToast(ArtifactsPlugin.Artifacts);
761-
}
762749
}}
763750
/>
764751
)}

app/components/markdown.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
HTMLPreview,
2020
HTMLPreviewHander,
2121
} from "./artifacts";
22-
import { ArtifactsPlugin } from "../constant";
2322
import { useChatStore } from "../store";
2423
import { IconButton } from "./button";
2524

@@ -77,7 +76,6 @@ export function PreCode(props: { children: any }) {
7776
const { height } = useWindowSize();
7877
const chatStore = useChatStore();
7978
const session = chatStore.currentSession();
80-
const plugins = session.mask?.plugin;
8179

8280
const renderArtifacts = useDebouncedCallback(() => {
8381
if (!ref.current) return;
@@ -94,10 +92,7 @@ export function PreCode(props: { children: any }) {
9492
}
9593
}, 600);
9694

97-
const enableArtifacts = useMemo(
98-
() => plugins?.includes(ArtifactsPlugin.Artifacts),
99-
[plugins],
100-
);
95+
const enableArtifacts = session.mask?.enableArtifacts !== false;
10196

10297
//Wrap the paragraph for plain-text
10398
useEffect(() => {

app/components/mask.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,22 @@ export function MaskConfig(props: {
167167
></input>
168168
</ListItem>
169169

170+
<ListItem
171+
title={Locale.Mask.Config.Artifacts.Title}
172+
subTitle={Locale.Mask.Config.Artifacts.SubTitle}
173+
>
174+
<input
175+
aria-label={Locale.Mask.Config.Artifacts.Title}
176+
type="checkbox"
177+
checked={props.mask.enableArtifacts}
178+
onChange={(e) => {
179+
props.updateMask((mask) => {
180+
mask.enableArtifacts = e.currentTarget.checked;
181+
});
182+
}}
183+
></input>
184+
</ListItem>
185+
170186
{!props.shouldSyncFromGlobal ? (
171187
<ListItem
172188
title={Locale.Mask.Config.Share.Title}

app/constant.ts

-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ export enum FileName {
7373
Prompts = "prompts.json",
7474
}
7575

76-
export enum ArtifactsPlugin {
77-
Artifacts = "artifacts",
78-
}
79-
8076
export enum StoreKey {
8177
Chat = "chat-next-web-store",
8278
Plugin = "chat-next-web-plugin",

app/locales/cn.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ const cn = {
532532
},
533533
Plugin: {
534534
Name: "插件",
535-
Artifacts: "Artifacts",
536535
Page: {
537536
Title: "插件",
538537
SubTitle: (count: number) => `${count} 个插件`,
@@ -604,6 +603,10 @@ const cn = {
604603
Title: "隐藏预设对话",
605604
SubTitle: "隐藏后预设对话不会出现在聊天界面",
606605
},
606+
Artifacts: {
607+
Title: "启用Artifacts",
608+
SubTitle: "启用之后可以直接渲染HTML页面",
609+
},
607610
Share: {
608611
Title: "分享此面具",
609612
SubTitle: "生成此面具的直达链接",

app/locales/en.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@ const en: LocaleType = {
540540
},
541541
Plugin: {
542542
Name: "Plugin",
543-
Artifacts: "Artifacts",
544543
Page: {
545544
Title: "Plugins",
546545
SubTitle: (count: number) => `${count} plugins`,
@@ -613,6 +612,10 @@ const en: LocaleType = {
613612
Title: "Hide Context Prompts",
614613
SubTitle: "Do not show in-context prompts in chat",
615614
},
615+
Artifacts: {
616+
Title: "Enable Artifacts",
617+
SubTitle: "Can render HTML page when enable artifacts.",
618+
},
616619
Share: {
617620
Title: "Share This Mask",
618621
SubTitle: "Generate a link to this mask",

app/store/mask.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { BUILTIN_MASKS } from "../masks";
22
import { getLang, Lang } from "../locales";
33
import { DEFAULT_TOPIC, ChatMessage } from "./chat";
44
import { ModelConfig, useAppConfig } from "./config";
5-
import { StoreKey, ArtifactsPlugin } from "../constant";
5+
import { StoreKey } from "../constant";
66
import { nanoid } from "nanoid";
77
import { createPersistStore } from "../utils/store";
88

@@ -18,6 +18,7 @@ export type Mask = {
1818
lang: Lang;
1919
builtin: boolean;
2020
plugin?: string[];
21+
enableArtifacts?: boolean;
2122
};
2223

2324
export const DEFAULT_MASK_STATE = {
@@ -38,7 +39,7 @@ export const createEmptyMask = () =>
3839
lang: getLang(),
3940
builtin: false,
4041
createdAt: Date.now(),
41-
plugin: [ArtifactsPlugin.Artifacts as string],
42+
plugin: [],
4243
}) as Mask;
4344

4445
export const useMaskStore = createPersistStore(

0 commit comments

Comments
 (0)