Manual Prompt | Mined Prompt |
---|---|
x is affiliated with the y religion | x who converted to y |
The headquarter of x is in y | x is based in y |
x died in y | x died at his home in y |
x is represented by music label y | x recorded for y |
x is a subclass of y | x is a type of y |
<?php
require 'examples/boot.php';
use Cognesy\Instructor\StructuredOutput;
use Cognesy\Instructor\Extras\Sequence\Sequence;
class PromptTemplate {
public string $prompt_template;
}
class GeneratePromptTemplates {
public function __invoke(string $prompt) : array {
$system = 'You are an expert prompt miner that generates 3 clearer, concise prompt templates.';
return (new StructuredOutput)->with(
messages: [
['role' => 'system', 'content' => $system],
['role' => 'system', 'content' => $prompt],
],
responseModel: Sequence::of(PromptTemplate::class),
)->get()->toArray();
}
}
$prompt = 'France is the capital of Paris';
$templates = (new GeneratePromptTemplates)($prompt);
dump($templates);
?>