Skip to content

Commit

Permalink
release: 1.8.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Byaidu committed Dec 15, 2024
1 parent d617c16 commit beb8517
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 12 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ pdf2zh --celery worker
```

```bash
curl http://localhost:11008/v1/translate -F "[email protected]" -F "data={\"lang_in\":\"en\",\"l
ang_out\":\"zh\",\"service\":\"google\",\"thread\":4}"
curl http://localhost:11008/v1/translate -F "[email protected]" -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
Expand Down
3 changes: 1 addition & 2 deletions README_ja-JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ pdf2zh --celery worker
```

```bash
curl http://localhost:11008/v1/translate -F "[email protected]" -F "data={\"lang_in\":\"en\",\"l
ang_out\":\"zh\",\"service\":\"google\",\"thread\":4}"
curl http://localhost:11008/v1/translate -F "[email protected]" -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
Expand Down
3 changes: 1 addition & 2 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ pdf2zh --celery worker
```

```bash
curl http://localhost:11008/v1/translate -F "[email protected]" -F "data={\"lang_in\":\"en\",\"l
ang_out\":\"zh\",\"service\":\"google\",\"thread\":4}"
curl http://localhost:11008/v1/translate -F "[email protected]" -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
Expand Down
2 changes: 1 addition & 1 deletion pdf2zh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

log = logging.getLogger(__name__)

__version__ = "1.8.7"
__version__ = "1.8.8"
__author__ = "Byaidu"
__all__ = ["translate", "translate_stream"]
7 changes: 3 additions & 4 deletions pdf2zh/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, lang_in, lang_out, model):
"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]
Expand All @@ -107,7 +107,7 @@ def fineSID(self):

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={
Expand Down Expand Up @@ -232,15 +232,14 @@ def __init__(self, lang_in, lang_out, model, base_url=None, api_key=None):
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)
self.options = {"temperature": 0}
self.client = openai.AzureOpenAI(
azure_endpoint=base_url,
azure_deployment=model,
api_version=api_version,
api_version="2024-06-01",
api_key=api_key,
)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pdf2zh"
version = "1.8.7"
version = "1.8.8"
description = "Latex PDF Translator"
authors = [{ name = "Byaidu", email = "[email protected]" }]
license = "AGPL-3.0"
Expand Down

0 comments on commit beb8517

Please sign in to comment.