From 5353deed6485748d38334996a5cf2a09f478b0b1 Mon Sep 17 00:00:00 2001 From: TimoYoung Date: Tue, 22 Apr 2025 14:32:17 +0800 Subject: [PATCH] =?UTF-8?q?fix=20openai=5Fproxy=E5=90=AF=E7=94=A8=E6=97=B6?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/autosubv2/__init__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/autosubv2/__init__.py b/plugins/autosubv2/__init__.py index 7352e6b..9c58d27 100644 --- a/plugins/autosubv2/__init__.py +++ b/plugins/autosubv2/__init__.py @@ -749,9 +749,8 @@ class AutoSubv2(_PluginBase): context = self.__get_context(all_subs, indices, is_batch=True) if self.context_window > 0 else None batch_text = '\n'.join([item.content for item in batch]) - openai = OpenAi(self._openai_key, self._openai_url, self._openai_proxy, self._openai_model) try: - ret, result = openai.translate_to_zh(batch_text, context) + ret, result = self.openai.translate_to_zh(batch_text, context) if not ret: raise Exception(result) @@ -770,11 +769,10 @@ class AutoSubv2(_PluginBase): def __process_single(self, all_subs: List[srt.Subtitle], item: srt.Subtitle) -> srt.Subtitle: """单条处理逻辑""" - openai = OpenAi(self._openai_key, self._openai_url, self._openai_proxy, self._openai_model) for _ in range(self.max_retries): idx = all_subs.index(item) context = self.__get_context(all_subs, [idx], is_batch=False) if self.context_window > 0 else None - success, trans = openai.translate_to_zh(item.content, context) + success, trans = self.openai.translate_to_zh(item.content, context) if success: item.content = f"{trans}\n{item.content}"