Spaces:
Running
Running
jhj0517
commited on
Commit
·
51a408d
1
Parent(s):
99bfa9a
Apply `add_timestamp` in caching
Browse files
modules/translation/deepl_api.py
CHANGED
|
@@ -130,7 +130,8 @@ class DeepLAPI:
|
|
| 130 |
api_key=auth_key,
|
| 131 |
is_pro=is_pro,
|
| 132 |
source_lang=source_lang,
|
| 133 |
-
target_lang=target_lang
|
|
|
|
| 134 |
)
|
| 135 |
|
| 136 |
files_info = {}
|
|
@@ -212,7 +213,8 @@ class DeepLAPI:
|
|
| 212 |
def cache_parameters(api_key: str,
|
| 213 |
is_pro: bool,
|
| 214 |
source_lang: str,
|
| 215 |
-
target_lang: str
|
|
|
|
| 216 |
cached_params = load_yaml(DEFAULT_PARAMETERS_CONFIG_PATH)
|
| 217 |
cached_params["translation"]["deepl"] = {
|
| 218 |
"api_key": api_key,
|
|
@@ -220,4 +222,5 @@ class DeepLAPI:
|
|
| 220 |
"source_lang": source_lang,
|
| 221 |
"target_lang": target_lang
|
| 222 |
}
|
| 223 |
-
|
|
|
|
|
|
| 130 |
api_key=auth_key,
|
| 131 |
is_pro=is_pro,
|
| 132 |
source_lang=source_lang,
|
| 133 |
+
target_lang=target_lang,
|
| 134 |
+
add_timestamp=add_timestamp
|
| 135 |
)
|
| 136 |
|
| 137 |
files_info = {}
|
|
|
|
| 213 |
def cache_parameters(api_key: str,
|
| 214 |
is_pro: bool,
|
| 215 |
source_lang: str,
|
| 216 |
+
target_lang: str,
|
| 217 |
+
add_timestamp: bool):
|
| 218 |
cached_params = load_yaml(DEFAULT_PARAMETERS_CONFIG_PATH)
|
| 219 |
cached_params["translation"]["deepl"] = {
|
| 220 |
"api_key": api_key,
|
|
|
|
| 222 |
"source_lang": source_lang,
|
| 223 |
"target_lang": target_lang
|
| 224 |
}
|
| 225 |
+
cached_params["translation"]["add_timestamp"] = add_timestamp
|
| 226 |
+
save_yaml(cached_params, DEFAULT_PARAMETERS_CONFIG_PATH)
|
modules/translation/translation_base.py
CHANGED
|
@@ -80,7 +80,8 @@ class TranslationBase(ABC):
|
|
| 80 |
self.cache_parameters(model_size=model_size,
|
| 81 |
src_lang=src_lang,
|
| 82 |
tgt_lang=tgt_lang,
|
| 83 |
-
max_length=max_length
|
|
|
|
| 84 |
|
| 85 |
self.update_model(model_size=model_size,
|
| 86 |
src_lang=src_lang,
|
|
@@ -161,12 +162,14 @@ class TranslationBase(ABC):
|
|
| 161 |
def cache_parameters(model_size: str,
|
| 162 |
src_lang: str,
|
| 163 |
tgt_lang: str,
|
| 164 |
-
max_length: int
|
|
|
|
| 165 |
cached_params = load_yaml(DEFAULT_PARAMETERS_CONFIG_PATH)
|
| 166 |
cached_params["translation"]["nllb"] = {
|
| 167 |
"model_size": model_size,
|
| 168 |
"src_lang": src_lang,
|
| 169 |
"tgt_lang": tgt_lang,
|
| 170 |
-
"max_length": max_length
|
| 171 |
}
|
| 172 |
-
|
|
|
|
|
|
| 80 |
self.cache_parameters(model_size=model_size,
|
| 81 |
src_lang=src_lang,
|
| 82 |
tgt_lang=tgt_lang,
|
| 83 |
+
max_length=max_length,
|
| 84 |
+
add_timestamp=add_timestamp)
|
| 85 |
|
| 86 |
self.update_model(model_size=model_size,
|
| 87 |
src_lang=src_lang,
|
|
|
|
| 162 |
def cache_parameters(model_size: str,
|
| 163 |
src_lang: str,
|
| 164 |
tgt_lang: str,
|
| 165 |
+
max_length: int,
|
| 166 |
+
add_timestamp: bool):
|
| 167 |
cached_params = load_yaml(DEFAULT_PARAMETERS_CONFIG_PATH)
|
| 168 |
cached_params["translation"]["nllb"] = {
|
| 169 |
"model_size": model_size,
|
| 170 |
"src_lang": src_lang,
|
| 171 |
"tgt_lang": tgt_lang,
|
| 172 |
+
"max_length": max_length,
|
| 173 |
}
|
| 174 |
+
cached_params["translation"]["add_timestamp"] = add_timestamp
|
| 175 |
+
save_yaml(cached_params, DEFAULT_PARAMETERS_CONFIG_PATH)
|