1. Go to this page and download the library: Download lonnieezell/scribe 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/ */
lonnieezell / scribe example snippets
// Define once
class SummarizePrompt extends BasePrompt
{
public function __construct(private string $text) {}
public function systemPrompt(): string
{
return 'You are a concise summarizer. Return a 2-sentence summary.';
}
public function userPrompt(): string
{
return 'Summarize: ' . $this->text;
}
}
// Use anywhere in your CI4 app
$response = service('scribe')->run(new SummarizePrompt($articleText));
echo $response->content;
namespace App\Prompts;
use Myth\Scribe\Prompts\BasePrompt;
class ClassifyEmailPrompt extends BasePrompt
{
public function __construct(private string $emailBody) {}
public function systemPrompt(): string
{
return 'Classify the email as spam or not_spam.';
}
public function userPrompt(): string
{
return $this->emailBody;
}
public function schema(): ?array
{
return [
'type' => 'object',
'properties' => ['label' => ['type' => 'string', 'enum' => ['spam', 'not_spam']]],
'
use Myth\Scribe\Drivers\FakeDriver;
$fake = new FakeDriver(['content' => '{"label":"spam"}']);
// inject $fake into your service or swap the driver in config
$prompt = new SummarizePrompt($text);
$prompt->driver = 'openai';
bash
php spark publish:config AI
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.