[Update/Chore] Config Page: Add 'CTranslate2 Compute Type' Selection.
UI: Rename 'CTranslate2 compute device' to 'Translation compute device'.
This commit is contained in:
@@ -133,8 +133,10 @@ config_page:
|
||||
desc: "You can choose the translation model when using the {{ctranslate2}} translation engine."
|
||||
small: "Basic Model ({{capacity}})"
|
||||
large: "High Accuracy Model ({{capacity}})"
|
||||
ctranslate2_compute_device:
|
||||
label: "Processing device for AI translation {{ctranslate2}}"
|
||||
ctranslate2_compute_type:
|
||||
label: "Processing type for AI translation {{ctranslate2}}"
|
||||
translation_compute_device:
|
||||
label: "Processing device for AI translation"
|
||||
deepl_auth_key:
|
||||
label: "DeepL Auth Key"
|
||||
desc: "When using it, please change {{translator}} on the main screen to DeepL_API. ※Some languages may not be supported."
|
||||
|
||||
@@ -133,8 +133,10 @@ config_page:
|
||||
desc: "翻訳エンジン「{{ctranslate2}}」で翻訳する際に、使用する翻訳モデルを選択できます。"
|
||||
small: "通常モデル ({{capacity}})"
|
||||
large: "高精度モデル ({{capacity}})"
|
||||
ctranslate2_compute_device:
|
||||
label: "AI翻訳 {{ctranslate2}} の処理デバイス"
|
||||
ctranslate2_compute_type:
|
||||
label: "AI翻訳 {{ctranslate2}} の処理タイプ"
|
||||
translation_compute_device:
|
||||
label: "AI翻訳の処理デバイス"
|
||||
deepl_auth_key:
|
||||
label: "DeepL APIキーの登録"
|
||||
desc: "使用の際は、メイン画面にある {{translator}} をDeepL_APIに変更してください。\n※対応していない言語もあります。"
|
||||
|
||||
@@ -133,8 +133,10 @@ config_page:
|
||||
desc: "오프라인 번역 시의 번역 모델을 변경합니다."
|
||||
small: "일반 모델 ({{capacity}})"
|
||||
large: "정밀 모델 ({{capacity}})"
|
||||
ctranslate2_compute_device:
|
||||
label: "AI 번역 {{ctranslate2}} 처리 장치"
|
||||
ctranslate2_compute_type:
|
||||
label:
|
||||
translation_compute_device:
|
||||
label: "AI 번역 처리 장치"
|
||||
deepl_auth_key:
|
||||
label: "DeepL 인증키"
|
||||
desc: "사용시 메인화면에 있는 {{translator}}를 DeepL_API로 변경해 주세요.\n지원하지 않는 언어도 있습니다."
|
||||
|
||||
@@ -133,7 +133,9 @@ config_page:
|
||||
desc: "可以选择用于离线翻译的翻译模型"
|
||||
small: "普通模型 ({{capacity}})"
|
||||
large: "高精度模型 ({{capacity}})"
|
||||
ctranslate2_compute_device:
|
||||
ctranslate2_compute_type:
|
||||
label:
|
||||
translation_compute_device:
|
||||
label:
|
||||
deepl_auth_key:
|
||||
label: "DeepL 授权密匙"
|
||||
|
||||
@@ -133,7 +133,9 @@ config_page:
|
||||
desc: "你可以選擇用於離線翻譯引擎的翻譯模型。"
|
||||
small: "基本模型({{capacity}})"
|
||||
large: "高準確率模型({{capacity}})"
|
||||
ctranslate2_compute_device:
|
||||
ctranslate2_compute_type:
|
||||
label:
|
||||
translation_compute_device:
|
||||
label:
|
||||
deepl_auth_key:
|
||||
label: "DeepL 授權金鑰"
|
||||
|
||||
@@ -18,7 +18,8 @@ export const Translation = () => {
|
||||
return (
|
||||
<>
|
||||
<CTranslate2WeightType_Box />
|
||||
<CTranslation2ComputeDevice_Box />
|
||||
<CTranslate2ComputeType_Box />
|
||||
<TranslationComputeDevice_Box />
|
||||
<DeeplAuthKey_Box />
|
||||
</>
|
||||
);
|
||||
@@ -62,7 +63,7 @@ const CTranslate2WeightType_Box = () => {
|
||||
"config_page.translation.ctranslate2_weight_type.desc",
|
||||
{ctranslate2: "CTranslate2"}
|
||||
)}
|
||||
name="ctransalte2_weight_type"
|
||||
name="ctranslate2_weight_type"
|
||||
options={c_translate2_weight_types}
|
||||
checked_variable={currentSelectedCTranslate2WeightType}
|
||||
selectFunction={selectFunction}
|
||||
@@ -72,47 +73,72 @@ const CTranslate2WeightType_Box = () => {
|
||||
);
|
||||
};
|
||||
|
||||
// Duplicate
|
||||
import { useComputeMode } from "@logics_common";
|
||||
const CTranslation2ComputeDevice_Box = () => {
|
||||
const CTranslate2ComputeType_Box = () => {
|
||||
const { t } = useI18n();
|
||||
const { currentSelectedCTranslate2ComputeDevice, setSelectedCTranslate2ComputeDevice } = useTranslation();
|
||||
const { currentSelectableCTranslate2ComputeDeviceList } = useTranslation();
|
||||
const { currentSelectableCTranslate2ComputeTypeList } = useTranslation();
|
||||
const { currentSelectedCTranslate2ComputeType, setSelectedCTranslate2ComputeType } = useTranslation();
|
||||
|
||||
const selectFunction = (selected_data) => {
|
||||
const target_obj = currentSelectableCTranslate2ComputeDeviceList.data[selected_data.selected_id];
|
||||
setSelectedCTranslate2ComputeDevice(target_obj);
|
||||
setSelectedCTranslate2ComputeType(selected_data.selected_id);
|
||||
};
|
||||
|
||||
const list_for_ui = transformDeviceArray(currentSelectableCTranslate2ComputeDeviceList.data);
|
||||
const ctranslate2_compute_type_label = t("config_page.translation.ctranslate2_compute_type.label", {
|
||||
ctranslate2: "CTranslate2"
|
||||
});
|
||||
|
||||
const target_index = findKeyByDeviceValue(currentSelectableCTranslate2ComputeDeviceList.data, currentSelectedCTranslate2ComputeDevice.data);
|
||||
return (
|
||||
<DropdownMenuContainer
|
||||
dropdown_id="ctranslate2_compute_type"
|
||||
label={ctranslate2_compute_type_label}
|
||||
selected_id={currentSelectedCTranslate2ComputeType.data}
|
||||
list={currentSelectableCTranslate2ComputeTypeList.data}
|
||||
selectFunction={selectFunction}
|
||||
state={currentSelectedCTranslate2ComputeType.state}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
// Duplicate
|
||||
import { useComputeMode } from "@logics_common";
|
||||
const TranslationComputeDevice_Box = () => {
|
||||
const { t } = useI18n();
|
||||
const { currentSelectedTranslationComputeDevice, setSelectedTranslationComputeDevice } = useTranslation();
|
||||
const { currentSelectableTranslationComputeDeviceList } = useTranslation();
|
||||
|
||||
const selectFunction = (selected_data) => {
|
||||
const target_obj = currentSelectableTranslationComputeDeviceList.data[selected_data.selected_id];
|
||||
setSelectedTranslationComputeDevice(target_obj);
|
||||
};
|
||||
|
||||
const list_for_ui = transformDeviceArray(currentSelectableTranslationComputeDeviceList.data);
|
||||
|
||||
const target_index = findKeyByDeviceValue(currentSelectableTranslationComputeDeviceList.data, currentSelectedTranslationComputeDevice.data);
|
||||
|
||||
|
||||
const { currentComputeMode } = useComputeMode();
|
||||
const ctranslate2_compute_device_label = t("config_page.translation.ctranslate2_compute_device.label", {
|
||||
ctranslate2: "Ctranslate2"
|
||||
const translation_compute_device_label = t("config_page.translation.translation_compute_device.label", {
|
||||
ctranslate2: "CTranslate2"
|
||||
});
|
||||
if (currentComputeMode.data === "cpu") {
|
||||
return (
|
||||
<ComputeDeviceContainer
|
||||
label={ctranslate2_compute_device_label}
|
||||
label={translation_compute_device_label}
|
||||
selected_id={target_index}
|
||||
list={list_for_ui}
|
||||
selectFunction={selectFunction}
|
||||
state={currentSelectedCTranslate2ComputeDevice.state}
|
||||
state={currentSelectedTranslationComputeDevice.state}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<DropdownMenuContainer
|
||||
dropdown_id="ctranslate2_compute_device"
|
||||
label={ctranslate2_compute_device_label}
|
||||
dropdown_id="translation_compute_device"
|
||||
label={translation_compute_device_label}
|
||||
selected_id={target_index}
|
||||
list={list_for_ui}
|
||||
selectFunction={selectFunction}
|
||||
state={currentSelectedCTranslate2ComputeDevice.state}
|
||||
state={currentSelectedTranslationComputeDevice.state}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import {
|
||||
useStore_CTranslate2WeightTypeStatus,
|
||||
useStore_SelectedCTranslate2WeightType,
|
||||
useStore_SelectableCTranslate2ComputeDeviceList,
|
||||
useStore_SelectedCTranslate2ComputeDevice,
|
||||
useStore_SelectableCTranslate2ComputeTypeList,
|
||||
useStore_SelectedCTranslate2ComputeType,
|
||||
useStore_SelectableTranslationComputeDeviceList,
|
||||
useStore_SelectedTranslationComputeDevice,
|
||||
useStore_DeepLAuthKey,
|
||||
} from "@store";
|
||||
import { useStdoutToPython } from "@useStdoutToPython";
|
||||
import { useI18n } from "@useI18n";
|
||||
import { transformToIndexedArray } from "@utils";
|
||||
import { transformToIndexedArray, arrayToObject } from "@utils";
|
||||
import { useNotificationStatus } from "@logics_common";
|
||||
|
||||
export const useTranslation = () => {
|
||||
@@ -17,8 +19,13 @@ export const useTranslation = () => {
|
||||
|
||||
const { currentCTranslate2WeightTypeStatus, updateCTranslate2WeightTypeStatus, pendingCTranslate2WeightTypeStatus } = useStore_CTranslate2WeightTypeStatus();
|
||||
const { currentSelectedCTranslate2WeightType, updateSelectedCTranslate2WeightType, pendingSelectedCTranslate2WeightType } = useStore_SelectedCTranslate2WeightType();
|
||||
const { currentSelectableCTranslate2ComputeDeviceList, updateSelectableCTranslate2ComputeDeviceList, pendingSelectableCTranslate2ComputeDeviceList } = useStore_SelectableCTranslate2ComputeDeviceList();
|
||||
const { currentSelectedCTranslate2ComputeDevice, updateSelectedCTranslate2ComputeDevice, pendingSelectedCTranslate2ComputeDevice } = useStore_SelectedCTranslate2ComputeDevice();
|
||||
|
||||
const { currentSelectableCTranslate2ComputeTypeList, updateSelectableCTranslate2ComputeTypeList, pendingSelectableCTranslate2ComputeTypeList } = useStore_SelectableCTranslate2ComputeTypeList();
|
||||
const { currentSelectedCTranslate2ComputeType, updateSelectedCTranslate2ComputeType, pendingSelectedCTranslate2ComputeType } = useStore_SelectedCTranslate2ComputeType();
|
||||
|
||||
const { currentSelectableTranslationComputeDeviceList, updateSelectableTranslationComputeDeviceList, pendingSelectableTranslationComputeDeviceList } = useStore_SelectableTranslationComputeDeviceList();
|
||||
const { currentSelectedTranslationComputeDevice, updateSelectedTranslationComputeDevice, pendingSelectedTranslationComputeDevice } = useStore_SelectedTranslationComputeDevice();
|
||||
|
||||
const { currentDeepLAuthKey, updateDeepLAuthKey, pendingDeepLAuthKey } = useStore_DeepLAuthKey();
|
||||
|
||||
|
||||
@@ -80,28 +87,56 @@ export const useTranslation = () => {
|
||||
};
|
||||
|
||||
|
||||
const getSelectableCTranslate2ComputeDeviceList = () => {
|
||||
pendingSelectableCTranslate2ComputeDeviceList();
|
||||
|
||||
const getSelectableCTranslate2ComputeTypeList = () => {
|
||||
pendingSelectableCTranslate2ComputeTypeList();
|
||||
asyncStdoutToPython("/get/data/ctranslate2_compute_type_list");
|
||||
};
|
||||
|
||||
const updateSelectableCTranslate2ComputeTypeList_FromBackend = (payload) => {
|
||||
updateSelectableCTranslate2ComputeTypeList(arrayToObject(payload));
|
||||
};
|
||||
|
||||
|
||||
const getSelectedCTranslate2ComputeType = () => {
|
||||
pendingSelectedCTranslate2ComputeType();
|
||||
asyncStdoutToPython("/get/data/ctranslate2_compute_type");
|
||||
};
|
||||
|
||||
const setSelectedCTranslate2ComputeType = (selected_ctranslate2_compute_type) => {
|
||||
pendingSelectedCTranslate2ComputeType();
|
||||
asyncStdoutToPython("/set/data/ctranslate2_compute_type", selected_ctranslate2_compute_type);
|
||||
};
|
||||
|
||||
const setSuccessSelectedCTranslate2ComputeType = (selected_ctranslate2_compute_type) => {
|
||||
updateSelectedCTranslate2ComputeType(selected_ctranslate2_compute_type);
|
||||
showNotification_SaveSuccess();
|
||||
};
|
||||
|
||||
|
||||
|
||||
const getSelectableTranslationComputeDeviceList = () => {
|
||||
pendingSelectableTranslationComputeDeviceList();
|
||||
asyncStdoutToPython("/get/data/translation_compute_device_list");
|
||||
};
|
||||
|
||||
const updateSelectableCTranslate2ComputeDeviceList_FromBackend = (payload) => {
|
||||
updateSelectableCTranslate2ComputeDeviceList(transformToIndexedArray(payload));
|
||||
const updateSelectableTranslationComputeDeviceList_FromBackend = (payload) => {
|
||||
updateSelectableTranslationComputeDeviceList(transformToIndexedArray(payload));
|
||||
};
|
||||
|
||||
|
||||
const getSelectedCTranslate2ComputeDevice = () => {
|
||||
pendingSelectedCTranslate2ComputeDevice();
|
||||
const getSelectedTranslationComputeDevice = () => {
|
||||
pendingSelectedTranslationComputeDevice();
|
||||
asyncStdoutToPython("/get/data/selected_translation_compute_device");
|
||||
};
|
||||
|
||||
const setSelectedCTranslate2ComputeDevice = (selected_translation_compute_device) => {
|
||||
pendingSelectedCTranslate2ComputeDevice();
|
||||
const setSelectedTranslationComputeDevice = (selected_translation_compute_device) => {
|
||||
pendingSelectedTranslationComputeDevice();
|
||||
asyncStdoutToPython("/set/data/selected_translation_compute_device", selected_translation_compute_device);
|
||||
};
|
||||
|
||||
const setSuccessSelectedCTranslate2ComputeDevice = (selected_translation_compute_device) => {
|
||||
updateSelectedCTranslate2ComputeDevice(selected_translation_compute_device);
|
||||
const setSuccessSelectedTranslationComputeDevice = (selected_translation_compute_device) => {
|
||||
updateSelectedTranslationComputeDevice(selected_translation_compute_device);
|
||||
showNotification_SaveSuccess();
|
||||
};
|
||||
|
||||
@@ -146,16 +181,29 @@ export const useTranslation = () => {
|
||||
setSelectedCTranslate2WeightType,
|
||||
setSuccessSelectedCTranslate2WeightType,
|
||||
|
||||
currentSelectableCTranslate2ComputeDeviceList,
|
||||
getSelectableCTranslate2ComputeDeviceList,
|
||||
updateSelectableCTranslate2ComputeDeviceList,
|
||||
updateSelectableCTranslate2ComputeDeviceList_FromBackend,
|
||||
|
||||
currentSelectedCTranslate2ComputeDevice,
|
||||
getSelectedCTranslate2ComputeDevice,
|
||||
updateSelectedCTranslate2ComputeDevice,
|
||||
setSelectedCTranslate2ComputeDevice,
|
||||
setSuccessSelectedCTranslate2ComputeDevice,
|
||||
currentSelectableCTranslate2ComputeTypeList,
|
||||
getSelectableCTranslate2ComputeTypeList,
|
||||
updateSelectableCTranslate2ComputeTypeList,
|
||||
updateSelectableCTranslate2ComputeTypeList_FromBackend,
|
||||
|
||||
currentSelectedCTranslate2ComputeType,
|
||||
getSelectedCTranslate2ComputeType,
|
||||
updateSelectedCTranslate2ComputeType,
|
||||
setSelectedCTranslate2ComputeType,
|
||||
setSuccessSelectedCTranslate2ComputeType,
|
||||
|
||||
|
||||
currentSelectableTranslationComputeDeviceList,
|
||||
getSelectableTranslationComputeDeviceList,
|
||||
updateSelectableTranslationComputeDeviceList,
|
||||
updateSelectableTranslationComputeDeviceList_FromBackend,
|
||||
|
||||
currentSelectedTranslationComputeDevice,
|
||||
getSelectedTranslationComputeDevice,
|
||||
updateSelectedTranslationComputeDevice,
|
||||
setSelectedTranslationComputeDevice,
|
||||
setSuccessSelectedTranslationComputeDevice,
|
||||
|
||||
currentDeepLAuthKey,
|
||||
getDeepLAuthKey,
|
||||
|
||||
@@ -168,19 +168,22 @@ export const ROUTE_META_LIST = [
|
||||
{ endpoint: "/delete/data/deepl_auth_key", ns: configs, hook_name: "useTranslation", method_name: "deleteSuccessDeepLAuthKey" },
|
||||
|
||||
// Translation (AI Models)
|
||||
{ endpoint: "/get/data/selectable_ctranslate2_weight_type_dict", ns: configs, hook_name: "useTranslation", method_name: "updateDownloadedCTranslate2WeightTypeStatus" },
|
||||
{ endpoint: "/get/data/ctranslate2_weight_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedCTranslate2WeightType" },
|
||||
{ endpoint: "/set/data/ctranslate2_weight_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedCTranslate2WeightType" },
|
||||
|
||||
{ endpoint: "/get/data/selectable_ctranslate2_weight_type_dict", ns: configs, hook_name: "useTranslation", method_name: "updateDownloadedCTranslate2WeightTypeStatus" },
|
||||
{ endpoint: "/get/data/ctranslate2_compute_type_list", ns: configs, hook_name: "useTranslation", method_name: "updateSelectableCTranslate2ComputeTypeList_FromBackend" },
|
||||
{ endpoint: "/get/data/ctranslate2_compute_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedCTranslate2ComputeType" },
|
||||
{ endpoint: "/set/data/ctranslate2_compute_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedCTranslate2ComputeType" },
|
||||
|
||||
{ endpoint: "/run/downloaded_ctranslate2_weight", ns: configs, hook_name: "useTranslation", method_name: "downloadedCTranslate2WeightType" },
|
||||
{ endpoint: "/run/download_ctranslate2_weight", ns: null, hook_name: null, method_name: null },
|
||||
{ endpoint: "/run/download_progress_ctranslate2_weight", ns: configs, hook_name: "useTranslation", method_name: "updateDownloadProgressCTranslate2WeightTypeStatus" },
|
||||
|
||||
{ endpoint: "/get/data/translation_compute_device_list", ns: configs, hook_name: "useTranslation", method_name: "updateSelectableCTranslate2ComputeDeviceList_FromBackend" },
|
||||
{ endpoint: "/get/data/translation_compute_device_list", ns: configs, hook_name: "useTranslation", method_name: "updateSelectableTranslationComputeDeviceList_FromBackend" },
|
||||
|
||||
{ endpoint: "/get/data/selected_translation_compute_device", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedCTranslate2ComputeDevice" },
|
||||
{ endpoint: "/set/data/selected_translation_compute_device", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedCTranslate2ComputeDevice" },
|
||||
{ endpoint: "/get/data/selected_translation_compute_device", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedTranslationComputeDevice" },
|
||||
{ endpoint: "/set/data/selected_translation_compute_device", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedTranslationComputeDevice" },
|
||||
|
||||
|
||||
// Transcription
|
||||
|
||||
@@ -218,10 +218,15 @@ export const { atomInstance: Atom_MicWordFilterList, useHook: useStore_MicWordFi
|
||||
// Translation
|
||||
export const { atomInstance: Atom_DeepLAuthKey, useHook: useStore_DeepLAuthKey } = createAtomWithHook(null, "DeepLAuthKey");
|
||||
export const { atomInstance: Atom_SelectedCTranslate2WeightType, useHook: useStore_SelectedCTranslate2WeightType } = createAtomWithHook("", "SelectedCTranslate2WeightType");
|
||||
export const { atomInstance: Atom_SelectableCTranslate2ComputeDeviceList, useHook: useStore_SelectableCTranslate2ComputeDeviceList } = createAtomWithHook({}, "SelectableCTranslate2ComputeDeviceList");
|
||||
export const { atomInstance: Atom_SelectedCTranslate2ComputeDevice, useHook: useStore_SelectedCTranslate2ComputeDevice } = createAtomWithHook("", "SelectedCTranslate2ComputeDevice");
|
||||
export const { atomInstance: Atom_CTranslate2WeightTypeStatus, useHook: useStore_CTranslate2WeightTypeStatus } = createAtomWithHook(ctranslate2_weight_type_status, "CTranslate2WeightTypeStatus");
|
||||
|
||||
export const { atomInstance: Atom_SelectableCTranslate2ComputeTypeList, useHook: useStore_SelectableCTranslate2ComputeTypeList } = createAtomWithHook({}, "SelectableCTranslate2ComputeTypeList");
|
||||
export const { atomInstance: Atom_SelectedCTranslate2ComputeType, useHook: useStore_SelectedCTranslate2ComputeType } = createAtomWithHook("", "SelectedCTranslate2ComputeType");
|
||||
|
||||
|
||||
export const { atomInstance: Atom_SelectableTranslationComputeDeviceList, useHook: useStore_SelectableTranslationComputeDeviceList } = createAtomWithHook({}, "SelectableTranslationComputeDeviceList");
|
||||
export const { atomInstance: Atom_SelectedTranslationComputeDevice, useHook: useStore_SelectedTranslationComputeDevice } = createAtomWithHook("", "SelectedTranslationComputeDevice");
|
||||
|
||||
// Transcription
|
||||
export const { atomInstance: Atom_MicRecordTimeout, useHook: useStore_MicRecordTimeout } = createAtomWithHook(0, "MicRecordTimeout");
|
||||
export const { atomInstance: Atom_MicPhraseTimeout, useHook: useStore_MicPhraseTimeout } = createAtomWithHook(0, "MicPhraseTimeout");
|
||||
|
||||
Reference in New Issue
Block a user