| 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: |