Skip to content

Commit

Permalink
Merge pull request #4 from yoziru/add-markdown
Browse files Browse the repository at this point in the history
feat: add support for markdown
  • Loading branch information
yoziru authored Jul 28, 2024
2 parents c53673e + d7427ed commit 89f7754
Show file tree
Hide file tree
Showing 3 changed files with 840 additions and 5 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"react-code-blocks": "^0.1.6",
"react-dom": "^18",
"react-hook-form": "^7.51.2",
"react-markdown": "^9.0.1",
"react-textarea-autosize": "^8.5.3",
"remark-gfm": "^4.0.0",
"sonner": "^1.4.41",
"tailwind-merge": "^2.2.2",
"use-debounce": "^10.0.0",
Expand Down
6 changes: 4 additions & 2 deletions src/components/chat/chat-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Image from "next/image";

import OllamaLogo from "../../../public/ollama.png";
import CodeDisplayBlock from "../code-display-block";
import Markdown from "react-markdown";
import remarkGfm from "remark-gfm";
import { Message } from "ai";

interface ChatListProps {
Expand Down Expand Up @@ -101,9 +103,9 @@ export default function ChatList({ messages, isLoading }: ChatListProps) {
{message.content.split("```").map((part, index) => {
if (index % 2 === 0) {
return (
<React.Fragment key={index}>
<Markdown key={index} remarkPlugins={[remarkGfm]}>
{part}
</React.Fragment>
</Markdown>
);
} else {
return (
Expand Down
Loading

0 comments on commit 89f7754

Please sign in to comment.