Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions frontend/src/locales/ar/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,10 @@ const TRANSLATIONS = {
icon: null,
link: null,
},
"render-html": {
title: null,
description: null,
},
},
},
"main-page": {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/da/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,10 @@ const TRANSLATIONS = {
icon: null,
link: null,
},
"render-html": {
title: null,
description: null,
},
},
},
"main-page": {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/de/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,10 @@ const TRANSLATIONS = {
icon: "Icon",
link: "Link",
},
"render-html": {
title: null,
description: null,
},
},
},
api: {
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/locales/en/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,11 @@ const TRANSLATIONS = {
icon: "Icon",
link: "Link",
},
"render-html": {
title: "Render HTML in chat",
description:
"Render HTML responses in assistant responses.\nThis can result in a much higher fidelity of response quality, but can also lead to potential security risks.",
},
},
},

Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/es/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ const TRANSLATIONS = {
icon: "Icono",
link: "Enlace",
},
"render-html": {
title: null,
description: null,
},
},
},
api: {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/et/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ const TRANSLATIONS = {
icon: "Ikoon",
link: "Link",
},
"render-html": {
title: null,
description: null,
},
},
},
api: {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/fa/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,10 @@ const TRANSLATIONS = {
icon: null,
link: null,
},
"render-html": {
title: null,
description: null,
},
},
},
"main-page": {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/fr/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,10 @@ const TRANSLATIONS = {
icon: null,
link: null,
},
"render-html": {
title: null,
description: null,
},
},
},
"main-page": {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/he/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,10 @@ const TRANSLATIONS = {
icon: "במל",
link: "Χ§Χ™Χ©Χ•Χ¨",
},
"render-html": {
title: null,
description: null,
},
},
},
api: {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/it/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,10 @@ const TRANSLATIONS = {
icon: null,
link: null,
},
"render-html": {
title: null,
description: null,
},
},
},
"main-page": {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/ja/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,10 @@ const TRANSLATIONS = {
icon: null,
link: null,
},
"render-html": {
title: null,
description: null,
},
},
},
"main-page": {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/ko/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ const TRANSLATIONS = {
icon: "μ•„μ΄μ½˜",
link: "링크",
},
"render-html": {
title: null,
description: null,
},
},
},
api: {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/lv/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,10 @@ const TRANSLATIONS = {
icon: "Ikona",
link: "Saite",
},
"render-html": {
title: null,
description: null,
},
},
},
api: {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/nl/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,10 @@ const TRANSLATIONS = {
icon: null,
link: null,
},
"render-html": {
title: null,
description: null,
},
},
},
"main-page": {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/pl/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,10 @@ const TRANSLATIONS = {
icon: "Ikona",
link: "Link",
},
"render-html": {
title: null,
description: null,
},
},
},
api: {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/pt_BR/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ const TRANSLATIONS = {
icon: "Ícone",
link: "Link",
},
"render-html": {
title: null,
description: null,
},
},
},
api: {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/ro/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,10 @@ const TRANSLATIONS = {
icon: "IconiΘ›Δƒ",
link: "Link",
},
"render-html": {
title: null,
description: null,
},
},
},
api: {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/ru/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,10 @@ const TRANSLATIONS = {
icon: null,
link: null,
},
"render-html": {
title: null,
description: null,
},
},
},
"main-page": {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/tr/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,10 @@ const TRANSLATIONS = {
icon: null,
link: null,
},
"render-html": {
title: null,
description: null,
},
},
},
"main-page": {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/vn/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,10 @@ const TRANSLATIONS = {
icon: null,
link: null,
},
"render-html": {
title: null,
description: null,
},
},
},
"main-page": {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/zh/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,10 @@ const TRANSLATIONS = {
icon: "ε›Ύζ ‡",
link: "ι“ΎζŽ₯",
},
"render-html": {
title: null,
description: null,
},
},
},
api: {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/zh_TW/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,10 @@ const TRANSLATIONS = {
icon: "εœ–η€Ί",
link: "連硐",
},
"render-html": {
title: null,
description: null,
},
},
},
"main-page": {
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/models/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { APPEARANCE_SETTINGS } from "@/utils/constants";
* @typedef { 'showScrollbar' |
* 'autoSubmitSttInput' |
* 'autoPlayAssistantTtsResponse' |
* 'enableSpellCheck'
* 'enableSpellCheck' |
* 'renderHTML'
* } AvailableSettings - The supported settings for the appearance model.
*/

Expand All @@ -14,11 +15,12 @@ const Appearance = {
autoSubmitSttInput: true,
autoPlayAssistantTtsResponse: false,
enableSpellCheck: true,
renderHTML: false,
},

/**
* Fetches any locally storage settings for the user
* @returns {{showScrollbar: boolean}}
* @returns {{showScrollbar: boolean, autoSubmitSttInput: boolean, autoPlayAssistantTtsResponse: boolean, enableSpellCheck: boolean, renderHTML: boolean}}
*/
getSettings: () => {
try {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/pages/GeneralSettings/Settings/Chat/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AutoSubmit from "../components/AutoSubmit";
import AutoSpeak from "../components/AutoSpeak";
import SpellCheck from "../components/SpellCheck";
import ShowScrollbar from "../components/ShowScrollbar";
import ChatRenderHTML from "../components/ChatRenderHTML";

export default function ChatSettings() {
const { t } = useTranslation();
Expand All @@ -31,6 +32,7 @@ export default function ChatSettings() {
<AutoSpeak />
<SpellCheck />
<ShowScrollbar />
<ChatRenderHTML />
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React, { useState, useEffect } from "react";
import Appearance from "@/models/appearance";
import { useTranslation } from "react-i18next";

export default function ChatRenderHTML() {
const { t } = useTranslation();
const [saving, setSaving] = useState(false);
const [renderHTML, setRenderHTML] = useState(false);

const handleChange = async (e) => {
const newValue = e.target.checked;
setRenderHTML(newValue);
setSaving(true);
try {
Appearance.updateSettings({ renderHTML: newValue });
} catch (error) {
console.error("Failed to update appearance settings:", error);
setRenderHTML(!newValue);
}
setSaving(false);
};

useEffect(() => {
function fetchSettings() {
const settings = Appearance.getSettings();
setRenderHTML(settings.renderHTML);
}
fetchSettings();
}, []);

return (
<div className="flex flex-col gap-y-0.5 my-4">
<p className="text-sm leading-6 font-semibold text-white">
{t("customization.items.render-html.title")}
</p>
<p className="text-xs text-white/60 w-1/2 whitespace-pre-line">
{t("customization.items.render-html.description")}
</p>
<div className="flex items-center gap-x-4 pt-1">
<label className="relative inline-flex cursor-pointer items-center">
<input
id="render_html"
type="checkbox"
name="render_html"
value="yes"
checked={renderHTML}
onChange={handleChange}
disabled={saving}
className="peer sr-only"
/>
<div className="pointer-events-none peer h-6 w-11 rounded-full bg-[#CFCFD0] after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:shadow-xl after:border-none after:bg-white after:box-shadow-md after:transition-all after:content-[''] peer-checked:bg-[#32D583] peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-transparent"></div>
</label>
</div>
</div>
);
}
3 changes: 2 additions & 1 deletion frontend/src/utils/chat/markdown.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { encode as HTMLEncode } from "he";
import markdownIt from "markdown-it";
import markdownItKatexPlugin from "./plugins/markdown-katex";
import Appearance from "@/models/appearance";
import hljs from "highlight.js";
import "./themes/github-dark.css";
import "./themes/github.css";
import { v4 } from "uuid";

const markdown = markdownIt({
html: false,
html: Appearance.get("renderHTML") ?? false,
typographer: true,
highlight: function (code, lang) {
const uuid = v4();
Expand Down