fix: rerank clear failed

This commit is contained in:
jialin
2024-11-27 22:47:53 +08:00
parent 324bd57e3d
commit af789ee886
9 changed files with 223 additions and 160 deletions
@@ -7,11 +7,12 @@ import useRequestToken from '@/hooks/use-request-token';
import {
ClearOutlined,
HolderOutlined,
InfoCircleOutlined,
PlusOutlined,
SendOutlined
} from '@ant-design/icons';
import { useIntl, useSearchParams } from '@umijs/max';
import { Button, Checkbox, Segmented, Tabs } from 'antd';
import { Button, Checkbox, Segmented, Tabs, Tooltip } from 'antd';
import classNames from 'classnames';
import { PCA } from 'ml-pca';
import 'overlayscrollbars/overlayscrollbars.css';
@@ -98,6 +99,7 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
]);
const [scatterData, setScatterData] = useState<any[]>([]);
const resizeMaxHeight = 400;
const { initialize, updateScrollerPosition: updateDocumentScrollerPosition } =
useOverlayScroller();
@@ -252,7 +254,10 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
d: any
) => {
console.log('handleScaleOutputSize', e, direction, ref, d);
if (d.height + outputHeight <= 300 && d.height + outputHeight >= 180) {
if (
d.height + outputHeight <= resizeMaxHeight &&
d.height + outputHeight >= 180
) {
setOutputHeight(d.height + outputHeight);
}
};
@@ -277,18 +282,19 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
if (!multiplePasteEnable.current) return;
const text = e.clipboardData.getData('text');
if (text) {
console.log('text:', text);
const dataLlist = text
.split('\n')
.map((item: string) => {
return {
text: item?.trim(),
uid: inputListRef.current?.setMessageId(),
name: ''
};
})
.filter((item: any) => item.text);
setTextList([...textList.slice(0, index), ...dataLlist]);
const dataLlist = text.split('\n').map((item: string) => {
return {
text: item?.trim(),
uid: inputListRef.current?.setMessageId(),
name: ''
};
});
const result = [
...textList.slice(0, index),
...dataLlist,
...textList.slice(index + 1)
].filter((item) => item.text);
setTextList(result);
}
},
[textList]
@@ -408,24 +414,6 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
})}
</Checkbox>
</Button>
{/* <Tooltip
title={intl.formatMessage({
id: 'playground.input.multiplePaste'
})}
>
<Switch
checkedChildren={intl.formatMessage({
id: 'playground.multiple.on'
})}
unCheckedChildren={intl.formatMessage({
id: 'playground.multiple.off'
})}
defaultChecked={multiplePasteEnable.current}
onChange={(checked) => {
multiplePasteEnable.current = checked;
}}
/>
</Tooltip> */}
<Button size="middle" onClick={handleAddText}>
<PlusOutlined />
{intl.formatMessage({ id: 'playground.embedding.addtext' })}
@@ -497,8 +485,28 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
>
<h3 className="m-l-10 flex-between flex-center font-size-14 line-24 m-b-16">
<div className="flex gap-20">
<span>
<span className="flex-center">
{intl.formatMessage({ id: 'playground.embedding.output' })}
<Tooltip
title={
<span className="flex-column">
<span>
1.
{intl.formatMessage({
id: 'playground.embedding.pcatips1'
})}
</span>
<span>
2.{' '}
{intl.formatMessage({
id: 'playground.embedding.pcatips2'
})}
</span>
</span>
}
>
<InfoCircleOutlined className="m-l-4" />
</Tooltip>
</span>
<AlertInfo
type="danger"
@@ -529,21 +537,27 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
}}
handleComponent={{
top: (
<Button
size="small"
className="drag-handler"
color="default"
variant="filled"
icon={
<HolderOutlined
rotate={90}
style={{ fontSize: 'var(--font-size-14)' }}
/>
}
></Button>
<Tooltip
title={intl.formatMessage({
id: 'playground.embedding.handler.tips'
})}
>
<Button
size="small"
className="drag-handler"
color="default"
variant="filled"
icon={
<HolderOutlined
rotate={90}
style={{ fontSize: 'var(--font-size-14)' }}
/>
}
></Button>
</Tooltip>
)
}}
maxHeight={300}
maxHeight={resizeMaxHeight}
minHeight={180}
onResizeStop={handleScaleOutputSize}
>
@@ -231,7 +231,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
const result: any = await fetchChunkedData({
data: params,
url: CREAT_IMAGE_API,
url: `${CREAT_IMAGE_API}?t=${Date.now()}`,
signal: requestToken.current.signal
});
@@ -301,8 +301,8 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
form.current?.form?.setFieldsValue({
seed: null,
sampler: 'euler_a',
cfg_scale: 1,
sample_steps: 5,
cfg_scale: 4.5,
sample_steps: 10,
negative_prompt: null
});
setParams((pre: object) => {
@@ -310,8 +310,8 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
..._.omit(pre, ['quality', 'style']),
seed: null,
sampler: 'euler_a',
cfg_scale: 1,
sample_steps: 5,
cfg_scale: 4.5,
sample_steps: 10,
negative_prompt: null
};
});
@@ -350,17 +350,19 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
const text = e.clipboardData.getData('text');
if (text) {
console.log('text:', text);
const dataLlist = text
.split('\n')
.map((item: string) => {
return {
text: item?.trim(),
uid: inputListRef.current?.setMessageId(),
name: ''
};
})
.filter((item: any) => item.text);
setTextList([...textList.slice(0, index), ...dataLlist]);
const dataLlist = text.split('\n').map((item: string) => {
return {
text: item?.trim(),
uid: inputListRef.current?.setMessageId(),
name: ''
};
});
const result = [
...textList.slice(0, index),
...dataLlist,
...textList.slice(index + 1)
].filter((item) => item.text);
setTextList(result);
}
},
[textList]
@@ -475,24 +477,6 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
})}
</Checkbox>
</Button>
{/* <Tooltip
title={intl.formatMessage({
id: 'playground.input.multiplePaste'
})}
>
<Switch
checkedChildren={intl.formatMessage({
id: 'playground.multiple.on'
})}
unCheckedChildren={intl.formatMessage({
id: 'playground.multiple.off'
})}
defaultChecked={multiplePasteEnable.current}
onChange={(checked) => {
multiplePasteEnable.current = checked;
}}
/>
</Tooltip> */}
<Button size="middle" onClick={handleAddText}>
<PlusOutlined />
{intl.formatMessage({ id: 'playground.embedding.addtext' })}
@@ -508,6 +492,7 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
</div>
<div className="docs-wrapper">
<InputList
key={messageId.current}
sortIndex={sortIndexMap}
ref={inputListRef}
textList={textList}
@@ -253,7 +253,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
alignItems: 'center'
}}
>
<div className="content">
<div className="content" style={{ maxWidth: 1000 }}>
{messageList.length ? (
<SpeechContent dataList={messageList} loading={loading} />
) : (
+6 -4
View File
@@ -263,7 +263,8 @@ export const ImageAdvancedParamsConfig: ParamsSchema[] = [
},
attrs: {
min: 1,
max: 100
max: 100,
defaultValue: 10
},
rules: [
{
@@ -275,13 +276,14 @@ export const ImageAdvancedParamsConfig: ParamsSchema[] = [
type: 'InputNumber',
name: 'cfg_scale',
label: {
text: 'playground.image.params.cfgScale',
isLocalized: true
text: 'CFG Scale',
isLocalized: false
},
attrs: {
min: 1.0,
max: 10,
step: 0.1
step: 0.1,
defaulValue: 4.5
},
rules: [
{