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
+8
View File
@@ -42,6 +42,14 @@
margin-left: 40px;
}
.m-t-16 {
margin-top: 16px;
}
.m-t-10 {
margin-top: 10px;
}
.m-r-10 {
margin-right: 10px;
}
+1 -1
View File
@@ -9,5 +9,5 @@ const externalLinks = {
export default externalLinks;
export const externalRefer = {
audioPermission: `${externalLinks.documentation}latest/user-guide/playground/#audio-playground`
audioPermission: `${externalLinks.documentation}latest/user-guide/playground/#audio-speech-to-text`
};
+11
View File
@@ -713,6 +713,17 @@ body {
}
}
.full-wrap::after {
content: '';
display: flex;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 1;
}
.login-wrapper {
position: fixed;
top: 0;
+4 -1
View File
@@ -77,6 +77,7 @@ export default {
'playground.rerank.score': 'Score',
'playground.rerank.query.holder': 'Input your query',
'playground.image.prompt': 'Text Prompt',
'playground.audio.textinput': 'Text Input',
'playground.audio.texttospeech': 'Text to Speech',
'playground.audio.speechtotext': 'Speech to Text',
'playground.audio.texttospeech.tips': 'Generated speech will appear here',
@@ -121,5 +122,7 @@ export default {
'playgorund.audio.voice.error':
'Voices are unavailable. The model may still be initializing. Please refresh after a brief wait.',
'playground.params.size.description':
'The maximum size of the generated image is controlled by the deployment parameters of the model. <a href="https://github.com/gpustack/llama-box" target="_blank">Refer to</a>'
'The maximum size of the generated image is controlled by the deployment parameters of the model. <a href="https://github.com/gpustack/llama-box" target="_blank">Refer to</a>',
'playground.documents.verify.embedding': 'At least add two pieces of text.',
'playground.documents.verify.rerank': 'The documents cannot be empty.'
};
+4 -1
View File
@@ -77,6 +77,7 @@ export default {
'playground.rerank.score': '分数',
'playground.rerank.query.holder': '输入查询',
'playground.image.prompt': '输入提示',
'playground.audio.textinput': '输入文本',
'playground.audio.texttospeech': '文本转语音',
'playground.audio.speechtotext': '语音转文本',
'playground.audio.texttospeech.tips': '生成的语音将出现在这里',
@@ -118,5 +119,7 @@ export default {
'playgorund.audio.voice.error':
'声音无法使用。该模型可能仍在初始化。请稍候后刷新。',
'playground.params.size.description':
'图片生成的最大尺寸受控于模型的部署参数。<a href="https://github.com/gpustack/llama-box" target="_blank">参考文档</a>'
'图片生成的最大尺寸受控于模型的部署参数。<a href="https://github.com/gpustack/llama-box" target="_blank">参考文档</a>',
'playground.documents.verify.embedding': '至少输入两条文本',
'playground.documents.verify.rerank': '文档不能为空'
};
@@ -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,