chore: rerank documents verify non-empty

This commit is contained in:
jialin
2024-12-04 15:15:35 +08:00
parent bed3684a0c
commit 241930cefe
9 changed files with 66 additions and 15 deletions
@@ -339,6 +339,10 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
setScatterData([]);
setTokenResult(null);
setLessTwoInput(false);
setEmbeddingData({
code: '',
copyValue: ''
});
};
const handleOutputTypeChange = (value: string) => {
@@ -522,7 +526,9 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
{lessTwoInput && (
<AlertInfo
type="danger"
message="Please input at least two documents"
message={intl.formatMessage({
id: 'playground.documents.verify.embedding'
})}
></AlertInfo>
)}
</div>
@@ -1,3 +1,4 @@
import AlertInfo from '@/components/alert-info';
import HotKeys, { KeyMap } from '@/config/hotkeys';
import useOverlayScroller from '@/hooks/use-overlay-scroller';
import useRequestToken from '@/hooks/use-request-token';
@@ -86,6 +87,7 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
const requestToken = useRef<any>(null);
const formRef = useRef<any>(null);
const multiplePasteEnable = useRef<boolean>(true);
const [isEmptyText, setIsEmptyText] = useState<boolean>(false);
const [fileList, setFileList] = useState<
{
text: string;
@@ -200,6 +202,15 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
await formRef.current?.form.validateFields();
if (!parameters.model) return;
try {
const documentList: any[] = [...textList, ...fileList];
const validDocus = documentList.filter((item) => item.text);
if (!validDocus.length) {
setIsEmptyText(true);
return;
}
setIsEmptyText(false);
setLoading(true);
setMessageId();
setTokenResult(null);
@@ -210,8 +221,6 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
contentRef.current = current?.content || '';
const documentList: any[] = [...textList, ...fileList];
const result: any = await rerankerQuery(
{
model: parameters.model,
@@ -422,6 +431,7 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
]);
setFileList([]);
setTokenResult(null);
setIsEmptyText(false);
};
useHotkeys(
@@ -489,16 +499,9 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
</span>
}
>
<Button
ghost
variant="filled"
color="default"
style={{
border: 'none'
}}
>
<span className="full-wrap">
<SendOutlined rotate={0} className="font-size-14" />
</Button>
</span>
</Tooltip>
}
placeholder={intl.formatMessage({
@@ -569,6 +572,16 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
extra={renderPercent}
onPaste={handleOnPaste}
></InputList>
{isEmptyText && (
<div className="m-t-16">
<AlertInfo
type="danger"
message={intl.formatMessage({
id: 'playground.documents.verify.rerank'
})}
></AlertInfo>
</div>
)}
</div>
</div>
<div></div>
@@ -392,6 +392,11 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
minRows: 5,
maxRows: 5
}}
title={
<span className="font-600">
{intl.formatMessage({ id: 'playground.audio.textinput' })}
</span>
}
onCheck={handleOnCheckChange}
loading={loading}
disabled={!parameters.model}
@@ -85,6 +85,7 @@ interface MessageInputProps {
submitIcon?: React.ReactNode;
presetPrompt?: (list: CurrentMessage[]) => void;
addMessage?: (message: CurrentMessage) => void;
title?: React.ReactNode;
tools?: React.ReactNode;
loading: boolean;
disabled: boolean;
@@ -107,6 +108,7 @@ const MessageInput: React.FC<MessageInputProps> = forwardRef(
updateLayout,
addMessage,
onCheck,
title,
loading,
disabled,
isEmpty,