Skip to content

Commit

Permalink
update translator.py format
Browse files Browse the repository at this point in the history
  • Loading branch information
imClumsyPanda committed Dec 29, 2024
1 parent cfc10ee commit e1de87d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pdf2zh/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ def do_translate(self, text):
{
"role": "user",
"content": xf_prompt[0]["content"]
+ "\n"
+ xf_prompt[1]["content"],
+ "\n"
+ xf_prompt[1]["content"],
}
]
response = xf_model.chat(
Expand Down Expand Up @@ -355,7 +355,10 @@ def __init__(
model = self.envs["OPENAI_MODEL"]
super().__init__(lang_in, lang_out, model)
self.options = {"temperature": 0} # 随机采样可能会打断公式标记
self.client = openai.OpenAI(base_url=base_url or self.envs["OPENAI_BASE_URL"], api_key=api_key or self.envs["OPENAI_API_KEY"])
self.client = openai.OpenAI(
base_url=base_url or self.envs["OPENAI_BASE_URL"],
api_key=api_key or self.envs["OPENAI_API_KEY"],
)
self.prompttext = prompt
self.add_cache_impact_parameters("temperature", self.options["temperature"])
if prompt:
Expand Down

0 comments on commit e1de87d

Please sign in to comment.