fix: upload a image can clear other message
This commit is contained in:
@@ -4,7 +4,14 @@ import { Terminal } from '@xterm/xterm';
|
||||
import '@xterm/xterm/css/xterm.css';
|
||||
import classNames from 'classnames';
|
||||
import _ from 'lodash';
|
||||
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
||||
import {
|
||||
memo,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useState
|
||||
} from 'react';
|
||||
import './index.less';
|
||||
import useSize from './use-size';
|
||||
|
||||
@@ -22,7 +29,7 @@ const LogsViewer: React.FC<LogsViewerProps> = (props) => {
|
||||
const termRef = useRef<any>({});
|
||||
const termwrapRef = useRef<any>({});
|
||||
const fitAddonRef = useRef<any>({});
|
||||
const cacheDataRef = useRef<any>(null);
|
||||
const cacheDataRef = useRef<any>('');
|
||||
const [logs, setLogs] = useState('');
|
||||
const size = useSize(scroller);
|
||||
|
||||
@@ -99,7 +106,7 @@ const LogsViewer: React.FC<LogsViewerProps> = (props) => {
|
||||
};
|
||||
}, [termwrapRef.current]);
|
||||
|
||||
useEffect(() => {
|
||||
useLayoutEffect(() => {
|
||||
if (size) {
|
||||
handleResize();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
.logs-viewer-wrap-w2 {
|
||||
.wrap {
|
||||
padding: 5px 0 5px 10px;
|
||||
overflow: auto;
|
||||
background-color: var(--color-logs-bg);
|
||||
border-radius: var(--border-radius-mini);
|
||||
|
||||
.content {
|
||||
word-wrap: break-word;
|
||||
|
||||
&.line-break {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
color: var(--color-logs-text);
|
||||
font-size: var(--font-size-small);
|
||||
line-height: 22px;
|
||||
white-space: pre-wrap;
|
||||
background-color: var(--color-logs-bg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
import useSetChunkFetch from '@/hooks/use-chunk-fetch';
|
||||
import useSetChunkRequest from '@/hooks/use-chunk-request';
|
||||
import useContainerScroll from '@/hooks/use-container-scorll';
|
||||
import Convert from 'ansi-to-html';
|
||||
import classNames from 'classnames';
|
||||
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
||||
import './old.less';
|
||||
|
||||
interface LogsViewerProps {
|
||||
height: number;
|
||||
content?: string;
|
||||
url: string;
|
||||
params?: object;
|
||||
}
|
||||
const LogsViewer: React.FC<LogsViewerProps> = (props) => {
|
||||
const { height, content, url } = props;
|
||||
const [nowrap, setNowrap] = useState(false);
|
||||
const [logsContent, setLogsContent] = useState<string[]>([]);
|
||||
const { setChunkRequest } = useSetChunkRequest();
|
||||
const { setChunkFetch } = useSetChunkFetch();
|
||||
const chunkRequedtRef = useRef<any>(null);
|
||||
const scroller = useRef<any>(null);
|
||||
const cacheDataRef = useRef<any>('');
|
||||
const { updateScrollerPosition, handleContentWheel } = useContainerScroll(
|
||||
scroller,
|
||||
{ toBottom: true }
|
||||
);
|
||||
|
||||
const convert = new Convert({
|
||||
newline: true,
|
||||
escapeXML: true,
|
||||
stream: false
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
updateScrollerPosition();
|
||||
}, [logsContent]);
|
||||
|
||||
const ansiEscapeRegex = /(\x1B\[A)+$/;
|
||||
|
||||
const endsWithAnsiEscapeSequence = useCallback((str: string) => {
|
||||
return ansiEscapeRegex.test(str);
|
||||
}, []);
|
||||
const getCursorUpLines = useCallback((str: string) => {
|
||||
const matches = str.match(/(?:\x1B\[A)+$/);
|
||||
|
||||
return matches ? matches[0].length / 3 : 0;
|
||||
}, []);
|
||||
|
||||
const removeDot = useCallback((str: string) => {
|
||||
return str.replace(/^\(.*?\)/, '');
|
||||
}, []);
|
||||
const replaceAnsiEscapeSequence = useCallback((str: string) => {
|
||||
const res = str.replace(ansiEscapeRegex, '');
|
||||
return removeDot(res);
|
||||
}, []);
|
||||
|
||||
const handleRControl = useCallback((str: string) => {
|
||||
if (str.includes('\r')) {
|
||||
const parts = str.split('\r');
|
||||
const lastLine = parts[parts.length - 1];
|
||||
return lastLine;
|
||||
}
|
||||
return str;
|
||||
}, []);
|
||||
|
||||
const parseHtmlStr = useCallback((logStr: string) => {
|
||||
cacheDataRef.current += logStr.replace('\r\n', '\n');
|
||||
console.log('data>>>>>>>>>>>', {
|
||||
data: logStr,
|
||||
cacheDataRef: cacheDataRef.current
|
||||
});
|
||||
const result: string[] = [];
|
||||
const lines = cacheDataRef.current
|
||||
.split('\n')
|
||||
.filter((line: string) => line.trim() !== '');
|
||||
// const lines = text;
|
||||
lines.forEach((line: string, index: number) => {
|
||||
const upCount = getCursorUpLines(line);
|
||||
console.log('line=========1', {
|
||||
line,
|
||||
upCount,
|
||||
result
|
||||
});
|
||||
if (endsWithAnsiEscapeSequence(line)) {
|
||||
const newLine = handleRControl(line);
|
||||
const val = removeDot(newLine);
|
||||
if (result.length < upCount) {
|
||||
result.push('');
|
||||
}
|
||||
if (upCount) {
|
||||
console.log('line=========0', {
|
||||
line,
|
||||
upCount,
|
||||
result
|
||||
});
|
||||
const placeIndex = result.length - upCount;
|
||||
result[placeIndex] = replaceAnsiEscapeSequence(val);
|
||||
} else {
|
||||
result.push(val);
|
||||
}
|
||||
} else {
|
||||
const val = handleRControl(line);
|
||||
result.push(val);
|
||||
}
|
||||
});
|
||||
return result.map((item) => {
|
||||
return convert.toHtml(item);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const updateContent = (newVal: string) => {
|
||||
const list = parseHtmlStr(newVal);
|
||||
setLogsContent(list);
|
||||
};
|
||||
|
||||
const createChunkConnection = async () => {
|
||||
chunkRequedtRef.current?.current?.abort?.();
|
||||
chunkRequedtRef.current = setChunkFetch({
|
||||
url,
|
||||
params: {
|
||||
...props.params,
|
||||
watch: true
|
||||
},
|
||||
contentType: 'text',
|
||||
handler: updateContent
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
createChunkConnection();
|
||||
return () => {
|
||||
chunkRequedtRef.current?.current?.abort?.();
|
||||
};
|
||||
}, [url, props.params]);
|
||||
|
||||
return (
|
||||
<div className="logs-viewer-wrap-w2">
|
||||
<div
|
||||
className="wrap"
|
||||
style={{ height: height }}
|
||||
ref={scroller}
|
||||
onWheel={handleContentWheel}
|
||||
>
|
||||
<div className={classNames('content', { 'line-break': nowrap })}>
|
||||
<div className="text">
|
||||
{logsContent.map((item, index) => {
|
||||
return (
|
||||
<div key={index} dangerouslySetInnerHTML={{ __html: item }} />
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(LogsViewer);
|
||||
@@ -0,0 +1,186 @@
|
||||
export default [
|
||||
'2024-09-11T20:09:42+08:00 - gpustack.worker.downloaders - INFO - Downloading model leafspark/Reflection-Llama-3.1-70B-GGUF/Reflection-Llama-3.1-70B.fp16*.gguf',
|
||||
'\rFetching 4 files: 0%| | 0/4 [00:00<?, ?it/s]',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 0%| | 0.00/21.7G [00:00<?, ?B/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 0.00/39.8G [00:00<?, ?B/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 0.00/39.8G [00:00<?, ?B/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 0.00/39.8G [00:00<?, ?B/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 0%| | 10.5M/21.7G [00:00<33:18, 10.9MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 10.5M/39.8G [00:00<57:50, 11.5MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 10.5M/39.8G [00:01<1:10:14, 9.43MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 10.5M/39.8G [00:01<1:49:48, 6.04MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 0%| | 21.0M/21.7G [00:01<32:32, 11.1MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 21.0M/39.8G [00:01<1:01:12, 10.8MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 21.0M/39.8G [00:02<1:13:42, 8.99MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 21.0M/39.8G [00:02<1:15:27, 8.79MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 0%| | 31.5M/21.7G [00:02<31:03, 11.6MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 31.5M/39.8G [00:02<1:01:49, 10.7MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 31.5M/39.8G [00:03<1:11:03, 9.32MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 31.5M/39.8G [00:03<1:14:10, 8.94MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 0%| | 41.9M/21.7G [00:03<33:05, 10.9MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 41.9M/39.8G [00:04<1:05:32, 10.1MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 41.9M/39.8G [00:04<1:08:05, 9.72MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 41.9M/39.8G [00:04<1:16:35, 8.66MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 0%| | 52.4M/21.7G [00:05<38:18, 9.42MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 52.4M/39.8G [00:05<1:15:47, 8.75MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 52.4M/39.8G [00:05<1:10:49, 9.34MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 52.4M/39.8G [00:05<1:09:52, 9.49MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 0%| | 62.9M/21.7G [00:06<38:36, 9.34MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 62.9M/39.8G [00:06<1:08:09, 9.72MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 62.9M/39.8G [00:06<1:12:01, 9.18MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 62.9M/39.8G [00:06<1:08:42, 9.65MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 0%| | 73.4M/21.7G [00:07<35:51, 10.1MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 73.4M/39.8G [00:07<1:10:30, 9.40MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 73.4M/39.8G [00:07<1:07:33, 9.79MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 73.4M/39.8G [00:08<1:08:59, 9.60MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 0%| | 83.9M/21.7G [00:08<35:46, 10.1MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 83.9M/39.8G [00:08<1:09:18, 9.56MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 83.9M/39.8G [00:08<1:06:26, 9.95MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 83.9M/39.8G [00:09<1:09:44, 9.50MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 0%| | 94.4M/21.7G [00:09<37:16, 9.66MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 94.4M/39.8G [00:09<1:08:35, 9.66MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 94.4M/39.8G [00:10<1:15:34, 8.75MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 0%| | 105M/21.7G [00:10<38:00, 9.47MB/s] \x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 94.4M/39.8G [00:10<1:15:42, 8.75MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 105M/39.8G [00:10<1:09:51, 9.48MB/s] \x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 105M/39.8G [00:11<1:08:19, 9.67MB/s] \x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 105M/39.8G [00:11<1:08:56, 9.60MB/s] \x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 115M/21.7G [00:11<39:31, 9.10MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 115M/39.8G [00:11<1:09:17, 9.55MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 115M/39.8G [00:11<1:05:22, 10.1MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 115M/39.8G [00:12<1:07:16, 9.84MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 126M/21.7G [00:12<39:05, 9.20MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 126M/39.8G [00:13<1:10:29, 9.39MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 126M/39.8G [00:13<1:10:04, 9.43MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 126M/39.8G [00:13<1:10:03, 9.45MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 136M/39.8G [00:14<1:08:49, 9.61MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 136M/21.7G [00:14<41:08, 8.74MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 136M/39.8G [00:14<1:09:47, 9.46MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 136M/39.8G [00:14<1:11:33, 9.25MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 147M/21.7G [00:15<37:06, 9.68MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 147M/39.8G [00:15<1:08:57, 9.59MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 147M/39.8G [00:15<1:09:54, 9.44MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 147M/39.8G [00:15<1:09:24, 9.53MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 157M/21.7G [00:16<38:27, 9.34MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 157M/39.8G [00:16<1:10:05, 9.43MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 157M/39.8G [00:16<1:07:01, 9.85MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 157M/39.8G [00:16<1:07:50, 9.75MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 168M/21.7G [00:17<38:21, 9.36MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 168M/39.8G [00:17<1:09:56, 9.45MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 168M/39.8G [00:17<1:08:31, 9.63MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 168M/39.8G [00:17<1:07:58, 9.73MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 178M/21.7G [00:18<36:28, 9.84MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 178M/39.8G [00:18<1:08:43, 9.62MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 178M/39.8G [00:18<1:06:23, 9.93MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 178M/39.8G [00:18<1:07:04, 9.85MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 189M/21.7G [00:19<36:05, 9.93MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 0%| | 189M/39.8G [00:19<1:09:17, 9.53MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 0%| | 189M/39.8G [00:19<1:09:44, 9.46MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 0%| | 189M/39.8G [00:20<1:08:53, 9.59MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 199M/21.7G [00:20<37:40, 9.51MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 199M/39.8G [00:20<1:10:46, 9.33MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 199M/39.8G [00:20<1:09:30, 9.49MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 199M/39.8G [00:22<1:24:55, 7.78MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 210M/21.7G [00:23<57:14, 6.26MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 210M/39.8G [00:27<2:43:58, 4.02MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 210M/39.8G [00:27<2:51:41, 3.85MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 210M/39.8G [00:30<3:47:09, 2.91MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 220M/21.7G [00:34<2:34:24, 2.32MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 220M/39.8G [00:37<5:20:53, 2.06MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 220M/39.8G [00:38<5:29:14, 2.00MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 220M/39.8G [00:41<6:03:25, 1.82MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 231M/21.7G [00:45<3:38:08, 1.64MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 231M/39.8G [00:48<7:09:37, 1.54MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 220M/39.8G [00:49<5:29:14, 2.00MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 231M/39.8G [00:49<7:23:13, 1.49MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 231M/39.8G [00:53<7:47:12, 1.41MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 241M/21.7G [00:56<4:26:13, 1.34MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 231M/39.8G [00:59<7:09:37, 1.54MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 241M/39.8G [00:59<8:28:36, 1.30MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 241M/39.8G [01:00<8:38:48, 1.27MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 241M/39.8G [01:04<8:55:29, 1.23MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 252M/21.7G [01:07<4:59:02, 1.20MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 252M/39.8G [01:10<9:24:07, 1.17MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 252M/39.8G [01:11<9:31:14, 1.15MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 252M/39.8G [01:15<9:43:07, 1.13MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%| | 262M/21.7G [01:18<5:22:04, 1.11MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 262M/39.8G [01:21<10:02:41, 1.09MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 262M/39.8G [01:22<10:07:38, 1.08MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 262M/39.8G [01:26<10:16:38, 1.07MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%|▏ | 273M/21.7G [01:29<5:37:49, 1.06MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 273M/39.8G [01:32<10:30:00, 1.05MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 273M/39.8G [01:33<10:33:40, 1.04MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 273M/39.8G [01:37<10:38:34, 1.03MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%|▏ | 273M/21.7G [01:40<5:37:49, 1.06MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%|▏ | 283M/21.7G [01:40<5:49:35, 1.02MB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 283M/39.8G [01:43<10:49:55, 1.01MB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 283M/39.8G [01:44<10:50:42, 1.01MB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 283M/39.8G [01:48<10:54:20, 1.01MB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%|▏ | 294M/21.7G [01:51<5:57:39, 997kB/s] \x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 294M/39.8G [01:54<11:03:10, 994kB/s] \x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 294M/39.8G [01:55<11:03:01, 992kB/s] \x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 294M/39.8G [01:59<11:06:45, 988kB/s] \x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%|▏ | 304M/21.7G [02:02<6:02:42, 983kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 304M/39.8G [02:06<11:11:58, 980kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 304M/39.8G [02:07<11:13:31, 976kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 304M/39.8G [02:10<11:13:59, 977kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%|▏ | 315M/21.7G [02:13<6:06:19, 973kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 315M/39.8G [02:17<11:18:04, 971kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 315M/39.8G [02:18<11:19:02, 968kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 304M/39.8G [02:20<11:13:59, 977kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 315M/39.8G [02:21<11:19:35, 969kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 1%|▏ | 325M/21.7G [02:25<6:09:00, 965kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 325M/39.8G [02:28<11:23:11, 964kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 325M/39.8G [02:29<11:24:16, 960kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 325M/39.8G [02:32<11:23:06, 964kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 2%|▏ | 336M/21.7G [02:36<6:10:37, 961kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 336M/39.8G [02:39<11:30:56, 953kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 336M/39.8G [02:40<11:27:52, 955kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 336M/39.8G [02:43<11:26:57, 958kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 2%|▏ | 346M/21.7G [02:47<6:12:02, 957kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 346M/39.8G [02:50<11:27:09, 958kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 336M/39.8G [02:50<11:27:52, 955kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 346M/39.8G [02:51<11:29:24, 953kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 346M/39.8G [02:54<11:28:21, 956kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 2%|▏ | 357M/21.7G [02:58<6:12:46, 954kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 346M/39.8G [03:00<11:27:09, 958kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 357M/39.8G [03:01<11:28:44, 955kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 357M/39.8G [03:02<11:30:19, 951kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 357M/39.8G [03:05<11:29:12, 955kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 2%|▏ | 367M/21.7G [03:09<6:13:01, 953kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 367M/39.8G [03:12<11:29:49, 953kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 367M/39.8G [03:13<11:30:10, 951kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 367M/39.8G [03:16<11:30:21, 953kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 2%|▏ | 377M/21.7G [03:20<6:13:22, 952kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 377M/39.8G [03:23<11:30:39, 952kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 377M/39.8G [03:24<11:30:37, 950kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 377M/39.8G [03:27<11:31:13, 951kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 2%|▏ | 388M/21.7G [03:31<6:13:41, 950kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 388M/39.8G [03:34<11:31:12, 951kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 388M/39.8G [03:35<11:30:13, 951kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 388M/39.8G [03:38<11:31:04, 951kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 2%|▏ | 388M/21.7G [03:41<6:13:41, 950kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 2%|▏ | 398M/21.7G [03:42<6:14:00, 949kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 398M/39.8G [03:45<11:31:46, 950kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 398M/39.8G [03:46<11:30:55, 949kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 398M/39.8G [03:49<11:31:42, 950kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 2%|▏ | 409M/21.7G [03:53<6:14:52, 947kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 409M/39.8G [03:56<11:32:14, 949kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 409M/39.8G [03:57<11:31:30, 948kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 409M/39.8G [04:00<11:31:46, 950kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 2%|▏ | 419M/21.7G [04:04<6:14:17, 948kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 419M/39.8G [04:07<11:32:00, 949kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 419M/39.8G [04:08<11:30:58, 949kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 409M/39.8G [04:11<11:31:46, 950kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 419M/39.8G [04:11<11:32:14, 949kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 2%|▏ | 430M/21.7G [04:15<6:14:11, 947kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 430M/39.8G [04:18<11:33:24, 947kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 430M/39.8G [04:19<11:30:43, 949kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 430M/39.8G [04:22<11:31:17, 950kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 2%|▏ | 440M/21.7G [04:26<6:13:49, 948kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 440M/39.8G [04:29<11:32:42, 948kB/s]\x1B[A\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00001-of-00004.gguf: 1%| | 440M/39.8G [04:30<11:30:07, 950kB/s]\x1B[A\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00003-of-00004.gguf: 1%| | 440M/39.8G [04:33<11:30:57, 950kB/s]\x1B[A\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00004-of-00004.gguf: 2%|▏ | 451M/21.7G [04:37<6:13:16, 949kB/s]\x1B[A',
|
||||
'\r(…)n-Llama-3.1-70B.fp16-00002-of-00004.gguf: 1%| | 451M/39.8G [04:40<11:32:03, 948kB/s]\x1B[A\x1B[A\x1B[A\x1B[A'
|
||||
];
|
||||
@@ -1,5 +1,5 @@
|
||||
import { EyeOutlined } from '@ant-design/icons';
|
||||
import { Image, Typography } from 'antd';
|
||||
import { Checkbox, Image, Typography } from 'antd';
|
||||
import { unescape } from 'lodash';
|
||||
import { TokensList, marked } from 'marked';
|
||||
import React, { Fragment, useCallback, useEffect } from 'react';
|
||||
@@ -38,12 +38,15 @@ const MarkdownViewer: React.FC<MarkdownViewerProps> = ({
|
||||
'list_item',
|
||||
'br',
|
||||
'html',
|
||||
'escape'
|
||||
'escape',
|
||||
'del',
|
||||
'blockquote',
|
||||
'checkbox'
|
||||
];
|
||||
|
||||
renderer.link = ({ href, title, text }) => {
|
||||
return `<a href="${href}" title="${title || ''}" target="_blank" rel="noopener noreferrer">${text}</a>`;
|
||||
};
|
||||
// renderer.link = ({ href, title, text }) => {
|
||||
// return `<a href="${href}" title="${title || ''}" target="_blank" rel="noopener noreferrer">${text}</a>`;
|
||||
// };
|
||||
|
||||
const isValidURL = useCallback((url: string) => {
|
||||
const pattern = /^(https?:\/\/|\/\/)([^\s/$.?#].[^\s]*)$/;
|
||||
@@ -101,6 +104,18 @@ const MarkdownViewer: React.FC<MarkdownViewerProps> = ({
|
||||
htmlstr = <li>{text}</li>;
|
||||
}
|
||||
|
||||
if (token.type === 'del') {
|
||||
htmlstr = <del>{text}</del>;
|
||||
}
|
||||
|
||||
if (token.type === 'blockquote') {
|
||||
htmlstr = <blockquote>{text}</blockquote>;
|
||||
}
|
||||
|
||||
if (token.type === 'checkbox') {
|
||||
htmlstr = <Checkbox value={token.checked} />;
|
||||
}
|
||||
|
||||
if (token.type === 'br') {
|
||||
htmlstr = <br />;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,10 @@ const SealTable: React.FC<SealTableProps & { pagination: PaginationProps }> = (
|
||||
if (selectedRowKeys?.length === 0) {
|
||||
setSelectAll(false);
|
||||
setIndeterminate(false);
|
||||
} else if (selectedRowKeys?.length === props.dataSource.length) {
|
||||
} else if (
|
||||
selectedRowKeys?.length === props.dataSource.length &&
|
||||
selectedRowKeys.length > 0
|
||||
) {
|
||||
setSelectAll(true);
|
||||
setIndeterminate(false);
|
||||
} else {
|
||||
@@ -54,7 +57,7 @@ const SealTable: React.FC<SealTableProps & { pagination: PaginationProps }> = (
|
||||
setIndeterminate(true);
|
||||
}
|
||||
}
|
||||
}, [rowSelection]);
|
||||
}, [rowSelection, props.dataSource]);
|
||||
|
||||
const handleSelectAllChange = (e: any) => {
|
||||
if (e.target.checked) {
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
import qs from 'query-string';
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
interface RequestConfig {
|
||||
url: string;
|
||||
handler: (data: any) => any;
|
||||
beforeReconnect?: () => void;
|
||||
params?: object;
|
||||
contentType?: 'json' | 'text';
|
||||
}
|
||||
|
||||
const useSetChunkFetch = () => {
|
||||
const axiosToken = useRef<any>(null);
|
||||
const requestConfig = useRef<any>({});
|
||||
|
||||
const readTextEventStreamData = async (
|
||||
reader: any,
|
||||
decoder: TextDecoder,
|
||||
callback: (data: any) => void
|
||||
) => {
|
||||
const { done, value } = await reader.read();
|
||||
|
||||
if (done) {
|
||||
return;
|
||||
}
|
||||
|
||||
let chunk = decoder.decode(value, { stream: true });
|
||||
callback(chunk);
|
||||
await readTextEventStreamData(reader, decoder, callback);
|
||||
};
|
||||
|
||||
const fetchChunkRequest = async ({
|
||||
url,
|
||||
handler,
|
||||
params = {}
|
||||
}: RequestConfig) => {
|
||||
axiosToken.current?.abort?.();
|
||||
axiosToken.current = new AbortController();
|
||||
try {
|
||||
const response = await fetch(
|
||||
`v1${url}?${qs.stringify({
|
||||
...params,
|
||||
watch: true
|
||||
})}`,
|
||||
{
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: {
|
||||
'Content-Type': 'application/octet-stream'
|
||||
},
|
||||
signal: axiosToken.current.signal
|
||||
}
|
||||
);
|
||||
console.log('response============', response);
|
||||
if (!response.ok) {
|
||||
return;
|
||||
}
|
||||
const reader = response?.body?.getReader();
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
await readTextEventStreamData(reader, decoder, handler);
|
||||
} catch (error) {
|
||||
// handle error
|
||||
}
|
||||
|
||||
return axiosToken.current;
|
||||
};
|
||||
|
||||
const setChunkFetch = (config: RequestConfig) => {
|
||||
requestConfig.current = { ...config };
|
||||
fetchChunkRequest(requestConfig.current);
|
||||
return axiosToken;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const handleUnload = () => {
|
||||
axiosToken.current?.abort?.();
|
||||
};
|
||||
|
||||
window.addEventListener('beforeunload', handleUnload);
|
||||
|
||||
return () => {
|
||||
axiosToken.current?.abort?.();
|
||||
window.removeEventListener('beforeunload', handleUnload);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return {
|
||||
setChunkFetch
|
||||
};
|
||||
};
|
||||
|
||||
export default useSetChunkFetch;
|
||||
@@ -172,7 +172,7 @@ const useSetChunkRequest = () => {
|
||||
|
||||
let result = response;
|
||||
let cres = '';
|
||||
console.log('chunkrequest============e==', e);
|
||||
console.log('chunkrequest============e==', result);
|
||||
if (contentType === 'json') {
|
||||
const currentRes = sliceData(response, e.loaded, loadedSize);
|
||||
result = parseData(currentRes);
|
||||
@@ -194,7 +194,6 @@ const useSetChunkRequest = () => {
|
||||
retryCount.current -= 1;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('error=============', error);
|
||||
if (!axios.isCancel(error)) {
|
||||
setRequestReadyState(4);
|
||||
if (retryCount.current > 0) {
|
||||
|
||||
@@ -11,10 +11,15 @@ export default function useTableRowSelection() {
|
||||
setSelectedRowKeys([]);
|
||||
};
|
||||
|
||||
const removeSelectedKey = (rowKey: React.Key) => {
|
||||
setSelectedRowKeys((keys) => keys.filter((key) => key !== rowKey));
|
||||
};
|
||||
|
||||
const rowSelection = {
|
||||
selectedRowKeys,
|
||||
clearSelections,
|
||||
onChange: onSelectChange
|
||||
onChange: onSelectChange,
|
||||
removeSelectedKey
|
||||
};
|
||||
|
||||
return rowSelection;
|
||||
|
||||
@@ -311,6 +311,7 @@ const Models: React.FC<ModelsProps> = ({
|
||||
async onOk() {
|
||||
await deleteModel(row.id);
|
||||
updateExpandedRowKeys([row.id]);
|
||||
rowSelection.removeSelectedKey(row.id);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import LogsViewer from '@/components/logs-viewer';
|
||||
import LogsViewer from '@/components/logs-viewer/index';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Modal } from 'antd';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
@@ -58,7 +58,6 @@ const ContentItem: React.FC<MessageItemProps> = ({
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
let item = items[i];
|
||||
console.log('item===========', item);
|
||||
|
||||
if (item.kind === 'file' && item.type.indexOf('image') !== -1) {
|
||||
const file = item.getAsFile();
|
||||
@@ -102,7 +101,7 @@ const ContentItem: React.FC<MessageItemProps> = ({
|
||||
console.error('Error processing images:', error);
|
||||
}
|
||||
},
|
||||
[data]
|
||||
[data, updateMessage]
|
||||
);
|
||||
|
||||
const handleOnPaste = (e: any) => {
|
||||
@@ -131,7 +130,7 @@ const ContentItem: React.FC<MessageItemProps> = ({
|
||||
imgs: [...(data.imgs || []), ...list]
|
||||
});
|
||||
},
|
||||
[data]
|
||||
[data, updateMessage]
|
||||
);
|
||||
|
||||
const handleDeleteImg = (uid: number | string) => {
|
||||
|
||||
Reference in New Issue
Block a user