File attachments
Geben Sie Dateien oder Verzeichnisse wie folgt als Array an.
use Revolution\Copilot\Facades\Copilot;
$attachments = [
[
'type' => 'file',
'path' => '/path/to/file.php',
'displayName' => 'My File',// optional
],
[
'type' => 'directory',
'path' => '/path/to/dir/',
'displayName' => 'dir',// optional
],
[
'type' => 'selection',
'filePath' => '/path/to/file.php',
'displayName' => 'My File',// hier nicht optional
'selection' => [
'start' => ['line' => 1, 'character' => 10],
'end' => ['line' => 5, 'character' => 10],
],
'text' => '...',
],
[
'type' => 'blob',
'data' => base64_encode(file_get_contents('/path/to/image.png')),
'mimeType' => 'image/png',
'displayName' => 'screenshot.png',// optional
],
];
$response = Copilot::run(prompt: '...', attachments: $attachments);
Da sich ein solches Format schwer merken lässt, stehen Helper zur einfachen Nutzung bereit.
use Revolution\Copilot\Facades\Copilot;
use Revolution\Copilot\Support\Attachment;
$attachments = [
Attachment::file(path: '/path/to/file.php', displayName: 'My File'),
Attachment::directory(path: '/path/to/dir/', displayName: 'dir'),
Attachment::selection(filePath: '/path/to/file.php', displayName: 'My File', selection: ['start' => ['line' => 1, 'character' => 10], 'end' => ['line' => 5, 'character' => 10]], text: '...'),
Attachment::blob(data: base64_encode(file_get_contents('/path/to/image.png')), mimeType: 'image/png', displayName: 'screenshot.png'),
];
$response = Copilot::run(prompt: '...', attachments: $attachments);
Blob attachments
Der Typ blob wird verwendet, um Base64-kodierte Daten inline anzuhängen. So können Sie Binärdaten wie Bilder ohne Disk-I/O direkt senden.
use Revolution\Copilot\Support\Attachment;
// Bilddatei Base64-kodieren und anhängen
$attachment = Attachment::blob(
data: base64_encode(file_get_contents('/path/to/image.png')),
mimeType: 'image/png',
displayName: 'screenshot.png',
);
Für selection gibt es im offiziellen SDK noch keine Dokumentation, daher sind die Details unklar. Auch zu github_reference fehlen offizielle Informationen; eine Unterstützung ist zukünftig geplant.
Zuletzt geändert am 13. Juli 2026