Compare commits
8
Commits
gpu-service
...
v0.6.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3247793d11 | ||
|
|
2d46809b78 | ||
|
|
57f4ddad26 | ||
|
|
de34d0ae00 | ||
|
|
4f7037baa0 | ||
|
|
bd15e9aa6c | ||
|
|
907105a492 | ||
|
|
0d3da04356 |
@@ -4,11 +4,13 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'main'
|
- 'main'
|
||||||
|
- 'v*-dev'
|
||||||
tags:
|
tags:
|
||||||
- '*.*.*'
|
- '*.*.*'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- 'main'
|
- 'main'
|
||||||
|
- 'v*-dev'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
NODE_VERSION: '21'
|
NODE_VERSION: '21'
|
||||||
@@ -72,11 +74,6 @@ jobs:
|
|||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
version: ['latest', '${{ github.ref_name }}']
|
|
||||||
exclude:
|
|
||||||
- version: 'main'
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -92,10 +89,23 @@ jobs:
|
|||||||
${{ github.workspace }}/node_modules
|
${{ github.workspace }}/node_modules
|
||||||
- name: Build
|
- name: Build
|
||||||
run: scripts/build
|
run: scripts/build
|
||||||
|
- name: Determine Version
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
|
||||||
|
echo "version=latest" >> $GITHUB_OUTPUT
|
||||||
|
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||||
|
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||||
|
elif [[ "${GITHUB_REF}" == refs/heads/v*-dev ]]; then
|
||||||
|
echo "version=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "Not a publish target"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
- name: Package
|
- name: Package
|
||||||
run: scripts/package
|
run: scripts/package
|
||||||
env:
|
env:
|
||||||
VERSION: '${{ matrix.version }}'
|
VERSION: '${{ steps.version.outputs.version }}'
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: TencentCloud/cos-action@b0aa648235fb35a1bdd6a77f529eb0ac4c2f1c25
|
uses: TencentCloud/cos-action@b0aa648235fb35a1bdd6a77f529eb0ac4c2f1c25
|
||||||
with:
|
with:
|
||||||
@@ -103,7 +113,7 @@ jobs:
|
|||||||
secret_key: ${{ secrets.CI_TECENTCOS_SECRET_KEY }}
|
secret_key: ${{ secrets.CI_TECENTCOS_SECRET_KEY }}
|
||||||
cos_bucket: ${{ secrets.COS_BUCKET }}
|
cos_bucket: ${{ secrets.COS_BUCKET }}
|
||||||
cos_region: ${{ secrets.COS_REGION }}
|
cos_region: ${{ secrets.COS_REGION }}
|
||||||
local_path: dist/${{ matrix.version }}.tar.gz
|
local_path: dist/${{ steps.version.outputs.version }}.tar.gz
|
||||||
remote_path: releases/${{ matrix.version }}.tar.gz
|
remote_path: releases/${{ steps.version.outputs.version }}.tar.gz
|
||||||
accelerate: true
|
accelerate: true
|
||||||
clean: false
|
clean: false
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
"@umijs/max": "^4.2.11",
|
"@umijs/max": "^4.2.11",
|
||||||
"@xterm/addon-fit": "^0.10.0",
|
"@xterm/addon-fit": "^0.10.0",
|
||||||
"@xterm/xterm": "^5.5.0",
|
"@xterm/xterm": "^5.5.0",
|
||||||
|
"ahooks": "^3.8.5",
|
||||||
"ansi-to-html": "^0.7.2",
|
"ansi-to-html": "^0.7.2",
|
||||||
"antd": "^5.21.6",
|
"antd": "^5.21.6",
|
||||||
"antd-style": "^3.6.2",
|
"antd-style": "^3.6.2",
|
||||||
|
|||||||
Generated
+12
-8
@@ -47,6 +47,9 @@ dependencies:
|
|||||||
'@xterm/xterm':
|
'@xterm/xterm':
|
||||||
specifier: ^5.5.0
|
specifier: ^5.5.0
|
||||||
version: 5.5.0
|
version: 5.5.0
|
||||||
|
ahooks:
|
||||||
|
specifier: ^3.8.5
|
||||||
|
version: 3.8.5(react@18.2.0)
|
||||||
ansi-to-html:
|
ansi-to-html:
|
||||||
specifier: ^0.7.2
|
specifier: ^0.7.2
|
||||||
version: 0.7.2
|
version: 0.7.2
|
||||||
@@ -290,7 +293,7 @@ packages:
|
|||||||
'@umijs/bundler-utils': 4.2.8
|
'@umijs/bundler-utils': 4.2.8
|
||||||
'@umijs/plugins': 4.2.8(@babel/core@7.26.0)(@types/react-dom@18.3.0)(@types/react@18.3.1)(antd@5.21.6)(dva@2.5.0-beta.2)(rc-field-form@2.7.0)(react-dom@18.2.0)(react@18.2.0)
|
'@umijs/plugins': 4.2.8(@babel/core@7.26.0)(@types/react-dom@18.3.0)(@types/react@18.3.1)(antd@5.21.6)(dva@2.5.0-beta.2)(rc-field-form@2.7.0)(react-dom@18.2.0)(react@18.2.0)
|
||||||
'@umijs/utils': 4.2.8
|
'@umijs/utils': 4.2.8
|
||||||
ahooks: 3.8.0(react@18.2.0)
|
ahooks: 3.8.5(react@18.2.0)
|
||||||
antd-mobile-alita: 2.3.4(react-dom@18.2.0)(react@18.2.0)
|
antd-mobile-alita: 2.3.4(react-dom@18.2.0)(react@18.2.0)
|
||||||
antd-mobile-icons: 0.2.2
|
antd-mobile-icons: 0.2.2
|
||||||
babel-plugin-import: 1.13.8
|
babel-plugin-import: 1.13.8
|
||||||
@@ -7595,22 +7598,22 @@ packages:
|
|||||||
dev: false
|
dev: false
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/ahooks@3.8.0(react@18.2.0):
|
/ahooks@3.8.5(react@18.2.0):
|
||||||
resolution: {integrity: sha512-M01m+mxLRNNeJ/PCT3Fom26UyreTj6oMqJBetUrJnK4VNI5j6eMA543Xxo53OBXn6XibA2FXKcCCgrT6YCTtKQ==, tarball: https://registry.npmjs.org/ahooks/-/ahooks-3.8.0.tgz}
|
resolution: {integrity: sha512-Y+MLoJpBXVdjsnnBjE5rOSPkQ4DK+8i5aPDzLJdIOsCpo/fiAeXcBY1Y7oWgtOK0TpOz0gFa/XcyO1UGdoqLcw==, tarball: https://registry.npmjs.org/ahooks/-/ahooks-3.8.5.tgz}
|
||||||
engines: {node: '>=8.0.0'}
|
engines: {node: '>=8.0.0'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
react: ^16.8.0 || ^17.0.0 || ^18.0.0
|
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/runtime': 7.26.0
|
'@babel/runtime': 7.26.0
|
||||||
dayjs: 1.11.11
|
dayjs: 1.11.11
|
||||||
intersection-observer: 0.12.2
|
intersection-observer: 0.12.2
|
||||||
js-cookie: 2.2.1
|
js-cookie: 3.0.5
|
||||||
lodash: 4.17.21
|
lodash: 4.17.21
|
||||||
react: 18.2.0
|
react: 18.2.0
|
||||||
react-fast-compare: 3.2.2
|
react-fast-compare: 3.2.2
|
||||||
resize-observer-polyfill: 1.5.1
|
resize-observer-polyfill: 1.5.1
|
||||||
screenfull: 5.2.0
|
screenfull: 5.2.0
|
||||||
tslib: 2.6.2
|
tslib: 2.8.1
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/ajv-formats@2.1.1(ajv@8.13.0):
|
/ajv-formats@2.1.1(ajv@8.13.0):
|
||||||
@@ -12759,8 +12762,9 @@ packages:
|
|||||||
react: 18.2.0
|
react: 18.2.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/js-cookie@2.2.1:
|
/js-cookie@3.0.5:
|
||||||
resolution: {integrity: sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==, tarball: https://registry.npmjs.org/js-cookie/-/js-cookie-2.2.1.tgz}
|
resolution: {integrity: sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==, tarball: https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz}
|
||||||
|
engines: {node: '>=14'}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/js-sdsl@4.4.2:
|
/js-sdsl@4.4.2:
|
||||||
|
|||||||
@@ -7,10 +7,14 @@ interface UploadAudioProps {
|
|||||||
accept?: string;
|
accept?: string;
|
||||||
maxCount?: number;
|
maxCount?: number;
|
||||||
type?: 'text' | 'primary' | 'default';
|
type?: 'text' | 'primary' | 'default';
|
||||||
|
icon?: React.ReactNode;
|
||||||
|
size?: 'small' | 'middle' | 'large';
|
||||||
|
shape?: 'circle' | 'round' | 'default';
|
||||||
onChange?: (data: { file: any; fileList: any[] }) => void;
|
onChange?: (data: { file: any; fileList: any[] }) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const UploadAudio: React.FC<UploadAudioProps> = (props) => {
|
const UploadAudio: React.FC<UploadAudioProps> = (props) => {
|
||||||
|
const { icon, accept, type, size = 'large', shape = 'circle' } = props;
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const beforeUpload = (file: any) => {
|
const beforeUpload = (file: any) => {
|
||||||
return false;
|
return false;
|
||||||
@@ -48,9 +52,10 @@ const UploadAudio: React.FC<UploadAudioProps> = (props) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
icon={<UploadOutlined />}
|
size={size}
|
||||||
|
icon={icon ?? <UploadOutlined />}
|
||||||
type={props.type ?? 'text'}
|
type={props.type ?? 'text'}
|
||||||
shape="circle"
|
shape={shape}
|
||||||
></Button>
|
></Button>
|
||||||
</div>
|
</div>
|
||||||
</Upload>
|
</Upload>
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ interface ErrorResultProps {
|
|||||||
|
|
||||||
function isChunkLoadError(msg?: string): boolean {
|
function isChunkLoadError(msg?: string): boolean {
|
||||||
if (typeof msg !== 'string') return false;
|
if (typeof msg !== 'string') return false;
|
||||||
return msg.includes('Loading chunk') && msg.includes('failed');
|
const jsChunkFailed = msg.includes('Loading chunk');
|
||||||
|
const cssChunkFailed = msg.includes('Loading CSS chunk');
|
||||||
|
|
||||||
|
return (jsChunkFailed || cssChunkFailed) && msg.includes('failed');
|
||||||
}
|
}
|
||||||
|
|
||||||
const ErrorResult: React.FC<ErrorResultProps> = ({ extra }) => {
|
const ErrorResult: React.FC<ErrorResultProps> = ({ extra }) => {
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ const resetFields = [
|
|||||||
'env'
|
'env'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const resetFieldsByFile = [
|
||||||
|
'cpu_offloading',
|
||||||
|
'distributed_inference_across_workers',
|
||||||
|
'backend_parameters'
|
||||||
|
];
|
||||||
|
|
||||||
const ModalFooterStyle = {
|
const ModalFooterStyle = {
|
||||||
padding: '16px 24px',
|
padding: '16px 24px',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -94,6 +100,7 @@ const AddModal: FC<AddModalProps> = (props) => {
|
|||||||
handleBackendChangeBefore,
|
handleBackendChangeBefore,
|
||||||
cancelEvaluate,
|
cancelEvaluate,
|
||||||
handleOnValuesChange,
|
handleOnValuesChange,
|
||||||
|
handleEvaluateOnChange,
|
||||||
warningStatus,
|
warningStatus,
|
||||||
submitAnyway
|
submitAnyway
|
||||||
} = useCheckCompatibility();
|
} = useCheckCompatibility();
|
||||||
@@ -135,22 +142,37 @@ const AddModal: FC<AddModalProps> = (props) => {
|
|||||||
return categories || null;
|
return categories || null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSelectModelFile = (item: any, evaluate?: boolean) => {
|
const handleSelectModelFile = async (item: any, evaluate?: boolean) => {
|
||||||
form.current?.form?.resetFields(resetFields);
|
form.current?.form?.resetFields(resetFieldsByFile);
|
||||||
const modelInfo = onSelectModel(selectedModel, props.source);
|
const modelInfo = onSelectModel(selectedModel, props.source);
|
||||||
form.current?.setFieldsValue?.({
|
form.current?.setFieldsValue?.({
|
||||||
file_name: item.fakeName,
|
file_name: item.fakeName,
|
||||||
...getDefaultSpec(item),
|
|
||||||
...modelInfo,
|
...modelInfo,
|
||||||
categories: getCategory(item)
|
categories: getCategory(item)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve(true);
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
|
||||||
if (item.fakeName) {
|
if (item.fakeName) {
|
||||||
handleOnValuesChange?.({
|
const evaluateRes = await handleEvaluateOnChange?.({
|
||||||
changedValues: {},
|
changedValues: {},
|
||||||
allValues: form.current?.form?.getFieldsValue?.(),
|
allValues: form.current?.form?.getFieldsValue?.(),
|
||||||
source: props.source
|
source: props.source
|
||||||
});
|
});
|
||||||
|
const defaultSpec = getDefaultSpec({
|
||||||
|
evaluateResult: evaluateRes
|
||||||
|
});
|
||||||
|
console.log('defaultSpec', defaultSpec);
|
||||||
|
form.current?.setFieldsValue?.({
|
||||||
|
file_name: item.fakeName,
|
||||||
|
...defaultSpec,
|
||||||
|
...modelInfo,
|
||||||
|
categories: getCategory(item)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
|
|||||||
return (
|
return (
|
||||||
<TooltipOverlayScroller
|
<TooltipOverlayScroller
|
||||||
toolTipProps={{
|
toolTipProps={{
|
||||||
trigger: 'click',
|
trigger: 'hover',
|
||||||
overlayInnerStyle: {
|
overlayInnerStyle: {
|
||||||
width: 'max-content',
|
width: 'max-content',
|
||||||
maxWidth: '520px',
|
maxWidth: '520px',
|
||||||
|
|||||||
@@ -11,10 +11,6 @@ const options = [
|
|||||||
label: '--host',
|
label: '--host',
|
||||||
value: '--host'
|
value: '--host'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: '--port',
|
|
||||||
value: '--port'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: '--timeout',
|
label: '--timeout',
|
||||||
value: '--timeout'
|
value: '--timeout'
|
||||||
@@ -592,6 +588,22 @@ const options = [
|
|||||||
{
|
{
|
||||||
label: '--context-shift',
|
label: '--context-shift',
|
||||||
value: '--context-shift'
|
value: '--context-shift'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '--visual-max-image-cache',
|
||||||
|
value: '--visual-max-image-cache'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '--max-projected-cache',
|
||||||
|
value: '--max-projected-cache'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '--swa-full',
|
||||||
|
value: '--swa-full'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '--no-enable-reasoning',
|
||||||
|
value: '--no-enable-reasoning'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
import { ListItem as WorkerListItem } from '@/pages/resources/config/types';
|
import { ListItem as WorkerListItem } from '@/pages/resources/config/types';
|
||||||
import { convertFileSize } from '@/utils';
|
import { convertFileSize } from '@/utils';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
|
import { useDebounceFn } from 'ahooks';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import { evaluationsModelSpec, queryGPUList } from '../apis';
|
import { evaluationsModelSpec, queryGPUList } from '../apis';
|
||||||
@@ -522,7 +523,7 @@ export const useCheckCompatibility = () => {
|
|||||||
cacheFormValuesRef.current = allValues;
|
cacheFormValuesRef.current = allValues;
|
||||||
const data = getSourceRepoConfigValue(source, allValues);
|
const data = getSourceRepoConfigValue(source, allValues);
|
||||||
const gpuSelector = generateGPUIds(data.values);
|
const gpuSelector = generateGPUIds(data.values);
|
||||||
await handleDoEvalute({
|
return await handleDoEvalute({
|
||||||
...data.values,
|
...data.values,
|
||||||
...gpuSelector
|
...gpuSelector
|
||||||
});
|
});
|
||||||
@@ -546,7 +547,10 @@ export const useCheckCompatibility = () => {
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
const debounceHandleValuesChange = _.debounce(handleOnValuesChange, 500);
|
const { run: debounceHandleValuesChange } = useDebounceFn(
|
||||||
|
handleOnValuesChange,
|
||||||
|
{ wait: 500 }
|
||||||
|
);
|
||||||
|
|
||||||
const cancelEvaluate = () => {
|
const cancelEvaluate = () => {
|
||||||
checkTokenRef.current?.cancel();
|
checkTokenRef.current?.cancel();
|
||||||
@@ -570,6 +574,7 @@ export const useCheckCompatibility = () => {
|
|||||||
cancelEvaluate,
|
cancelEvaluate,
|
||||||
handleBackendChangeBefore,
|
handleBackendChangeBefore,
|
||||||
handleOnValuesChange: debounceHandleValuesChange,
|
handleOnValuesChange: debounceHandleValuesChange,
|
||||||
|
handleEvaluateOnChange: handleOnValuesChange,
|
||||||
warningStatus,
|
warningStatus,
|
||||||
checkTokenRef,
|
checkTokenRef,
|
||||||
submitAnyway
|
submitAnyway
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import IconFont from '@/components/icon-font';
|
import IconFont from '@/components/icon-font';
|
||||||
import HotKeys, { KeyMap } from '@/config/hotkeys';
|
import HotKeys, { KeyMap } from '@/config/hotkeys';
|
||||||
|
import { convertFileToBase64 } from '@/utils/load-audio-file';
|
||||||
import { ClearOutlined, SendOutlined, SwapOutlined } from '@ant-design/icons';
|
import { ClearOutlined, SendOutlined, SwapOutlined } from '@ant-design/icons';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Button, Checkbox, Divider, Input, Tooltip } from 'antd';
|
import { Button, Checkbox, Divider, Input, Tooltip } from 'antd';
|
||||||
@@ -19,6 +20,12 @@ import '../style/message-input.less';
|
|||||||
import ThumbImg from './thumb-img';
|
import ThumbImg from './thumb-img';
|
||||||
import UploadImg from './upload-img';
|
import UploadImg from './upload-img';
|
||||||
|
|
||||||
|
const audioTypeMap: Record<string, string> = {
|
||||||
|
'audio/wav': 'wav',
|
||||||
|
'audio/mp3': 'mp3',
|
||||||
|
'audio/mpeg': 'mp3'
|
||||||
|
};
|
||||||
|
|
||||||
type CurrentMessage = Omit<MessageItem, 'uid'>;
|
type CurrentMessage = Omit<MessageItem, 'uid'>;
|
||||||
|
|
||||||
type ActionType =
|
type ActionType =
|
||||||
@@ -260,6 +267,26 @@ const MessageInput: React.FC<MessageInputProps> = forwardRef(
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleUploadAudioChange = async (data: {
|
||||||
|
file: any;
|
||||||
|
fileList: any[];
|
||||||
|
}) => {
|
||||||
|
// convert audio file to base64
|
||||||
|
try {
|
||||||
|
console.log('audio file====', data.file);
|
||||||
|
const base64Audio = await convertFileToBase64(data.file);
|
||||||
|
setMessage({
|
||||||
|
...message,
|
||||||
|
audio: {
|
||||||
|
format: audioTypeMap[data.file.type],
|
||||||
|
dataUrl: base64Audio
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error converting audio to Base64:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleDeleteImg = (uid: number | string) => {
|
const handleDeleteImg = (uid: number | string) => {
|
||||||
const list = _.filter(
|
const list = _.filter(
|
||||||
message.imgs,
|
message.imgs,
|
||||||
@@ -360,6 +387,16 @@ const MessageInput: React.FC<MessageInputProps> = forwardRef(
|
|||||||
size="middle"
|
size="middle"
|
||||||
></UploadImg>
|
></UploadImg>
|
||||||
)}
|
)}
|
||||||
|
{/* {actions.includes('upload') && message.role === Roles.User && (
|
||||||
|
<UploadAudio
|
||||||
|
type="text"
|
||||||
|
accept={'.mp3,.wav'}
|
||||||
|
size="middle"
|
||||||
|
shape="default"
|
||||||
|
icon={<CustomerServiceOutlined />}
|
||||||
|
onChange={handleUploadAudioChange}
|
||||||
|
></UploadAudio>
|
||||||
|
)} */}
|
||||||
{tools}
|
{tools}
|
||||||
{actions.includes('clear') && (
|
{actions.includes('clear') && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export type MessageItemAction =
|
|||||||
export interface MessageItem {
|
export interface MessageItem {
|
||||||
content: string;
|
content: string;
|
||||||
imgs?: { uid: string | number; dataUrl: string }[];
|
imgs?: { uid: string | number; dataUrl: string }[];
|
||||||
|
audio?: { uid: string | number; dataUrl: string; format: 'wav' | 'mp3' };
|
||||||
role: string;
|
role: string;
|
||||||
title?: React.ReactNode;
|
title?: React.ReactNode;
|
||||||
uid: number;
|
uid: number;
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
import { convertFileSize } from './index';
|
import { convertFileSize } from './index';
|
||||||
|
|
||||||
|
export const convertFileToBase64 = (file: File): Promise<string> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
reader.onload = () => resolve(reader.result as string);
|
||||||
|
reader.onerror = (error) => reject(error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const loadAudioData = async (data: any, type: string) => {
|
export const loadAudioData = async (data: any, type: string) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user