From 22984f53ec8fd05035e8ae83b9ce5cb20e77e018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:36:09 +0800 Subject: [PATCH] fix --- .../translator/dev_llm_common.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/LunaTranslator/LunaTranslator/translator/dev_llm_common.py b/LunaTranslator/LunaTranslator/translator/dev_llm_common.py index c6c05c5b..fe8b2941 100644 --- a/LunaTranslator/LunaTranslator/translator/dev_llm_common.py +++ b/LunaTranslator/LunaTranslator/translator/dev_llm_common.py @@ -2,6 +2,7 @@ from translator.basetranslator_dev import basetransdev import time, os from myutils.utils import createenglishlangmap + class commonllmdev(basetransdev): jsfile = ... textarea_selector = ... @@ -52,16 +53,22 @@ class commonllmdev(basetransdev): f"document.querySelector({repr(self.button_selector)}).click()" ) if self.config["usingstream"]: - curr = "" - while not self.Runtime_evaluate("hasdone")["result"]["value"]: + __ = [""] + + def ___(__): time.sleep(0.1) thistext = self.Runtime_evaluate("thistext")["result"]["value"] - if thistext.startswith(curr): - yield thistext[len(curr) :] + + if thistext.startswith(__[0]): + yield thistext[len(__[0]) :] else: - yield '\0' + yield "\0" yield thistext - curr = thistext + __[0] = thistext + + while not self.Runtime_evaluate("hasdone")["result"]["value"]: + yield from ___(__) + yield from ___(__) else: while not self.Runtime_evaluate("hasdone")["result"]["value"]: time.sleep(0.1)