메인 콘텐츠로 건너뛰기

File attachments

다음과 같이 파일 또는 디렉터리를 배열로 지정합니다.
use Revolution\Copilot\Facades\Copilot;

$attachments = [
    [
        'type' => 'file',
        'path' => '/path/to/file.php',
        'displayName' => 'My File',// 생략 가능
    ],
    [
        'type' => 'directory',
        'path' => '/path/to/dir/',
        'displayName' => 'dir',// 생략 가능
    ],
    [
        'type' => 'selection',
        'filePath' => '/path/to/file.php',
        'displayName' => 'My File',// 여기는 생략 불가
        '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',// 생략 가능
    ],
];

$response = Copilot::run(prompt: '...', attachments: $attachments);
이런 포맷을 외우기는 어렵기 때문에 쉽게 사용할 수 있도록 헬퍼를 제공하고 있습니다.
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

blob 타입은 Base64 인코딩된 데이터를 인라인으로 첨부할 때 사용합니다. 디스크 I/O 없이 이미지 등의 바이너리 데이터를 직접 전송할 수 있습니다.
use Revolution\Copilot\Support\Attachment;

// 이미지 파일을 Base64로 인코딩하여 첨부
$attachment = Attachment::blob(
    data: base64_encode(file_get_contents('/path/to/image.png')),
    mimeType: 'image/png',
    displayName: 'screenshot.png',
);
selection은 공식 SDK에 아직 문서가 없어 상세는 불명입니다. github_reference도 공식 정보가 부족하기 때문에 향후 지원 예정입니다.
최신 정보는 GitHub 저장소를 참고하세요.
마지막 수정일 2026년 7월 13일