GenerativeModelGenerateObjectAsyncT(IEnumerablePart, CancellationToken) Method
Generates content asynchronously using JSON mode based on the specified content generation request parts and converts the resulting JSON into a C# object of type T.
Namespace: GenerativeAIAssembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
public Task<T> GenerateObjectAsync<T>(
IEnumerable<Part> parts,
CancellationToken cancellationToken = default
)
where T : class
- parts IEnumerablePart
- An enumerable containing the input parts used for generating the content.
- cancellationToken CancellationToken (Optional)
- A token to monitor for cancellation requests.
- T
- The type of C# object to convert the resulting JSON into.
TaskTA task that represents the asynchronous operation, containing the generated object of type
T.
IGenerativeModelGenerateObjectAsyncT(IEnumerablePart, CancellationToken) Some of the complex data types are not supported such as Dictionary. So make sure to avoid these.