PHP code example of jpsantosbembe / laravel-ai-budget
1. Go to this page and download the library: Download jpsantosbembe/laravel-ai-budget 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/ */
jpsantosbembe / laravel-ai-budget example snippets
class WeeklyReview extends AiPipeline
{
public function key(): string { return 'weekly_review'; }
public function profileKey(): string { return 'review_master'; }
public function stages(): array
{
return [
['name' => 'analyse', 'type' => self::STAGE_MAP],
['name' => 'summarise', 'type' => self::STAGE_SINGLE],
];
}
public function estimateStage(string $stage, array $params): float { /* ... */ }
public function items(AiPipelineRun $run, string $stage): array
{
return Conversation::whereWeek('created_at', $run->params['week'])->pluck('id')->map(strval(...))->all();
}
public function handleItem(AiPipelineRun $run, string $stage, string $itemKey): array
{
$result = app(AiRunner::class)->run('conversation_analysis', [/* ... */]);
return ['payload' => $result->json, 'cost' => $result->costLocal];
}
}
$run = app(AiPipelineRunner::class)->dispatch(new WeeklyReview, ['week' => 38]);
app(AiPipelineRunner::class)->progressSnapshot($run);
app(AiPipelineRunner::class)->retry($run); // only the items that failed