From b2e9cbb44ac3d04f7a8e1b3850018cc02d6c52b9 Mon Sep 17 00:00:00 2001 From: jialin Date: Mon, 30 Jun 2025 18:56:28 +0800 Subject: [PATCH] chore: update backend parameters and logs reading frequency --- src/components/logs-viewer/logs-list.tsx | 2 +- src/hooks/use-chunk-fetch.ts | 31 +++++++++++++++++++++- src/pages/llmodels/config/llama-config.ts | 4 +++ src/pages/llmodels/config/mindie-config.ts | 8 ++++++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/components/logs-viewer/logs-list.tsx b/src/components/logs-viewer/logs-list.tsx index 143d4c3d..e8ba5820 100644 --- a/src/components/logs-viewer/logs-list.tsx +++ b/src/components/logs-viewer/logs-list.tsx @@ -72,7 +72,7 @@ const LogsList: React.FC = forwardRef((props, ref) => { const isBottom = scrollTop + clientHeight + 150 >= scrollHeight; // is scroll to top - if (scrollTop === 0) { + if (scrollTop <= 10) { onScroll?.({ isTop: true, isBottom: false diff --git a/src/hooks/use-chunk-fetch.ts b/src/hooks/use-chunk-fetch.ts index be5cb2bd..270a378b 100644 --- a/src/hooks/use-chunk-fetch.ts +++ b/src/hooks/use-chunk-fetch.ts @@ -1,3 +1,4 @@ +import { convertFileSize } from '@/utils'; import { throttle } from 'lodash'; import qs from 'query-string'; import { useEffect, useRef } from 'react'; @@ -42,13 +43,19 @@ const useSetChunkFetch = () => { const readTextEventStreamData = async ( response: Response, callback: HandlerFunction, - delay = 200 + delay = 100 ) => { class BufferManager { private buffer: any[] = []; private contentLength: number | null = null; private progress: number = 0; private percent: number = 0; + private speedHistory: number[] = []; + private maxHistory = 5; + private lastTime: number = performance.now(); + private lastBytes: number = 0; + private totalBytes: number = 0; + private avgSpeed: number = 0; constructor(private options: { contentLength?: string | null }) { this.contentLength = options.contentLength @@ -63,6 +70,28 @@ const useSetChunkFetch = () => { } } + private logSpeed(speedBps: number) { + this.speedHistory.push(speedBps); + if (this.speedHistory.length > this.maxHistory) { + this.speedHistory.shift(); + } + this.avgSpeed = + this.speedHistory.reduce((a, b) => a + b, 0) / + this.speedHistory.length; + console.log(`瞬时均值: ${convertFileSize(this.avgSpeed)}/s`); + } + + public updateSpeed(bytes: number) { + const now = performance.now(); + const elapsed = (now - this.lastTime) / 1000; + if (elapsed > 0.3) { + const speed = (this.totalBytes + bytes - this.lastBytes) / elapsed; + this.logSpeed(speed); + this.lastTime = now; + this.lastBytes = this.totalBytes + bytes; + } + } + public add(data: any) { this.buffer.push(data); this.updateProgress(data); diff --git a/src/pages/llmodels/config/llama-config.ts b/src/pages/llmodels/config/llama-config.ts index 483828bf..179e4cc9 100644 --- a/src/pages/llmodels/config/llama-config.ts +++ b/src/pages/llmodels/config/llama-config.ts @@ -604,6 +604,10 @@ const options = [ { label: '--no-enable-reasoning', value: '--no-enable-reasoning' + }, + { + label: '--override-tensor', + value: '--override-tensor' } ]; diff --git a/src/pages/llmodels/config/mindie-config.ts b/src/pages/llmodels/config/mindie-config.ts index d3eb7d24..1987f1d4 100644 --- a/src/pages/llmodels/config/mindie-config.ts +++ b/src/pages/llmodels/config/mindie-config.ts @@ -183,6 +183,14 @@ const options = [ { label: '--moe-tensor-parallel-size', value: '--moe-tensor-parallel-size' + }, + { + label: '--enable-multi-token-prediction', + value: '--enable-multi-token-prediction' + }, + { + label: '--multi-token-prediction-tokens', + value: '--multi-token-prediction-tokens' } ];