Table of Contents

Class RequestExtensions

Namespace
GenerativeAI
Assembly
GenerativeAI.dll

A static class providing extension methods for formatting request contents used in generative AI models.

public static class RequestExtensions
Inheritance
RequestExtensions
Inherited Members

Methods

FormatGenerateContentInput(IEnumerable<Part>, string)

Creates a Content object based on the specified collection of Part instances and role.

public static Content FormatGenerateContentInput(IEnumerable<Part> request, string role = "user")

Parameters

request IEnumerable<Part>

A collection of Part objects representing the content components.

role string

The role associated with the content. Defaults to "user".

Returns

Content

A new instance of Content containing the provided parts and specified role.

FormatGenerateContentInput(IEnumerable<string>, string)

Creates a Content object using the specified parts of a request and role.

public static Content FormatGenerateContentInput(IEnumerable<string> request, string role = "user")

Parameters

request IEnumerable<string>

A collection of strings representing individual parts of the request.

role string

The role associated with the content. Defaults to "user".

Returns

Content

A new instance of Content containing the specified parts and role.

FormatGenerateContentInput(string, string)

Creates a Content object based on the specified input text and role.

public static Content FormatGenerateContentInput(string @params, string role = "user")

Parameters

params string

The input text to be formatted into the content object.

role string

The role associated with the content. Defaults to "user".

Returns

Content

A new instance of Content containing the formatted input and specified role.

FormatSystemInstruction(string?)

Creates a Content object for system instructions based on the specified input string.

public static Content? FormatSystemInstruction(string? @params)

Parameters

params string

The system instruction text to be formatted into the content object. If null or empty, returns null.

Returns

Content

A new instance of Content containing the formatted input as a system role, or null if the input is null or empty.