1. Go to this page and download the library: Download padosoft/laravel-ai-regolo 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/ */
padosoft / laravel-ai-regolo example snippets
// config/ai.php — both providers wired side-by-side
'providers' => [
'openai' => [/* … OpenAI key, models … */],
'regolo' => [/* … Regolo key, models … */],
],
// Anti-hallucination KB chat → Regolo (EU residency for the user prompts).
$answer = Agent::for($question)->using('regolo', 'Llama-3.3-70B-Instruct')->prompt();
// Frontier reasoning over a synthetic dataset (no PII) → OpenAI.
$reasoning = Agent::for($problem)->using('openai', 'gpt-4o')->prompt();
use Laravel\Ai\Agent;
$response = Agent::for('Tell me three things about Rome.')
->using('regolo', 'Llama-3.3-70B-Instruct')
->prompt();
echo $response->text;
// Rome was founded in 753 BC. It hosts the Vatican City...
use Laravel\Ai\Agent;
$response = Agent::for('Riassumi il manzoniano "Addio monti" in tre righe.')
->using('regolo', 'Llama-3.3-70B-Instruct')
->prompt();
$response->text; // string — final assistant message
$response->usage->promptTokens;
$response->usage->completionTokens;
$response->meta->provider; // 'regolo'
$response->meta->model; // 'Llama-3.3-70B-Instruct'
use Laravel\Ai\Agent;
use Laravel\Ai\Streaming\Events\TextDelta;
foreach (Agent::for('Spiega il teorema di Pitagora.')->using('regolo')->stream() as $event) {
if ($event instanceof TextDelta) {
echo $event->delta;
}
}
use Laravel\Ai\Agent;
use Laravel\Ai\Contracts\Tool;
use Illuminate\JsonSchema\JsonSchema;
class GetWeather implements Tool
{
public function description(): string { return 'Lookup current weather for an Italian city.'; }
public function schema(JsonSchema $schema): array
{
return $schema->object()
->property('city', $schema->string()->response->text; //
use Laravel\Ai\Embeddings;
// Single input
$single = Embeddings::for(['Roma è la capitale d\'Italia.'])
->generate('regolo', 'Qwen3-Embedding-8B');
$single->first(); // float[] — 4096-dim vector
$single->tokens; // int — billed token count
// Batch (one HTTP call, one billed request)
$batch = Embeddings::for([
'Roma è la capitale d\'Italia.',
'Parigi è la capitale della Francia.',
'Madrid è la capitale della Spagna.',
])->generate('regolo');
count($batch->embeddings); // 3
$batch->meta->model; // 'Qwen3-Embedding-8B' (default from config)
use Laravel\Ai\Reranking;
$ranked = Reranking::of([
'Rome is the capital of Italy.',
'Paris is the capital of France.',
'Pasta al pomodoro is a classic Italian dish.',
])
->limit(2)
->rerank('What is the capital of Italy?', 'regolo', 'Qwen3-Reranker-4B');
foreach ($ranked->results as $result) {
echo "{$result->score} {$result->document}\n";
}
// 0.91 Rome is the capital of Italy.
// 0.05 Pasta al pomodoro is a classic Italian dish.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.