ChatAttachment Class

A file attached to a ChatMessage, for example an image the user sends to a multimodal model.

Inheritance

Object

ChatAttachment

Namespace: Radzen.Blazor

Assembly: Radzen.Blazor.dll

Syntax

public class ChatAttachment

Constructors

ChatAttachmentLink to this section

A file attached to a ChatMessage, for example an image the user sends to a multimodal model.

Declaration
public ChatAttachment()

Properties

DataLink to this section

Gets or sets the file content.

Declaration
public ReadOnlyMemory<byte> Data { get; set; }
Property Value
Type Description
ReadOnlyMemory<byte>Gets or sets the file content.

IsImageLink to this section

Gets whether the attachment is an image.

Declaration
public bool IsImage { get; }
Property Value
Type Description
boolGets whether the attachment is an image.

MediaTypeLink to this section

Gets or sets the media type, for example image/png.

Declaration
public string MediaType { get; set; }
Property Value
Type Description
stringGets or sets the media type, for example image/png.

NameLink to this section

Gets or sets the file name.

Declaration
public string Name { get; set; }
Property Value
Type Description
stringGets or sets the file name.

UrlLink to this section

Gets the content as a data URI, usable as an image source.

Declaration
public string Url { get; }
Property Value
Type Description
stringGets the content as a data URI, usable as an image source.

Methods

FromDataContentLink to this section

Creates an attachment from the DataContent of a message.

Declaration
public static ChatAttachment FromDataContent(Microsoft.Extensions.AI.DataContent content)
Parameters
Type Name Description
Microsoft.Extensions.AI.DataContent content The content.
Returns
Type Description
ChatAttachment

GetMediaTypeLink to this section

Gets the media type for a file name from its extension, or application/octet-stream when unknown.

Declaration
public static string GetMediaType(string fileName)
Parameters
Type Name Description
string fileName The file name.
Returns
Type Description
string

ToDataContentLink to this section

Converts the attachment to the DataContent sent to the model.

Declaration
public Microsoft.Extensions.AI.DataContent ToDataContent()
Returns
Type Description
Microsoft.Extensions.AI.DataContent
An error has occurred. This app may no longer respond until reloaded. Reload 🗙