Skip to content

Commit

Permalink
fix(ui): render latex box expression in chat window
Browse files Browse the repository at this point in the history
  • Loading branch information
hughlv committed Jan 8, 2024
1 parent 6700553 commit 97abedc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
allow_headers=["*"]
)

app.include_router(chat_router.router, prefix="/chats", tags=["Chat"], trailing_slash=False)
app.include_router(chat_router.router, prefix="/chats", tags=["Chat"])
app.include_router(message_router.router, prefix="/messages", tags=["Message"])
app.include_router(dev_router.router, prefix="/dev", tags=["Dev"])
app.include_router(extension_router.router, prefix="/extensions", tags=["Extension"])
Expand Down
2 changes: 1 addition & 1 deletion api/app/routers/chat_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ..services.chat_service import ChatService
from ..dependencies import get_chat_service

router = APIRouter(trailing_slash=False)
router = APIRouter()

@router.get('', summary="Get existing chats", response_model=List[Chat])
async def get_chats(service: ChatService = Depends(get_chat_service)):
Expand Down
2 changes: 1 addition & 1 deletion api/app/services/chat_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async def get_chats(self):

async def create_chat(self, chat: dict):
"""Create a new chat session"""
new_chat = self.pocketbase_client.create_chat(self.token, chat)
new_chat = self.pocketbase_client.create_chat(self.user, chat)
return new_chat

async def start_chat(self, message: dict, chat_id: str):
Expand Down
7 changes: 6 additions & 1 deletion ui/src/components/Markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ const Markdown = ({

const markdownWithImages: string = preprocessImageTags(children as string);

const processedMarkdown = markdownWithImages.replace(
/\\\((.*?)\\\)/g,
(match, p1) => `$${p1}$`
);

return (
<ReactMarkdown
remarkPlugins={[RemarkGfm, RemarkBreaks, RemarkMath]}
Expand Down Expand Up @@ -117,7 +122,7 @@ const Markdown = ({
className={clsx(className, `markdown`)}
{...props}
>
{markdownWithImages}
{processedMarkdown}
</ReactMarkdown>
);
};
Expand Down

0 comments on commit 97abedc

Please sign in to comment.