This commit is contained in:
jialin
2025-06-20 19:34:04 +08:00
parent ca7dc02d88
commit 6be7140a47
18 changed files with 156 additions and 46 deletions
+19 -3
View File
@@ -206,6 +206,11 @@ const AddModal: FC<AddModalProps> = (props) => {
source: props.source
});
// for cancel evaluate request case
if (!evaluateRes) {
return;
}
const defaultSpec = getDefaultSpec({
evaluateResult: evaluateRes
});
@@ -254,10 +259,14 @@ const AddModal: FC<AddModalProps> = (props) => {
}
};
const handleCancelFiles = () => {
cancelEvaluate();
modelFileRef.current?.cancelRequest();
};
const handleOnSelectModel = async (item: any) => {
// If the item is empty or the same as the selected model, do nothing
console.log('handleOnSelectModel', item, selectedModel);
modelFileRef.current?.cancelRequest();
handleCancelFiles();
if (
_.isEmpty(item) ||
(item.isGGUF === selectedModel.isGGUF && item.name === selectedModel.name)
@@ -304,12 +313,18 @@ const AddModal: FC<AddModalProps> = (props) => {
state: EvaluateProccess.model,
requestModelId: updateRequestModelId()
});
modelFileRef.current?.cancelRequest();
handleCancelFiles();
const modelInfo = onSelectModel(item, props.source);
console.log(
'handleOnSelectModelAfterEvaluate',
item,
evaluateStateRef.current
);
if (
evaluateStateRef.current.state === EvaluateProccess.model &&
item.evaluateResult
item.evaluated
) {
handleShowCompatibleAlert(item.evaluateResult);
form.current?.setFieldsValue?.({
@@ -425,6 +440,7 @@ const AddModal: FC<AddModalProps> = (props) => {
handleOnOpen();
} else {
cancelEvaluate();
clearCahceFormValues();
}
return () => {
setSelectedModel({});
@@ -569,7 +569,6 @@ const Models: React.FC<ModelsProps> = ({
operation: 'common.start.confirm',
async onOk() {
await handleBatchRequest(rowSelection.selectedRows, handleStartModel);
rowSelection.clearSelections();
onStart?.();
}
});
@@ -583,7 +582,6 @@ const Models: React.FC<ModelsProps> = ({
operation: 'common.stop.confirm',
async onOk() {
await handleBatchRequest(rowSelection.selectedRows, handleStopModel);
rowSelection.clearSelections();
onStop?.(rowSelection.selectedRowKeys as number[]);
}
});
+5 -1
View File
@@ -298,6 +298,7 @@ export const useCheckCompatibility = () => {
options?: WarningStausOptions
) => {
const { lockAfterUpdate = false, override = false } = options || {};
console.log('updateWarningStatus', params, options);
setWarningStatus((prev: MessageStatus) => {
if (isLockWarningStatus.current && !override) {
@@ -348,6 +349,7 @@ export const useCheckCompatibility = () => {
const handleCheckCompatibility = (
evaluateResult: EvaluateResult | null
): MessageStatus => {
console.log('handleCheckCompatibility', evaluateResult);
if (!evaluateResult) {
return {
show: false,
@@ -586,14 +588,16 @@ export const useCheckCompatibility = () => {
);
const cancelEvaluate = () => {
// update the requestId to cancel the current evaluation
updateRequestId();
checkTokenRef.current?.cancel();
checkTokenRef.current = null;
cacheFormValuesRef.current = {};
};
useEffect(() => {
return () => {
cancelEvaluate();
clearCahceFormValues();
};
}, []);
@@ -9,7 +9,16 @@ import {
SendOutlined
} from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button, Checkbox, Form, Input, Spin, Tag, Tooltip } from 'antd';
import {
Button,
Checkbox,
Form,
Input,
Spin,
Tag,
Tooltip,
Typography
} from 'antd';
import classNames from 'classnames';
import _ from 'lodash';
import 'overlayscrollbars/overlayscrollbars.css';
@@ -22,6 +31,7 @@ import React, {
useRef,
useState
} from 'react';
import styled from 'styled-components';
import { rerankerQuery } from '../apis';
import { extractErrorMessage } from '../config';
import { ParamsSchema } from '../config/types';
@@ -36,6 +46,19 @@ import InputList from './input-list';
import TokenUsage from './token-usage';
import ViewCommonCode from './view-common-code';
const { Text } = Typography;
const SearchInputWrapper = styled.div`
margin: 16px 32px 10px;
position: relative;
`;
const ValidText = styled(Text)`
position: absolute;
bottom: -20px;
left: 0;
`;
interface MessageProps {
modelList: Global.BaseOption<string>[];
loaded?: boolean;
@@ -89,6 +112,7 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
rank?: number;
}[]
>([]);
const [isEmptyQuery, setIsEmptyQuery] = useState<boolean>(false);
const [textList, setTextList] = useState<
{
@@ -223,8 +247,10 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
const submitMessage = async (query: string) => {
try {
setIsEmptyQuery(!queryValue);
await formRef.current?.form.validateFields();
if (!parameters.model) return;
if (!parameters.model || !queryValue) return;
const documentList: any[] = [...textList, ...fileList];
const validDocus = documentList.filter((item) => item.text);
@@ -310,6 +336,7 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
const handleQueryChange = (e: any) => {
setQueryValue(e.target.value);
setIsEmptyQuery(!e.target.value);
};
const handleCloseViewCode = () => {
@@ -430,7 +457,7 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
>
<span>{intl.formatMessage({ id: 'playground.rerank.query' })}</span>
</h3>
<div style={{ margin: '16px 32px 10px' }}>
<SearchInputWrapper>
<Input.Search
allowClear
onSearch={handleSearch}
@@ -452,7 +479,12 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
id: 'playground.rerank.query.holder'
})}
></Input.Search>
</div>
{isEmptyQuery && (
<ValidText type="danger">
{intl.formatMessage({ id: 'playground.rerank.query.validate' })}
</ValidText>
)}
</SearchInputWrapper>
</div>
<div className="center" ref={scroller}>
<div className="documents">
+1 -1
View File
@@ -11,7 +11,7 @@
.doc-header {
margin-bottom: 16px;
padding-top: 16px;
margin-top: 16px;
position: sticky;
top: 0;
z-index: 100;