Belgeler alıntılar etkinleştirilmiş olarak gönderildiğinde, Claude'un yanıtı kaynak belgelerin belirli bölümlerine referanslar içerir. Bu, talepleri doğrulamanıza ve bilgileri kaynağına kadar izlemenize olanak tanır.
Document content block'larında CitationsEnabled'ı True olarak ayarlayın. Citations, bir istekteki belgelerin TÜMÜNDE veya HİÇBİRİNDE etkinleştirilmelidir.
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
Yanıttaki metin içerik blokları, kaynak referansları içeren bir Citations dizisi içerebilir.
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;