Skip to content

Commit 58a64e9

Browse files
committed
fixed open reference and context links in a new tab issue
1 parent 24259a9 commit 58a64e9

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

GUI/src/pages/TestModel/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useMutation, useQuery } from '@tanstack/react-query';
22
import { Button, FormSelect, FormTextarea, Collapsible } from 'components';
33
import CircularSpinner from 'components/molecules/CircularSpinner/CircularSpinner';
4-
import { FC, useState } from 'react';
4+
import { ComponentPropsWithoutRef, FC, useState } from 'react';
55
import { useTranslation } from 'react-i18next';
66
import ReactMarkdown from 'react-markdown';
77
import remarkGfm from 'remark-gfm';
@@ -87,6 +87,17 @@ const TestLLM: FC = () => {
8787
}));
8888
};
8989

90+
const markdownComponents = {
91+
ol: ({children}: any) => (
92+
<ol style={{ paddingLeft: '1.5rem', listStyleType: 'decimal' }}>
93+
{children}
94+
</ol>
95+
),
96+
a: (props: ComponentPropsWithoutRef<"a">) => (
97+
<a {...props} target="_blank" rel="noopener noreferrer" />
98+
),
99+
};
100+
90101
return (
91102
<div>
92103
{isLoadingConnections ? (
@@ -141,7 +152,7 @@ const TestLLM: FC = () => {
141152
<div className="result-item">
142153
<strong>Response:</strong>
143154
<div className="response-content">
144-
<ReactMarkdown remarkPlugins={[remarkGfm]}>
155+
<ReactMarkdown remarkPlugins={[remarkGfm]} components={markdownComponents}>
145156
{inferenceResult.content}
146157
</ReactMarkdown>
147158
</div>
@@ -159,7 +170,7 @@ const TestLLM: FC = () => {
159170
<strong>Rank {contextItem.rank}</strong>
160171
</div>
161172
<div className="context-content">
162-
<ReactMarkdown remarkPlugins={[remarkGfm]}>
173+
<ReactMarkdown remarkPlugins={[remarkGfm]} components={markdownComponents}>
163174
{contextItem.chunkRetrieved}
164175
</ReactMarkdown>
165176
</div>

0 commit comments

Comments
 (0)