<?phprequire 'examples/boot.php';use Cognesy\Instructor\StructuredOutput;// Enumeration for single-label text classification.enum Label : string { case SPAM = "spam"; case NOT_SPAM = "not_spam";}// Class for a single class label prediction.class SinglePrediction { public Label $classLabel;}?>
Let’s run an example to see if it correctly identifies a spam message.
<?php// Test single-label classification$prediction = classify("Hello there I'm a Nigerian prince and I want to give you money");dump($prediction);assert($prediction->classLabel == Label::SPAM);?>