diff --git a/python/model/BaiduCloud.py b/python/model/BaiduCloud.py index 3a5d018..9f2a78c 100644 --- a/python/model/BaiduCloud.py +++ b/python/model/BaiduCloud.py @@ -4,7 +4,6 @@ from model.TranslateModel import TranslateModel class BaiduCloud(TranslateModel): - def translate_text_with_machine(self, goto_translate_map: dict, source_language: str = "en", target_language: str = "zh") -> dict: if len(goto_translate_map) == 0: @@ -27,13 +26,11 @@ class BaiduCloud(TranslateModel): print(response_dict) return_false_code.update({"code": 10501}) # API接口错误 return return_false_code - print(response_dict) translate_context = response_dict["result"]["trans_result"][0]["dst"] translate_prompt_list = self.build_translate_tag_list(translate_context) for item in range(len(rebuild_list)): goto_translate_map[rebuild_list[item]].update({"translate": translate_prompt_list[item], - "translate_model": "network/百度机翻"}) - print(goto_translate_map) + "translate_model": "百度机器翻译"}) return_false_code.update({"status": True, "translate_map": goto_translate_map}) return return_false_code @@ -73,7 +70,7 @@ class BaiduCloud(TranslateModel): return return_false_code for item in range(len(rebuild_list)): goto_translate_map[rebuild_list[item]].update({"translate": translate_prompt_list[item], - "translate_model": "network/百度千帆大模型"}) + "translate_model": "百度千帆大模型"}) return_false_code.update({"status": True, "translate_map": goto_translate_map}) return return_false_code diff --git a/python/model/TencentCloud.py b/python/model/TencentCloud.py index 2848d72..256a99b 100644 --- a/python/model/TencentCloud.py +++ b/python/model/TencentCloud.py @@ -50,7 +50,7 @@ class TencentCloud(TranslateModel): for item in range(len(rebuild_list)): goto_translate_map[rebuild_list[item]].update({"translate": translate_prompt_list[item], - "translate_model": "network/腾讯混元大模型"}) + "translate_model": "腾讯混元大模型"}) return_false_code.update({"status": True, "translate_map": goto_translate_map}) return return_false_code @@ -84,7 +84,7 @@ class TencentCloud(TranslateModel): return return_false_code for item in range(len(rebuild_list)): goto_translate_map[rebuild_list[item]].update({"translate": network_translate_tag_list[item], - "translate_model": "network/腾讯机翻"}) + "translate_model": "腾讯机器翻译", }) return_false_code.update({"status": True, "translate_map": goto_translate_map}) return return_false_code diff --git a/python/routers/translate_rewrite.py b/python/routers/translate_rewrite.py index d071870..6fcd135 100644 --- a/python/routers/translate_rewrite.py +++ b/python/routers/translate_rewrite.py @@ -75,7 +75,7 @@ class OverwriteServerHandler(ServerHandler): else request_handler.translate_model, "translate_text": request_handler.translate_text, "is_rewrite": True} - print(self.return_web_data) + # print(self.return_web_data) def create_response_message(self): if self.return_web_data: diff --git a/python/routers/translate_with_ai.py b/python/routers/translate_with_ai.py index 8a73bb7..0c3271a 100644 --- a/python/routers/translate_with_ai.py +++ b/python/routers/translate_with_ai.py @@ -49,7 +49,8 @@ class OverwriteSqliteClient(SqliteClient): return result for item in result["result"]: translate_operation_map[item[0]].update({"translate": item[1], "translate_date": item[3], - "translate_model": f"local/{item[2]}"}) + "translate_model": f"{item[2]}", + "translate_source": "local"}) if debug: for item, value in translate_operation_map.items(): print(item, value) @@ -75,10 +76,13 @@ class OverwriteServerHandler(ServerHandler): prompt_text = prompt_text[:-1] source_list: list = prompt_text.split(",") source_list = [i.strip() for i in source_list] + # {'1girl': {'translate': '', 'index': 0, 'translate_date': '', 'translate_model': '',translate_source:"}, translate_operation_map: dict = {} for i in range(len(source_list)): translate_operation_map.update({source_list[i]: {"translate": "", "index": i, - "translate_date": "", "translate_model": ""}}) + "translate_date": "", "translate_model": "", + "translate_source": "network"}}) + # print(translate_operation_map) if request_handler.localhost_check_database: sqlite_client = OverwriteSqliteClient() result = sqlite_client.select_translate_record(translate_operation_map=translate_operation_map, @@ -131,12 +135,12 @@ class OverwriteServerHandler(ServerHandler): "translate": value["translate"], "name": f"{int(time.time()) + value['index']}", "active": True, - "is_rewrite": True if "local/" in value["translate_model"] else False, + "is_rewrite": False if value["translate_source"] == "network" else True, "translate_date": value["translate_date"], - "translate_model": value["translate_model"]}) - if debug: - for i in self.return_web_list: - print(i) + "translate_model": f'{value["translate_source"]}/{value["translate_model"]}'}) + if debug: + for i in self.return_web_list: + print(i) def create_response_message(self): if self.return_web_list: diff --git a/python/translate.db b/python/translate.db index 762f4bc..a81412a 100644 Binary files a/python/translate.db and b/python/translate.db differ diff --git a/view-ui-project-vite-main/src/views/TableVersion.vue b/view-ui-project-vite-main/src/views/TableVersion.vue index 197aecc..b894d7d 100644 --- a/view-ui-project-vite-main/src/views/TableVersion.vue +++ b/view-ui-project-vite-main/src/views/TableVersion.vue @@ -303,8 +303,8 @@ export default { { group_label: "机器翻译", items: [ - {value: "TencentModelMachine", label: "腾讯机翻"}, - {value: "BaiduModelMachine", label: "百度机翻"} + {value: "TencentModelMachine", label: "腾讯机器翻译"}, + {value: "BaiduModelMachine", label: "百度机器翻译"} ] }, ],