TsgcAIChat › Methods › ChatWithAttachments

ChatWithAttachments Method

Sends a user message together with several documents and returns the assistant response.

Syntax

function ChatWithAttachments(const aMessage: string; const aAttachments: TsgcAIChatAttachments): string;

Parameters

NameTypeDescription
aMessageconst stringUser message.
aAttachmentsconst TsgcAIChatAttachmentsThe documents to send.

Return Value

The assistant response, or an empty string on error. (string)

Remarks

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.

Example

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;

Back to Methods