Skip to content

Commit e0323d5

Browse files
committed
turn \n into linebreaks
1 parent 8f3a677 commit e0323d5

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

package-lock.json

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
"rehype-stringify": "10.0.1",
111111
"rehype-title-figure": "0.1.2",
112112
"remark": "15.0.1",
113+
"remark-breaks": "4.0.0",
113114
"remark-gfm": "4.0.1",
114115
"remark-stringify": "11.0.0",
115116
"sharp": "0.34.2",

src/components/SupportAI.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useState } from "react";
22
import Markdown from "react-markdown";
3+
import remarkBreaks from "remark-breaks";
34
import remarkGfm from "remark-gfm";
45
import { fetchEventSource } from "@microsoft/fetch-event-source";
56
import { Ring } from "ldrs/react";
@@ -30,7 +31,9 @@ function Messages({
3031
key={index}
3132
className={`${classes.base} ${message.role === "user" ? classes.user : classes.assistant}`}
3233
>
33-
<Markdown remarkPlugins={[remarkGfm]}>{message.content}</Markdown>
34+
<Markdown remarkPlugins={[remarkGfm, remarkBreaks]}>
35+
{message.content}
36+
</Markdown>
3437
</div>
3538
))}
3639
{loading && (
@@ -65,8 +68,8 @@ export default function SupportAI() {
6568
let sources: Sources = [];
6669

6770
await fetchEventSource(
68-
// "http://localhost:8010/proxy/devdocs/ask",
69-
"https://support-ai.cloudflaresupport.workers.dev/devdocs/ask",
71+
"http://localhost:8010/proxy/devdocs/ask",
72+
// "https://support-ai.cloudflaresupport.workers.dev/devdocs/ask",
7073
{
7174
method: "POST",
7275
body: JSON.stringify({
@@ -110,6 +113,8 @@ export default function SupportAI() {
110113
.map((source) => `- [${source.title}](${source.file_path})`)
111114
.join("\n"),
112115
].join("\n");
116+
117+
console.log(JSON.stringify(newMessages, null, 2));
113118
return newMessages;
114119
});
115120
}

0 commit comments

Comments
 (0)