mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
feat: add loading state to NLP prediction query
This commit is contained in:
parent
1288eb87cf
commit
4ff19ac57d
@ -1,11 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import AddIcon from "@mui/icons-material/Add";
|
import AddIcon from "@mui/icons-material/Add";
|
||||||
import Check from "@mui/icons-material/Check";
|
import Check from "@mui/icons-material/Check";
|
||||||
import DeleteIcon from "@mui/icons-material/Delete";
|
import DeleteIcon from "@mui/icons-material/Delete";
|
||||||
@ -65,6 +67,7 @@ const NlpDatasetSample: FC<NlpDatasetSampleProps> = ({
|
|||||||
hasCount: false,
|
hasCount: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
const getNlpValueFromCache = useGetFromCache(EntityType.NLP_VALUE);
|
const getNlpValueFromCache = useGetFromCache(EntityType.NLP_VALUE);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
const defaultValues: INlpSampleFormAttributes = useMemo(
|
const defaultValues: INlpSampleFormAttributes = useMemo(
|
||||||
@ -121,7 +124,12 @@ const NlpDatasetSample: FC<NlpDatasetSampleProps> = ({
|
|||||||
useQuery({
|
useQuery({
|
||||||
queryKey: ["nlp-prediction", currentText],
|
queryKey: ["nlp-prediction", currentText],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
return await apiClient.predictNlp(currentText);
|
setLoading(true);
|
||||||
|
try{
|
||||||
|
return await apiClient.predictNlp(currentText);
|
||||||
|
}finally{
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onSuccess: (result) => {
|
onSuccess: (result) => {
|
||||||
const traitEntities: INlpDatasetTraitEntity[] = result.entities.filter(
|
const traitEntities: INlpDatasetTraitEntity[] = result.entities.filter(
|
||||||
@ -226,6 +234,7 @@ const NlpDatasetSample: FC<NlpDatasetSampleProps> = ({
|
|||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
loading={loading}
|
||||||
/>
|
/>
|
||||||
</ContentItem>
|
</ContentItem>
|
||||||
<Box display="flex" flexDirection="column">
|
<Box display="flex" flexDirection="column">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user