fraudTech commited on
Commit
a3118ff
·
verified ·
1 Parent(s): cca6315

Update src/App.js

Browse files
Files changed (1) hide show
  1. src/App.js +14 -2
src/App.js CHANGED
@@ -4,6 +4,12 @@ import React, { useState } from "react";
4
  import { sendChat, login } from "./api";
5
  import "./App.css";
6
 
 
 
 
 
 
 
7
  function App() {
8
  // ---------------------------
9
  // Authentication State
@@ -185,6 +191,7 @@ function App() {
185
  // ============================================================
186
  // MESSAGE COMPONENT (unchanged)
187
  // ============================================================
 
188
  function Message({ message }) {
189
  const isUser = message.role === "user";
190
  const [showDebug, setShowDebug] = useState(false);
@@ -192,8 +199,12 @@ function Message({ message }) {
192
  return (
193
  <div className={`message ${isUser ? "user" : "assistant"}`}>
194
  <div className="bubble">
195
- {message.text &&
196
- message.text.split("\n").map((line, i) => <p key={i}>{line}</p>)}
 
 
 
 
197
  </div>
198
 
199
  {!isUser && message.debug && (
@@ -216,4 +227,5 @@ function Message({ message }) {
216
  );
217
  }
218
 
 
219
  export default App;
 
4
  import { sendChat, login } from "./api";
5
  import "./App.css";
6
 
7
+ import ReactMarkdown from "react-markdown";
8
+ import remarkMath from "remark-math";
9
+ import rehypeKatex from "rehype-katex";
10
+ import "katex/dist/katex.min.css";
11
+
12
+
13
  function App() {
14
  // ---------------------------
15
  // Authentication State
 
191
  // ============================================================
192
  // MESSAGE COMPONENT (unchanged)
193
  // ============================================================
194
+
195
  function Message({ message }) {
196
  const isUser = message.role === "user";
197
  const [showDebug, setShowDebug] = useState(false);
 
199
  return (
200
  <div className={`message ${isUser ? "user" : "assistant"}`}>
201
  <div className="bubble">
202
+ <ReactMarkdown
203
+ remarkPlugins={[remarkMath]}
204
+ rehypePlugins={[rehypeKatex]}
205
+ >
206
+ {message.text || ""}
207
+ </ReactMarkdown>
208
  </div>
209
 
210
  {!isUser && message.debug && (
 
227
  );
228
  }
229
 
230
+
231
  export default App;