fix: model be cleared when apply config to all in compare

This commit is contained in:
jialin
2024-11-22 18:25:07 +08:00
parent c8c22b3f22
commit a6f0f554f0
14 changed files with 124 additions and 102 deletions
@@ -221,7 +221,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
setLoading(false);
};
const submitMessage = async (current?: { role: string; content: string }) => {
const submitMessage = async (current?: { content: string }) => {
try {
await form.current?.form?.validateFields();
if (!parameters.model) return;
@@ -255,10 +255,13 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
const result: any = await fetchChunkedData({
data: params,
// url: 'http://192.168.50.27:40639/v1/images/generations',
url: CREAT_IMAGE_API,
signal: requestToken.current.signal,
headers: {
accept: 'text/event-stream'
'Cache-Control': 'no-cache',
Accept: 'text/event-stream',
Connection: 'keep-alive'
}
});
@@ -281,8 +284,8 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
});
return;
}
const data = chunk?.data || [];
data.forEach((item: any) => {
console.log('data:================', chunk);
chunk?.data?.forEach((item: any) => {
const imgItem = newImageList[item.index];
newImageList[item.index] = {
dataUrl: `data:image/png;base64,${item.b64_json}`,
@@ -363,7 +366,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
>
<SealInput.Number
style={{ width: '100%' }}
label={intl.formatMessage({ id: 'playground.params.width' })}
label={`${intl.formatMessage({ id: 'playground.params.width' })}(px)`}
></SealInput.Number>
</Form.Item>
<Form.Item
@@ -385,7 +388,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
>
<SealInput.Number
style={{ width: '100%' }}
label="Height"
label={`${intl.formatMessage({ id: 'playground.params.height' })}(px)`}
></SealInput.Number>
</Form.Item>
</div>
@@ -44,7 +44,6 @@ interface ModelItemProps {
const ModelItem: React.FC<ModelItemProps> = forwardRef(
({ model, modelList, instanceId }, ref) => {
const {
spans,
globalParams,
setGlobalParams,
setLoadingStatus,
@@ -56,7 +55,9 @@ const ModelItem: React.FC<ModelItemProps> = forwardRef(
const intl = useIntl();
const isApplyToAllModels = useRef(false);
const [systemMessage, setSystemMessage] = useState<string>('');
const [params, setParams] = useState<Record<string, any>>({});
const [params, setParams] = useState<Record<string, any>>({
model: model
});
const [loading, setLoading] = useState(false);
const messageId = useRef<number>(0);
const [messageList, setMessageList] = useState<MessageItem[]>([]);
@@ -314,10 +315,9 @@ const ModelItem: React.FC<ModelItemProps> = forwardRef(
useEffect(() => {
setParams({
...params,
model: model,
...globalParams
});
}, [globalParams, model]);
}, [globalParams]);
useEffect(() => {
return () => {
@@ -52,21 +52,21 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = ({
useEffect(() => {
if (showModelSelector) {
form.setFieldsValue({
model: selectedModel || _.get(modelList, '[0].value'),
...initialValues
...initialValues,
model: selectedModel || _.get(modelList, '[0].value')
});
setParams({
model: selectedModel || _.get(modelList, '[0].value'),
...initialValues
...initialValues,
model: selectedModel || _.get(modelList, '[0].value')
});
} else {
form.setFieldsValue({
model: selectedModel || '',
...initialValues
...initialValues,
model: selectedModel || ''
});
setParams({
model: selectedModel || '',
...initialValues
...initialValues,
model: selectedModel || ''
});
}
}, [modelList, showModelSelector, selectedModel]);