Class ContentRequestExtensions
- Namespace
- GenerativeAI
- Assembly
- GenerativeAI.dll
Contains extension methods for working with objects implementing IContentsRequest.
public static class ContentRequestExtensions
- Inheritance
-
ContentRequestExtensions
- Inherited Members
Methods
AddContent(IContentsRequest, Content)
Adds a new Content object to the IContentsRequest.
public static void AddContent(this IContentsRequest request, Content content)
Parameters
requestIContentsRequestThe IContentsRequest instance to which the Content will be added.
contentContentThe Content object to add to the request.
AddInlineData(IContentsRequest, string, string, bool, string)
Adds inline data such as an image or audio file into the latest Content in the IContentsRequest and associates it with the specified role.
public static void AddInlineData(this IContentsRequest request, string data, string mimeType, bool appendToLastContent = true, string role = "user")
Parameters
requestIContentsRequestThe IContentsRequest instance to which the inline data will be added.
datastringThe inline data to include, represented as a base64-encoded string.
mimeTypestringThe MIME type of the inline data.
appendToLastContentboolIndicates whether to append the Part to the latest Content or Create a new Content
rolestringThe role associated with the inline data. Defaults to User.
AddInlineFile(IContentsRequest, string, bool, string)
Adds a new Content that includes an inline file as a Part to the IContentsRequest.
public static void AddInlineFile(this IContentsRequest request, string filePath, bool appendToLastContent = true, string role = "user")
Parameters
requestIContentsRequestThe IContentsRequest instance to which the inline file will be added.
filePathstringThe file path of the inline file to be added.
appendToLastContentboolIndicates whether to append the Part to the latest Content or Create a new Content
rolestringThe role associated with the inline file. Defaults to User.
AddPart(IContentsRequest, Part, bool, string)
Adds a specific Part to the latest Content in the IContentsRequest. If no Content exists, a new one is created with the provided Part.
public static void AddPart(this IContentsRequest request, Part part, bool appendToLastContent = true, string role = "user")
Parameters
requestIContentsRequestThe IContentsRequest instance to which the Part is added.
partPartThe Part to add.
appendToLastContentboolIndicates whether to append the Part to the latest Content or Create a new Content
rolestring
AddParts(IContentsRequest, IEnumerable<Part>, bool, string)
Adds a collection of Part objects to the latest Content in the IContentsRequest with the specified role. If no Content exists, a new one is created with the provided Part collection.
public static void AddParts(this IContentsRequest request, IEnumerable<Part> parts, bool appendToLastContent = true, string role = "user")
Parameters
requestIContentsRequestThe IContentsRequest instance to which the Part objects will be added.
partsIEnumerable<Part>The collection of Part objects to add.
appendToLastContentboolIndicates whether to append the Part to the latest Content or Create a new Content
rolestringThe role associated with the Part objects. Defaults to User.
AddRemoteFile(GenerateContentRequest, RemoteFile, bool, string)
Adds a remote file to the IContentsRequest using a RemoteFile object.
public static void AddRemoteFile(this GenerateContentRequest request, RemoteFile file, bool appendToLastContent = true, string role = "user")
Parameters
requestGenerateContentRequestThe IContentsRequest instance to which the remote file will be added.
fileRemoteFileThe RemoteFile object to be added.
appendToLastContentboolIndicates whether to append the Part to the latest Content or Create a new Content
rolestringThe role associated with the remote file. Defaults to User.
AddRemoteFile(IContentsRequest, RemoteFile, bool, string)
Adds a remote file to the IContentsRequest using a RemoteFile object.
public static void AddRemoteFile(this IContentsRequest request, RemoteFile file, bool appendToLastContent = true, string role = "user")
Parameters
requestIContentsRequestThe IContentsRequest instance to which the remote file will be added.
fileRemoteFileThe RemoteFile object to be added.
appendToLastContentboolIndicates whether to append the Part to the latest Content or Create a new Content
rolestringThe role associated with the remote file. Defaults to User.
AddRemoteFile(IContentsRequest, string, string, bool, string)
Adds a remote file to the IContentsRequest using a URL and MIME type.
public static void AddRemoteFile(this IContentsRequest request, string url, string mimeType, bool appendToLastContent = true, string role = "user")
Parameters
requestIContentsRequestThe IContentsRequest instance to which the remote file will be added.
urlstringThe URL of the remote file to be added.
mimeTypestringThe MIME type of the remote file. Must be one of the supported formats defined in SupportedMimeTypes.
appendToLastContentboolIndicates whether to append the Part to the latest Content or Create a new Content
rolestringThe role associated with the remote file. Defaults to User.
AddText(IContentsRequest, string, bool, string)
Adds a single text Part to the IContentsRequest with the specified role.
public static void AddText(this IContentsRequest request, string text, bool appendToLastContent = true, string role = "user")
Parameters
requestIContentsRequestThe IContentsRequest instance to which the text Part will be added.
textstringThe text content to add as a Part.
appendToLastContentboolIndicates whether to append the Part to the latest Content or Create a new Content
rolestring