Byaidu 1 год назад
Родитель
Сommit
beb85174ca
6 измененных файлов с 8 добавлено и 12 удалено
  1. 1 2
      README.md
  2. 1 2
      README_ja-JP.md
  3. 1 2
      README_zh-CN.md
  4. 1 1
      pdf2zh/__init__.py
  5. 3 4
      pdf2zh/translator.py
  6. 1 1
      pyproject.toml

+ 1 - 2
README.md

@@ -264,8 +264,7 @@ pdf2zh --celery worker
 ```
 
 ```bash
-curl http://localhost:11008/v1/translate -F "file=@example.pdf" -F "data={\"lang_in\":\"en\",\"l
-ang_out\":\"zh\",\"service\":\"google\",\"thread\":4}"
+curl http://localhost:11008/v1/translate -F "file=@example.pdf" -F "data={\"lang_in\":\"en\",\"lang_out\":\"zh\",\"service\":\"google\",\"thread\":4}"
 {"id":"d9894125-2f4e-45ea-9d93-1a9068d2045a"}
 
 curl http://localhost:11008/v1/translate/d9894125-2f4e-45ea-9d93-1a9068d2045a

+ 1 - 2
README_ja-JP.md

@@ -264,8 +264,7 @@ pdf2zh --celery worker
 ```
 
 ```bash
-curl http://localhost:11008/v1/translate -F "file=@example.pdf" -F "data={\"lang_in\":\"en\",\"l
-ang_out\":\"zh\",\"service\":\"google\",\"thread\":4}"
+curl http://localhost:11008/v1/translate -F "file=@example.pdf" -F "data={\"lang_in\":\"en\",\"lang_out\":\"zh\",\"service\":\"google\",\"thread\":4}"
 {"id":"d9894125-2f4e-45ea-9d93-1a9068d2045a"}
 
 curl http://localhost:11008/v1/translate/d9894125-2f4e-45ea-9d93-1a9068d2045a

+ 1 - 2
README_zh-CN.md

@@ -264,8 +264,7 @@ pdf2zh --celery worker
 ```
 
 ```bash
-curl http://localhost:11008/v1/translate -F "file=@example.pdf" -F "data={\"lang_in\":\"en\",\"l
-ang_out\":\"zh\",\"service\":\"google\",\"thread\":4}"
+curl http://localhost:11008/v1/translate -F "file=@example.pdf" -F "data={\"lang_in\":\"en\",\"lang_out\":\"zh\",\"service\":\"google\",\"thread\":4}"
 {"id":"d9894125-2f4e-45ea-9d93-1a9068d2045a"}
 
 curl http://localhost:11008/v1/translate/d9894125-2f4e-45ea-9d93-1a9068d2045a

+ 1 - 1
pdf2zh/__init__.py

@@ -3,6 +3,6 @@ from pdf2zh.high_level import translate, translate_stream
 
 log = logging.getLogger(__name__)
 
-__version__ = "1.8.7"
+__version__ = "1.8.8"
 __author__ = "Byaidu"
 __all__ = ["translate", "translate_stream"]

+ 3 - 4
pdf2zh/translator.py

@@ -94,7 +94,7 @@ class BingTranslator(BaseTranslator):
             "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0",  # noqa: E501
         }
 
-    def fineSID(self):
+    def findSID(self):
         response = self.session.get(self.endpoint)
         response.raise_for_status()
         url = response.url[:-10]
@@ -107,7 +107,7 @@ class BingTranslator(BaseTranslator):
 
     def translate(self, text):
         text = text[:1000]  # bing translate max length
-        url, ig, iid, key, token = self.fineSID()
+        url, ig, iid, key, token = self.findSID()
         response = self.session.post(
             f"{url}ttranslatev3?IG={ig}&IID={iid}",
             data={
@@ -232,7 +232,6 @@ class AzureOpenAITranslator(BaseTranslator):
         base_url = os.getenv(
             "AZURE_OPENAI_BASE_URL", self.envs["AZURE_OPENAI_BASE_URL"]
         )
-        api_version = os.getenv("AZURE_OPENAI_API_VERSION", "2024-06-01")
         if not model:
             model = os.getenv("AZURE_OPENAI_MODEL", self.envs["AZURE_OPENAI_MODEL"])
         super().__init__(lang_in, lang_out, model)
@@ -240,7 +239,7 @@ class AzureOpenAITranslator(BaseTranslator):
         self.client = openai.AzureOpenAI(
             azure_endpoint=base_url,
             azure_deployment=model,
-            api_version=api_version,
+            api_version="2024-06-01",
             api_key=api_key,
         )
 

+ 1 - 1
pyproject.toml

@@ -1,6 +1,6 @@
 [project]
 name = "pdf2zh"
-version = "1.8.7"
+version = "1.8.8"
 description = "Latex PDF Translator"
 authors = [{ name = "Byaidu", email = "byaidux@gmail.com" }]
 license = "AGPL-3.0"