| 443 | ), |
| 444 | ) |
| 445 | def do_translate(self, text) -> str: |
| 446 | response = self.client.chat.completions.create( |
| 447 | model=self.model, |
| 448 | **self.options, |
| 449 | messages=self.prompt(text, self.prompttext), |
| 450 | ) |
| 451 | if not response.choices: |
| 452 | if hasattr(response, "error"): |
| 453 | raise ValueError("Error response from Service", response.error) |
| 454 | content = response.choices[0].message.content.strip() |
| 455 | content = self.think_filter_regex.sub("", content).strip() |
| 456 | return content |
| 457 | |
| 458 | def get_formular_placeholder(self, id: int): |
| 459 | return "{{v" + str(id) + "}}" |