인용이 활성화된 상태로 문서가 전송되면, Claude의 응답에는 소스 문서의 특정 부분에 대한 참조가 포함됩니다. 이를 통해 주장을 검증하고 정보를 그 출처까지 추적할 수 있습니다.
document 콘텐츠 블록에서 CitationsEnabled를 True로 설정하십시오. Citations는 요청의 문서 전체에서 활성화하거나 전혀 활성화하지 않아야 합니다.
oDocBlock := TsgcAnthropicClass_Request_Content_Block.Create;
oDocBlock.ContentType := 'document';
oDocBlock.SourceType := 'base64';
oDocBlock.MediaType := 'application/pdf';
oDocBlock.Data := sgcBase64Encode(LoadFileToBytes('report.pdf'));
oDocBlock.CitationsEnabled := True; // Enable citations
응답의 텍스트 콘텐츠 블록에는 소스 참조가 있는 Citations 배열이 포함될 수 있습니다.
oResponse := Anthropic.CreateMessage(oRequest);
Try
for i := 0 to Length(oResponse.Content) - 1 do
begin
if oResponse.Content[i].ContentType = 'text' then
begin
WriteLn(oResponse.Content[i].Text);
// Process citations
for j := 0 to Length(oResponse.Content[i].Citations) - 1 do
begin
oCitation := oResponse.Content[i].Citations[j];
WriteLn(Format(' Citation [%s]: "%s"',
[oCitation.CitationType, oCitation.CitedText]));
if oCitation.CitationType = 'page_location' then
WriteLn(Format(' Pages %d-%d of "%s"',
[oCitation.StartPageNumber, oCitation.EndPageNumber,
oCitation.DocumentTitle]));
end;
end;
end;
Finally
oResponse.Free;
End;