[Update] Config Page: Translation Tab. Add Internal Translation Weight Type Selector. Downloadable.
This commit is contained in:
@@ -31,7 +31,9 @@ export { useSpeakerRecordTimeout } from "./transcription/useSpeakerRecordTimeout
|
||||
export { useSpeakerPhraseTimeout } from "./transcription/useSpeakerPhraseTimeout";
|
||||
export { useSpeakerMaxWords } from "./transcription/useSpeakerMaxWords";
|
||||
|
||||
export { useCTranslate2WeightTypeStatus } from "./translation/useCTranslate2WeightTypeStatus";
|
||||
export { useDeepLAuthKey } from "./translation/useDeepLAuthKey";
|
||||
export { useSelectedCTranslate2WeightType } from "./translation/useSelectedCTranslate2WeightType";
|
||||
|
||||
export { useIsEnabledOverlaySmallLog } from "./vr/useIsEnabledOverlaySmallLog";
|
||||
export { useOverlaySettings } from "./vr/useOverlaySettings";
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import { useStore_CTranslate2WeightTypeStatus } from "@store";
|
||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||
|
||||
export const useCTranslate2WeightTypeStatus = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { currentCTranslate2WeightTypeStatus, updateCTranslate2WeightTypeStatus, pendingCTranslate2WeightTypeStatus } = useStore_CTranslate2WeightTypeStatus();
|
||||
|
||||
const updateDownloadedCTranslate2WeightTypeStatus = (downloaded_weight_type_status) => {
|
||||
updateCTranslate2WeightTypeStatus((old_status) =>
|
||||
old_status.data.map((item) => ({
|
||||
...item,
|
||||
is_downloaded: downloaded_weight_type_status[item.id] ?? item.is_downloaded,
|
||||
}))
|
||||
);
|
||||
};
|
||||
const updateDownloadProgressCTranslate2WeightTypeStatus = (payload) => {
|
||||
if (payload === true) return console.error("fix me.");
|
||||
|
||||
updateCTranslate2WeightTypeStatus((old_status) =>
|
||||
old_status.data.map((item) =>
|
||||
payload.weight_type === item.id
|
||||
? { ...item, progress: payload.progress * 100 }
|
||||
: item
|
||||
)
|
||||
);
|
||||
};
|
||||
const pendingCTranslate2WeightType = (id) => {
|
||||
updateCTranslate2WeightTypeStatus((old_status) =>
|
||||
old_status.data.map((item) =>
|
||||
id === item.id
|
||||
? { ...item, is_pending: true }
|
||||
: item
|
||||
)
|
||||
);
|
||||
};
|
||||
const downloadedCTranslate2WeightType = (id) => {
|
||||
updateCTranslate2WeightTypeStatus((old_status) =>
|
||||
old_status.data.map((item) =>
|
||||
id === item.id
|
||||
? { ...item, is_downloaded: true, is_pending: false, progress: null }
|
||||
: item
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
const downloadCTranslate2Weight = (weight_type) => {
|
||||
asyncStdoutToPython("/run/download_ctranslate2_weight", weight_type);
|
||||
};
|
||||
|
||||
return {
|
||||
currentCTranslate2WeightTypeStatus,
|
||||
updateCTranslate2WeightTypeStatus,
|
||||
|
||||
updateDownloadedCTranslate2WeightTypeStatus,
|
||||
updateDownloadProgressCTranslate2WeightTypeStatus,
|
||||
pendingCTranslate2WeightType,
|
||||
downloadedCTranslate2WeightType,
|
||||
downloadCTranslate2Weight,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useStore_SelectedCTranslate2WeightType } from "@store";
|
||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||
|
||||
export const useSelectedCTranslate2WeightType = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { currentSelectedCTranslate2WeightType, updateSelectedCTranslate2WeightType, pendingSelectedCTranslate2WeightType } = useStore_SelectedCTranslate2WeightType();
|
||||
|
||||
const getSelectedCTranslate2WeightType = () => {
|
||||
pendingSelectedCTranslate2WeightType();
|
||||
asyncStdoutToPython("/get/data/ctranslate2_weight_type");
|
||||
};
|
||||
|
||||
const setSelectedCTranslate2WeightType = (selected_ctranslate2_weight_type) => {
|
||||
pendingSelectedCTranslate2WeightType();
|
||||
asyncStdoutToPython("/set/data/ctranslate2_weight_type", selected_ctranslate2_weight_type);
|
||||
};
|
||||
|
||||
return {
|
||||
currentSelectedCTranslate2WeightType,
|
||||
getSelectedCTranslate2WeightType,
|
||||
updateSelectedCTranslate2WeightType,
|
||||
setSelectedCTranslate2WeightType,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user