B09_BatchInference
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
<?php
require 'examples/boot.php';
require __DIR__.'/../Support/DemoBatch.php';
use Cognesy\Polyglot\BatchInference\Enums\BatchResultsAvailability;
use Examples\BatchInference\Support\DemoBatch;
$batches = DemoBatch::client(partial: true);
$reference = $batches->submit(DemoBatch::items())->reference();
$first = $batches->results($reference);
$firstKeys = array_map(static fn ($item): string => $item->key(), iterator_to_array($first->items()));
$later = $batches->results($reference);
$laterKeys = array_map(static fn ($item): string => $item->key(), iterator_to_array($later->items()));
if ($first->availability() !== BatchResultsAvailability::Partial
|| $firstKeys !== ['row-1'] || $laterKeys !== ['row-1']) {
throw new RuntimeException('Partial result reread behaved unexpectedly.');
}
echo "Partial result key row-1 appeared in both snapshots\n";
?>