TsgcAIDocumentExtractor › Methods › ExtractAttachments
Extracts the data of documents already loaded as TsgcAIChatAttachments.
function ExtractAttachments(const aAttachments: TsgcAIChatAttachments): string;
| Name | Type | Description |
|---|---|---|
aAttachments | const TsgcAIChatAttachments | The documents to extract, sent in order in one request. |
The extracted data as a JSON document, the same text as LastResult.Data. (string)
Use it when the document is already in memory, for example received from a database or an upload, as base64 plus its media type. The list stays owned by the caller. See TsgcAIChat Documents and PDF for the attachments class. With the local OCR, the attachments are decoded to temporary files before they are recognised.
Raises EsgcAIDocumentExtractor when AIChat is not assigned, when the schema is empty or invalid, when there is nothing to extract, when OCRMode needs an OCR that is not assigned, and when the data does not validate and RaiseOnInvalid is True. Transport and provider errors of the chat propagate to the caller as they are, they do not reach OnChatError.
oAttachments := TsgcAIChatAttachments.Create;
Try
oAttachments.Add(vBase64, 'application/pdf', 'invoice.pdf');
vJSON := oExtractor.ExtractAttachments(oAttachments);
Finally
oAttachments.Free;
End;