PHP code example of rawphp / laravel-capabilities-ai
1. Go to this page and download the library: Download rawphp/laravel-capabilities-ai 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/ */
rawphp / laravel-capabilities-ai example snippets
use Rawphp\CapabilitiesAi\Contracts\LlmClient;
use Rawphp\CapabilitiesAi\Support\FakeLlmClient;
use Rawphp\CapabilitiesAi\Support\AnthropicLlmClient;
// Testing default
$app->bind(LlmClient::class, fn () => new FakeLlmClient);
// Production
$app->bind(LlmClient::class, fn () => new AnthropicLlmClient(
apiKey: config('capabilities-ai.llm.anthropic.api_key'),
model: config('capabilities-ai.llm.anthropic.model'),
));
// AppServiceProvider::boot — after CapabilitiesAiServiceProvider has registered
use Rawphp\CapabilitiesAi\Contracts\ProgressStore;
$this->app->extend(ProgressStore::class, function (ProgressStore $inner, $app) {
return new TtsDispatchingProgressStore($inner, $app->make(TtsService::class));
});
use Rawphp\CapabilitiesAi\Support\ArrayProgressStore;
use Rawphp\CapabilitiesAi\Support\RedisProgressStore;
$store = new ArrayProgressStore;
$store->append($turnUlid, ['kind' => 'status', 'data' => ['status' => 'running']]);
$events = $store->since($turnUlid, $cursor);