处理识别不到字典数据类型的错误
This commit is contained in:
parent
9a34ccc26b
commit
ce5b0123b6
@ -20,7 +20,7 @@ class VolcEngine(TranslateParent):
|
||||
@staticmethod
|
||||
def _start_translate_threads(tag_list: list, target_language: str, api_instance) -> dict:
|
||||
index = -1
|
||||
if type(tag_list[0] == dict):
|
||||
if isinstance(tag_list[0], dict):
|
||||
index = tag_list.pop(0)["index"]
|
||||
translate_text_request = volcenginesdktranslate20250301.TranslateTextRequest(
|
||||
source_language="en",
|
||||
@ -29,6 +29,8 @@ class VolcEngine(TranslateParent):
|
||||
)
|
||||
try:
|
||||
response = api_instance.translate_text(translate_text_request)
|
||||
if index == -1:
|
||||
return {"thread_status": True, "thread_data": response.translation_list}
|
||||
return {"thread_status": True, "thread_data": response.translation_list, "index": index}
|
||||
except ApiException as e:
|
||||
# 复制代码运行示例,请自行打印API错误信息。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user