Skip to content

Commit

Permalink
Remove notes added by ChatGPT to translation
Browse files Browse the repository at this point in the history
  • Loading branch information
drejmanMacopedia committed May 9, 2023
1 parent 766c72e commit 085a68b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
class ErrorResponse extends Response
{
public function __construct(
private string $error
private string|array $error
) {
}

public function getError(): string
{
return $this->error;
$error = $this->error;

if (is_array($error)) {
$error = json_encode($error);
}
return $error;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ public function __construct(

public function translate(string $text, Language $targetLanguageCode): ?string
{
return $this
$answer = $this
->openAiClient
->ask('user', sprintf(self::MESSAGE, $targetLanguageCode->asText(), $text));

if ($answer !== null) {
$answer = preg_replace('/(\(Note.*)/','',$answer);
}

return $answer;
}
}

0 comments on commit 085a68b

Please sign in to comment.