MCPcopy
hub / github.com/PDFMathTranslate/PDFMathTranslate / do_translate

Method do_translate

pdf2zh/translator.py:326–336  ·  view source on GitHub ↗
(self, text: str)

Source from the content-addressed store, hash-verified

324 self.add_cache_impact_parameters("temperature", self.options["temperature"])
325
326 def do_translate(self, text: str) -> str:
327 if (max_token := len(text) * 5) > self.options["num_predict"]:
328 self.options["num_predict"] = max_token
329
330 response = self.client.chat(
331 model=self.model,
332 messages=self.prompt(text, self.prompt_template),
333 options=self.options,
334 )
335 content = self._remove_cot_content(response.message.content or "")
336 return content.strip()
337
338 @staticmethod
339 def _remove_cot_content(content: str) -> str:

Callers 1

test_do_translateMethod · 0.95

Calls 2

_remove_cot_contentMethod · 0.95
promptMethod · 0.80

Tested by 1

test_do_translateMethod · 0.76