TsgcAIChat › Methods › ChatWithAttachments
Sends a user message together with several documents and returns the assistant response.
function ChatWithAttachments(const aMessage: string; const aAttachments: TsgcAIChatAttachments): string;
| Name | Type | Description |
|---|---|---|
aMessage | const string | User message. |
aAttachments | const TsgcAIChatAttachments | The documents to send. |
The assistant response, or an empty string on error. (string)
Every attachment is sent, in order, with the message. The attachments are copied into the history and aAttachments stays owned by the caller, so free it after the call.
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.
oAttachments := TsgcAIChatAttachments.Create;
Try
oAttachments.AddFile('invoice.pdf');
oAttachments.AddFile('delivery_note.png');
vAnswer := oChat.ChatWithAttachments('Do both documents match?', oAttachments);
Finally
oAttachments.Free;
End;