fix: tts show error message
This commit is contained in:
@@ -2,9 +2,13 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
color: rgba(0, 0, 0, 45%);
|
||||||
|
font-size: var(--font-size-base);
|
||||||
|
|
||||||
.note-info {
|
.note-info {
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.star {
|
.star {
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 2px;
|
top: 2px;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { ParamsSchema } from '@/pages/playground/config/types';
|
import { ParamsSchema } from '@/pages/playground/config/types';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import React, { useCallback, useMemo } from 'react';
|
import React, { useCallback, useMemo } from 'react';
|
||||||
|
import LabelInfo from './components/label-info';
|
||||||
import componentsMap from './config/components';
|
import componentsMap from './config/components';
|
||||||
|
|
||||||
const FieldComponent: React.FC<ParamsSchema> = (props) => {
|
const FieldComponent: React.FC<ParamsSchema> = (props) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const { type, label, attrs, style, value, ...rest } = props;
|
const { type, label, attrs, style, value, ...rest } = props;
|
||||||
@@ -10,7 +10,16 @@ const FieldComponent: React.FC<ParamsSchema> = (props) => {
|
|||||||
(type: string) => {
|
(type: string) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'Checkbox':
|
case 'Checkbox':
|
||||||
return <span>{intl.formatMessage({ id: label.text })}</span>;
|
return (
|
||||||
|
<LabelInfo
|
||||||
|
required={props.required}
|
||||||
|
label={
|
||||||
|
label.isLocalized
|
||||||
|
? intl.formatMessage({ id: label.text })
|
||||||
|
: label.text
|
||||||
|
}
|
||||||
|
></LabelInfo>
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -360,7 +360,12 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
const formValues = form.current?.form?.getFieldsValue();
|
const formValues = form.current?.form?.getFieldsValue();
|
||||||
return ImageAdvancedParamsConfig.map((item: ParamsSchema) => {
|
return ImageAdvancedParamsConfig.map((item: ParamsSchema) => {
|
||||||
return (
|
return (
|
||||||
<Form.Item name={item.name} rules={item.rules} key={item.name}>
|
<Form.Item
|
||||||
|
name={item.name}
|
||||||
|
rules={item.rules}
|
||||||
|
key={item.name}
|
||||||
|
noStyle={item.name === 'random_seed'}
|
||||||
|
>
|
||||||
<FieldComponent
|
<FieldComponent
|
||||||
disabled={
|
disabled={
|
||||||
item.disabledConfig
|
item.disabledConfig
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
const [parameters, setParams] = useState<any>({});
|
const [parameters, setParams] = useState<any>({});
|
||||||
const [show, setShow] = useState(false);
|
const [show, setShow] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [tokenResult, setTokenResult] = useState<any>(null);
|
const [tokenResult, setTokenResult] = useState<any>();
|
||||||
const [collapse, setCollapse] = useState(false);
|
const [collapse, setCollapse] = useState(false);
|
||||||
const controllerRef = useRef<any>(null);
|
const controllerRef = useRef<any>(null);
|
||||||
const scroller = useRef<any>(null);
|
const scroller = useRef<any>(null);
|
||||||
@@ -96,7 +96,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const submitMessage = async (current?: { role: string; content: string }) => {
|
const submitMessage = async (current?: { role: string; content: string }) => {
|
||||||
// await formRef.current?.form.validateFields();
|
await formRef.current?.form.validateFields();
|
||||||
if (!parameters.model) return;
|
if (!parameters.model) return;
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -174,12 +174,26 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
const res = await queryModelVoices({
|
const res = await queryModelVoices({
|
||||||
model: value
|
model: value
|
||||||
});
|
});
|
||||||
|
console.log('res:', res);
|
||||||
|
if (res.error) {
|
||||||
|
setTokenResult({
|
||||||
|
error: true,
|
||||||
|
errorMessage:
|
||||||
|
res?.data?.error?.message ||
|
||||||
|
res?.data?.error ||
|
||||||
|
res.error?.detail ||
|
||||||
|
''
|
||||||
|
});
|
||||||
|
setVoiceList([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const voiceList = _.map(res.voices || [], (item: any) => {
|
const voiceList = _.map(res.voices || [], (item: any) => {
|
||||||
return {
|
return {
|
||||||
label: item,
|
label: item,
|
||||||
value: item
|
value: item
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
setVoiceList(voiceList);
|
setVoiceList(voiceList);
|
||||||
setParams((pre: any) => {
|
setParams((pre: any) => {
|
||||||
return {
|
return {
|
||||||
@@ -188,7 +202,16 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
formRef.current?.form.setFieldValue('voice', voiceList[0]?.value);
|
formRef.current?.form.setFieldValue('voice', voiceList[0]?.value);
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
|
const res = error?.response?.data;
|
||||||
|
if (res.error) {
|
||||||
|
setTokenResult({
|
||||||
|
error: true,
|
||||||
|
errorMessage:
|
||||||
|
res?.error?.message || res?.data?.error || res.error?.detail || ''
|
||||||
|
});
|
||||||
|
}
|
||||||
|
console.log('error:', error);
|
||||||
setVoiceList([]);
|
setVoiceList([]);
|
||||||
formRef.current?.form.setFieldValue('voice', '');
|
formRef.current?.form.setFieldValue('voice', '');
|
||||||
setParams((pre: any) => {
|
setParams((pre: any) => {
|
||||||
|
|||||||
@@ -322,19 +322,6 @@ export const ImageAdvancedParamsConfig: ParamsSchema[] = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
type: 'Checkbox',
|
|
||||||
name: 'random_seed',
|
|
||||||
label: {
|
|
||||||
text: 'playground.image.params.randomseed',
|
|
||||||
isLocalized: true
|
|
||||||
},
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
required: false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
type: 'InputNumber',
|
type: 'InputNumber',
|
||||||
name: 'seed',
|
name: 'seed',
|
||||||
@@ -354,5 +341,18 @@ export const ImageAdvancedParamsConfig: ParamsSchema[] = [
|
|||||||
required: false
|
required: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'Checkbox',
|
||||||
|
name: 'random_seed',
|
||||||
|
label: {
|
||||||
|
text: 'playground.image.params.randomseed',
|
||||||
|
isLocalized: true
|
||||||
|
},
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: false
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
export interface ModelSelectionItem extends Global.BaseOption<string> {
|
export interface ModelSelectionItem extends Global.BaseOption<string> {
|
||||||
uid: number;
|
uid: number;
|
||||||
instanceId: symbol;
|
instanceId: symbol;
|
||||||
@@ -43,8 +45,9 @@ export interface ParamsSchema {
|
|||||||
when: (values: Record<string, any>) => boolean;
|
when: (values: Record<string, any>) => boolean;
|
||||||
};
|
};
|
||||||
defaultValue?: string | number | boolean;
|
defaultValue?: string | number | boolean;
|
||||||
|
required?: boolean;
|
||||||
rules: { required: boolean; message?: string }[];
|
rules: { required: boolean; message?: string }[];
|
||||||
placeholder?: string;
|
placeholder?: React.ReactNode;
|
||||||
attrs?: Record<string, any>;
|
attrs?: Record<string, any>;
|
||||||
description?: {
|
description?: {
|
||||||
text: string;
|
text: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user