From 08f9029bf8e5ef00fecab91109a883d19d40e28f Mon Sep 17 00:00:00 2001 From: jialin Date: Thu, 9 Jan 2025 14:10:42 +0800 Subject: [PATCH] chore: audio file .m4a support --- src/components/logs-viewer/styles/index.less | 10 +++++----- .../logs-viewer/virtual-log-list.tsx | 12 ++++++++---- src/components/upload-audio/index.tsx | 2 +- src/pages/llmodels/catalog.tsx | 19 ------------------- .../llmodels/components/catalog-list.tsx | 3 ++- .../playground/components/ground-stt.tsx | 3 ++- src/pages/playground/config/index.ts | 2 ++ 7 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/components/logs-viewer/styles/index.less b/src/components/logs-viewer/styles/index.less index 63ac7e1d..5f0f3b4c 100644 --- a/src/components/logs-viewer/styles/index.less +++ b/src/components/logs-viewer/styles/index.less @@ -14,11 +14,11 @@ &::before { content: ''; position: absolute; - top: 30px; - bottom: 30px; - right: 0; - width: 100px; - height: 60px; + top: 0; + bottom: 0; + right: -18px; + width: 80px; + height: 185px; &:hover { .pagination { diff --git a/src/components/logs-viewer/virtual-log-list.tsx b/src/components/logs-viewer/virtual-log-list.tsx index 51eece17..a1adf4b6 100644 --- a/src/components/logs-viewer/virtual-log-list.tsx +++ b/src/components/logs-viewer/virtual-log-list.tsx @@ -45,6 +45,7 @@ const LogsViewer: React.FC = forwardRef((props, ref) => { const loadMoreDone = useRef(false); const pageRef = useRef(page); const totalPageRef = useRef(totalPage); + const isLoadingMoreRef = useRef(false); useImperativeHandle(ref, () => ({ abort() { @@ -79,6 +80,7 @@ const LogsViewer: React.FC = forwardRef((props, ref) => { const debounceLoading = _.debounce(() => { setLoading(false); + isLoadingMoreRef.current = false; }, 200); const isClean = useCallback((input: string) => { @@ -91,8 +93,9 @@ const LogsViewer: React.FC = forwardRef((props, ref) => { const getLastPage = (data: string) => { const list = _.split(data.trim(), '\n'); let result = ''; - console.log('getlastPage===', list.length, enableScorllLoad, pageSize); - setLoading(true); + if (isLoadingMoreRef.current) { + setLoading(true); + } if (!enableScorllLoad) { result = list.join('\n'); } else if (list.length <= pageSize) { @@ -142,7 +145,7 @@ const LogsViewer: React.FC = forwardRef((props, ref) => { const start = (newPage - 1) * pageSize; const end = newPage * pageSize; const prePage = list.slice(start, end).join('\n'); - console.log('prePage===', newPage); + setPage(() => newPage); setScrollPos(['bottom', newPage]); pageRef.current = newPage; @@ -160,7 +163,7 @@ const LogsViewer: React.FC = forwardRef((props, ref) => { const start = (newPage - 1) * pageSize; const end = newPage * pageSize; const nextPage = list.slice(start, end).join('\n'); - console.log('nextPage===', newPage); + setPage(() => newPage); setScrollPos(['top', newPage]); pageRef.current = newPage; @@ -241,6 +244,7 @@ const LogsViewer: React.FC = forwardRef((props, ref) => { tail.current = undefined; createChunkConnection(); loadMoreDone.current = true; + isLoadingMoreRef.current = true; } else if (isTop && page <= totalPage && page > 1) { // getPrePage(); } else if (isBottom && page < totalPage) { diff --git a/src/components/upload-audio/index.tsx b/src/components/upload-audio/index.tsx index 796dced2..5c65c9bd 100644 --- a/src/components/upload-audio/index.tsx +++ b/src/components/upload-audio/index.tsx @@ -24,7 +24,7 @@ const UploadAudio: React.FC = (props) => { ); return ( { setActiveId(-1); }; - const handleResize = useCallback( - _.throttle((size: { width: number; height: number }) => { - const { width } = size; - if (width < breakpoints.xs) { - setSpan(24); - } else if (width < breakpoints.sm) { - setSpan(24); - } else if (width < breakpoints.md) { - setSpan(12); - } else if (width < breakpoints.lg) { - setSpan(12); - } else { - setSpan(8); - } - }, 100), - [] - ); - const handleOnDeploy = useCallback((item: CatalogItemType) => { setActiveId(item.id); setOpenDeployModal({ diff --git a/src/pages/llmodels/components/catalog-list.tsx b/src/pages/llmodels/components/catalog-list.tsx index 283b386f..8872ecdd 100644 --- a/src/pages/llmodels/components/catalog-list.tsx +++ b/src/pages/llmodels/components/catalog-list.tsx @@ -1,5 +1,5 @@ import breakpoints from '@/config/breakpoints'; -import { Col, Row, Spin } from 'antd'; +import { Col, FloatButton, Row, Spin } from 'antd'; import ResizeObserver from 'rc-resize-observer'; import React, { useCallback } from 'react'; import { CatalogItem as CatalogItemType } from '../config/types'; @@ -80,6 +80,7 @@ const CatalogList: React.FC = (props) => { )} + ); }; diff --git a/src/pages/playground/components/ground-stt.tsx b/src/pages/playground/components/ground-stt.tsx index 5bc90efa..c84a8b08 100644 --- a/src/pages/playground/components/ground-stt.tsx +++ b/src/pages/playground/components/ground-stt.tsx @@ -25,6 +25,7 @@ import { useState } from 'react'; import { speechToText } from '../apis'; +import { SpeechToTextFormat } from '../config'; import { RealtimeParamsConfig as paramsConfig } from '../config/params-config'; import '../style/ground-left.less'; import '../style/speech-to-text.less'; @@ -306,7 +307,7 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { {!isRecording && ( )} diff --git a/src/pages/playground/config/index.ts b/src/pages/playground/config/index.ts index 3d43843d..4863e07d 100644 --- a/src/pages/playground/config/index.ts +++ b/src/pages/playground/config/index.ts @@ -137,6 +137,8 @@ export const OpenAIViewCode = { } }; +export const SpeechToTextFormat = ['.mp3', '.mp4', '.wav', '.m4a']; + export const promptList = [ 'a lovely cat.', "Digital art, portrait of an anthropomorphic roaring Tiger warrior with full armor, close up in the middle of a battle, behind him there is a banner with the text 'Open Source'.",