TsgcAIChat › Methods › ChatWithDocument
Sends a user message together with a PDF or image file and returns the assistant response.
function ChatWithDocument(const aMessage, aFileName: string): string;
| Name | Type | Description |
|---|---|---|
aMessage | const string | User message, for example the question about the document. |
aFileName | const string | Full path of the PDF or image file. |
The assistant response, or an empty string on error. (string)
The file is read, encoded as base64 and attached to the user message. The media type comes from the extension: .pdf, .png, .jpg, .jpeg, .gif or .webp. The message and the document are stored in the history, so follow up questions can refer to the document without sending it again.
See TsgcAIChat Documents and PDF for the providers that accept PDF documents.
Like Chat, a transport error, a provider error or a document the provider does not accept is reported through OnChatError and the method returns an empty string. An unsupported extension is reported the same way.
vAnswer := oChat.ChatWithDocument('Summarise this report', 'report.pdf');