Spaces:
Sleeping
Sleeping
Strip code fences from debug
Browse files- src/App.js +9 -1
src/App.js
CHANGED
|
@@ -938,6 +938,14 @@ function App() {
|
|
| 938 |
function Message({ message }) {
|
| 939 |
const isUser = message.role === "user";
|
| 940 |
const [showDebug, setShowDebug] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 941 |
const normalizedText = React.useMemo(
|
| 942 |
() => normalizeLatex(message.text || ""),
|
| 943 |
[message.text]
|
|
@@ -998,7 +1006,7 @@ function Message({ message }) {
|
|
| 998 |
overflowX: "auto",
|
| 999 |
color: "#1a1a1a"
|
| 1000 |
}}>
|
| 1001 |
-
{message.debug.llm_analysis}
|
| 1002 |
</pre>
|
| 1003 |
</div>
|
| 1004 |
)}
|
|
|
|
| 938 |
function Message({ message }) {
|
| 939 |
const isUser = message.role === "user";
|
| 940 |
const [showDebug, setShowDebug] = useState(false);
|
| 941 |
+
const stripMarkdownFences = React.useCallback((text) => {
|
| 942 |
+
if (typeof text !== "string") return "";
|
| 943 |
+
// Remove triple-backtick fences like ```json ... ``` (common in LLM outputs).
|
| 944 |
+
return text
|
| 945 |
+
.replace(/```\s*json\s*/gi, "")
|
| 946 |
+
.replace(/```/g, "")
|
| 947 |
+
.trim();
|
| 948 |
+
}, []);
|
| 949 |
const normalizedText = React.useMemo(
|
| 950 |
() => normalizeLatex(message.text || ""),
|
| 951 |
[message.text]
|
|
|
|
| 1006 |
overflowX: "auto",
|
| 1007 |
color: "#1a1a1a"
|
| 1008 |
}}>
|
| 1009 |
+
{stripMarkdownFences(message.debug.llm_analysis)}
|
| 1010 |
</pre>
|
| 1011 |
</div>
|
| 1012 |
)}
|