chore: rerank documents verify non-empty
This commit is contained in:
@@ -42,6 +42,14 @@
|
|||||||
margin-left: 40px;
|
margin-left: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.m-t-16 {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-t-10 {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.m-r-10 {
|
.m-r-10 {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ const externalLinks = {
|
|||||||
export default externalLinks;
|
export default externalLinks;
|
||||||
|
|
||||||
export const externalRefer = {
|
export const externalRefer = {
|
||||||
audioPermission: `${externalLinks.documentation}latest/user-guide/playground/#audio-playground`
|
audioPermission: `${externalLinks.documentation}latest/user-guide/playground/#audio-speech-to-text`
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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 {
|
.login-wrapper {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ export default {
|
|||||||
'playground.rerank.score': 'Score',
|
'playground.rerank.score': 'Score',
|
||||||
'playground.rerank.query.holder': 'Input your query',
|
'playground.rerank.query.holder': 'Input your query',
|
||||||
'playground.image.prompt': 'Text Prompt',
|
'playground.image.prompt': 'Text Prompt',
|
||||||
|
'playground.audio.textinput': 'Text Input',
|
||||||
'playground.audio.texttospeech': 'Text to Speech',
|
'playground.audio.texttospeech': 'Text to Speech',
|
||||||
'playground.audio.speechtotext': 'Speech to Text',
|
'playground.audio.speechtotext': 'Speech to Text',
|
||||||
'playground.audio.texttospeech.tips': 'Generated speech will appear here',
|
'playground.audio.texttospeech.tips': 'Generated speech will appear here',
|
||||||
@@ -121,5 +122,7 @@ export default {
|
|||||||
'playgorund.audio.voice.error':
|
'playgorund.audio.voice.error':
|
||||||
'Voices are unavailable. The model may still be initializing. Please refresh after a brief wait.',
|
'Voices are unavailable. The model may still be initializing. Please refresh after a brief wait.',
|
||||||
'playground.params.size.description':
|
'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.'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ export default {
|
|||||||
'playground.rerank.score': '分数',
|
'playground.rerank.score': '分数',
|
||||||
'playground.rerank.query.holder': '输入查询',
|
'playground.rerank.query.holder': '输入查询',
|
||||||
'playground.image.prompt': '输入提示',
|
'playground.image.prompt': '输入提示',
|
||||||
|
'playground.audio.textinput': '输入文本',
|
||||||
'playground.audio.texttospeech': '文本转语音',
|
'playground.audio.texttospeech': '文本转语音',
|
||||||
'playground.audio.speechtotext': '语音转文本',
|
'playground.audio.speechtotext': '语音转文本',
|
||||||
'playground.audio.texttospeech.tips': '生成的语音将出现在这里',
|
'playground.audio.texttospeech.tips': '生成的语音将出现在这里',
|
||||||
@@ -118,5 +119,7 @@ export default {
|
|||||||
'playgorund.audio.voice.error':
|
'playgorund.audio.voice.error':
|
||||||
'声音无法使用。该模型可能仍在初始化。请稍候后刷新。',
|
'声音无法使用。该模型可能仍在初始化。请稍候后刷新。',
|
||||||
'playground.params.size.description':
|
'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([]);
|
setScatterData([]);
|
||||||
setTokenResult(null);
|
setTokenResult(null);
|
||||||
setLessTwoInput(false);
|
setLessTwoInput(false);
|
||||||
|
setEmbeddingData({
|
||||||
|
code: '',
|
||||||
|
copyValue: ''
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOutputTypeChange = (value: string) => {
|
const handleOutputTypeChange = (value: string) => {
|
||||||
@@ -522,7 +526,9 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
{lessTwoInput && (
|
{lessTwoInput && (
|
||||||
<AlertInfo
|
<AlertInfo
|
||||||
type="danger"
|
type="danger"
|
||||||
message="Please input at least two documents"
|
message={intl.formatMessage({
|
||||||
|
id: 'playground.documents.verify.embedding'
|
||||||
|
})}
|
||||||
></AlertInfo>
|
></AlertInfo>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import AlertInfo from '@/components/alert-info';
|
||||||
import HotKeys, { KeyMap } from '@/config/hotkeys';
|
import HotKeys, { KeyMap } from '@/config/hotkeys';
|
||||||
import useOverlayScroller from '@/hooks/use-overlay-scroller';
|
import useOverlayScroller from '@/hooks/use-overlay-scroller';
|
||||||
import useRequestToken from '@/hooks/use-request-token';
|
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 requestToken = useRef<any>(null);
|
||||||
const formRef = useRef<any>(null);
|
const formRef = useRef<any>(null);
|
||||||
const multiplePasteEnable = useRef<boolean>(true);
|
const multiplePasteEnable = useRef<boolean>(true);
|
||||||
|
const [isEmptyText, setIsEmptyText] = useState<boolean>(false);
|
||||||
const [fileList, setFileList] = useState<
|
const [fileList, setFileList] = useState<
|
||||||
{
|
{
|
||||||
text: string;
|
text: string;
|
||||||
@@ -200,6 +202,15 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
await formRef.current?.form.validateFields();
|
await formRef.current?.form.validateFields();
|
||||||
if (!parameters.model) return;
|
if (!parameters.model) return;
|
||||||
try {
|
try {
|
||||||
|
const documentList: any[] = [...textList, ...fileList];
|
||||||
|
|
||||||
|
const validDocus = documentList.filter((item) => item.text);
|
||||||
|
|
||||||
|
if (!validDocus.length) {
|
||||||
|
setIsEmptyText(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setIsEmptyText(false);
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setMessageId();
|
setMessageId();
|
||||||
setTokenResult(null);
|
setTokenResult(null);
|
||||||
@@ -210,8 +221,6 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
|
|
||||||
contentRef.current = current?.content || '';
|
contentRef.current = current?.content || '';
|
||||||
|
|
||||||
const documentList: any[] = [...textList, ...fileList];
|
|
||||||
|
|
||||||
const result: any = await rerankerQuery(
|
const result: any = await rerankerQuery(
|
||||||
{
|
{
|
||||||
model: parameters.model,
|
model: parameters.model,
|
||||||
@@ -422,6 +431,7 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
]);
|
]);
|
||||||
setFileList([]);
|
setFileList([]);
|
||||||
setTokenResult(null);
|
setTokenResult(null);
|
||||||
|
setIsEmptyText(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
useHotkeys(
|
useHotkeys(
|
||||||
@@ -489,16 +499,9 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Button
|
<span className="full-wrap">
|
||||||
ghost
|
|
||||||
variant="filled"
|
|
||||||
color="default"
|
|
||||||
style={{
|
|
||||||
border: 'none'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SendOutlined rotate={0} className="font-size-14" />
|
<SendOutlined rotate={0} className="font-size-14" />
|
||||||
</Button>
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
}
|
}
|
||||||
placeholder={intl.formatMessage({
|
placeholder={intl.formatMessage({
|
||||||
@@ -569,6 +572,16 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
extra={renderPercent}
|
extra={renderPercent}
|
||||||
onPaste={handleOnPaste}
|
onPaste={handleOnPaste}
|
||||||
></InputList>
|
></InputList>
|
||||||
|
{isEmptyText && (
|
||||||
|
<div className="m-t-16">
|
||||||
|
<AlertInfo
|
||||||
|
type="danger"
|
||||||
|
message={intl.formatMessage({
|
||||||
|
id: 'playground.documents.verify.rerank'
|
||||||
|
})}
|
||||||
|
></AlertInfo>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div></div>
|
<div></div>
|
||||||
|
|||||||
@@ -392,6 +392,11 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
minRows: 5,
|
minRows: 5,
|
||||||
maxRows: 5
|
maxRows: 5
|
||||||
}}
|
}}
|
||||||
|
title={
|
||||||
|
<span className="font-600">
|
||||||
|
{intl.formatMessage({ id: 'playground.audio.textinput' })}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
onCheck={handleOnCheckChange}
|
onCheck={handleOnCheckChange}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
disabled={!parameters.model}
|
disabled={!parameters.model}
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ interface MessageInputProps {
|
|||||||
submitIcon?: React.ReactNode;
|
submitIcon?: React.ReactNode;
|
||||||
presetPrompt?: (list: CurrentMessage[]) => void;
|
presetPrompt?: (list: CurrentMessage[]) => void;
|
||||||
addMessage?: (message: CurrentMessage) => void;
|
addMessage?: (message: CurrentMessage) => void;
|
||||||
|
title?: React.ReactNode;
|
||||||
tools?: React.ReactNode;
|
tools?: React.ReactNode;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
@@ -107,6 +108,7 @@ const MessageInput: React.FC<MessageInputProps> = forwardRef(
|
|||||||
updateLayout,
|
updateLayout,
|
||||||
addMessage,
|
addMessage,
|
||||||
onCheck,
|
onCheck,
|
||||||
|
title,
|
||||||
loading,
|
loading,
|
||||||
disabled,
|
disabled,
|
||||||
isEmpty,
|
isEmpty,
|
||||||
|
|||||||
Reference in New Issue
Block a user