use Cognesy\Instructor\StructuredOutput;
class Email {
public function __construct(
public string $address = '',
public string $subject = '',
public string $body = '',
) {}
}
$email = new Email(
address: 'joe@gmail.com',
subject: 'Status update',
body: 'Your account has been updated.',
);
$translation = (new StructuredOutput)
->withInput($email)
->withPrompt('Translate the text fields of email to Spanish. Keep other fields unchanged.')
->withResponseClass(Email::class)
->get();
// Email {
// address: "joe@gmail.com",
// subject: "Actualización de estado",
// body: "Su cuenta ha sido actualizada."
// }
// @doctest id="412f"