1. Go to this page and download the library: Download mosaiqo/proofread library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mosaiqo / proofread example snippets
namespace App\Agents;
use Laravel\Ai\Contracts\Agent;
use Laravel\Ai\Promptable;
use Stringable;
class SentimentAgent implements Agent
{
use Promptable;
public function instructions(): Stringable|string
{
return <<<'PROMPT'
You are a sentiment classifier.
Classify the user message as exactly one of: positive, negative, neutral.
Respond with a single lowercase word. No punctuation, no explanation.
PROMPT;
}
}
use App\Agents\SentimentAgent;
use Mosaiqo\Proofread\Assertions\CostLimit;
use Mosaiqo\Proofread\Assertions\RegexAssertion;
use Mosaiqo\Proofread\Assertions\Rubric;
use Mosaiqo\Proofread\Support\Dataset;
it('classifies sentiment reliably and cheaply', function (): void {
$dataset = Dataset::make('sentiment', [
['input' => 'I love this product!', 'expected' => 'positive'],
['input' => 'This is terrible.', 'expected' => 'negative'],
['input' => 'It works as described.', 'expected' => 'neutral'],
]);
expect(SentimentAgent::class)->toPassEval($dataset, [
RegexAssertion::make('/^(positive|negative|neutral)$/'),
Rubric::make('response is a single lowercase sentiment label'),
CostLimit::under(0.01),
]);
});
namespace App\Evals;
use App\Agents\SentimentAgent;
use Mosaiqo\Proofread\Assertions\RegexAssertion;
use Mosaiqo\Proofread\Suite\EvalSuite;
use Mosaiqo\Proofread\Support\Dataset;
final class SentimentSuite extends EvalSuite
{
public function dataset(): Dataset
{
return Dataset::make('sentiment', [
['input' => 'I love this product!', 'expected' => 'positive'],
['input' => 'This is terrible.', 'expected' => 'negative'],
]);
}
public function subject(): mixed
{
return SentimentAgent::class;
}
public function assertions(): array
{
return [
RegexAssertion::make('/^(positive|negative|neutral)$/'),
];
}
}
abstract public function dataset(): Dataset;
abstract public function subject(): mixed;
abstract public function assertions(): array;
use App\Agents\SentimentAgent;
use Mosaiqo\Proofread\Assertions\RegexAssertion;
use Mosaiqo\Proofread\Shadow\ShadowAssertionsRegistry;
public function boot(ShadowAssertionsRegistry $registry): void
{
$registry->register(SentimentAgent::class, [
RegexAssertion::make('/^(positive|negative|neutral)$/'),
]);
}
use Laravel\Mcp\Server;
use Mosaiqo\Proofread\Mcp\McpIntegration;
class ProofreadMcpServer extends Server
{
protected array $tools = McpIntegration::tools();
}
use Mosaiqo\Proofread\Cli\Subjects\ClaudeCodeCliSubject;
use Mosaiqo\Proofread\Runner\EvalRunner;
$subject = ClaudeCodeCliSubject::make()
->withModel('claude-sonnet-4-6')
->withTimeout(60);
$run = (new EvalRunner)->run($subject, $dataset, $assertions);
use Mosaiqo\Proofread\Cli\CliResponse;
use Mosaiqo\Proofread\Cli\CliSubject;
final class MyCliSubject extends CliSubject
{
public function binary(): string
{
return 'mycli';
}
public function args(string $prompt): array
{
return ['--prompt', $prompt, '--json'];
}
public function parseOutput(string $stdout, string $stderr): CliResponse
{
$decoded = json_decode($stdout, true);
return new CliResponse(
output: $decoded['response'] ?? '',
metadata: [
'tokens_in' => $decoded['tokens']['in'] ?? null,
'tokens_out' => $decoded['tokens']['out'] ?? null,
'model' => $decoded['model'] ?? null,
],
);
}
}