Class GENTask<TSelf, TOptions, TPrompt, TResult>
Abstract base class for all generative AI tasks (text, image, audio). Supports text, image, and audio prompts with fluent configuration methods.
public abstract class GENTask<TSelf, TOptions, TPrompt, TResult> : TaskBase<TSelf, TResult>, IGENTask where TSelf : GENTask<TSelf, TOptions, TPrompt, TResult> where TOptions : IGENOptions where TResult : IGeneratedResult
Type Parameters
TSelfTOptionsTPromptTResult
- Inheritance
-
objectTaskBase<TSelf, TResult>GENTask<TSelf, TOptions, TPrompt, TResult>
- Implements
- Derived
- Inherited Members
Constructors
GENTask()
protected GENTask()
GENTask(TPrompt)
protected GENTask(TPrompt prompt)
Parameters
promptTPrompt
Properties
Api
public override Api Api { get; set; }
Property Value
MaxN
public int MaxN { get; }
Property Value
- int
ModelId
public string ModelId { get; }
Property Value
- string
N
public int N { get; }
Property Value
- int
Options
public TOptions Options { get; set; }
Property Value
- TOptions
OutputFileNote
public string OutputFileNote { get; }
Property Value
- string
OutputFilePath
public string OutputFilePath { get; }
Property Value
- string
Prompt
public TPrompt Prompt { get; set; }
Property Value
- TPrompt
RecordHistory
public bool RecordHistory { get; }
Property Value
- bool
SaveGeneratedContents
public bool SaveGeneratedContents { get; }
Property Value
- bool
Methods
CreateMergedHistoryRecordINTERNAL(List<TResult>)
protected void CreateMergedHistoryRecordINTERNAL(List<TResult> results)
Parameters
resultsList<TResult>
EnablePromptHistory(bool)
Enables or disables prompt history for this task.
public TSelf EnablePromptHistory(bool enablePromptHistory = true)
Parameters
enablePromptHistorybool
Returns
- TSelf
ExecuteAsync()
Executes the task and returns the output of type TResult.
This is the main entry point for executing the task.
public override UniTask<TResult> ExecuteAsync()
Returns
- UniTask<TResult>
GetPrompt()
public IPrompt GetPrompt()
Returns
ResolveOutputPath(Api?, string)
protected virtual TSelf ResolveOutputPath(Api? apiOverride = null, string keyword = null)
Parameters
apiOverrideApi?keywordstring
Returns
- TSelf
SaveContentsTo(string, string)
Sets the download path for the generated content(s). This is the path where the generated content(s) will be saved.
public TSelf SaveContentsTo(string outputFilePath = null, string outputFileNote = null)
Parameters
outputFilePathstringThe path where the generated content(s) will be saved.
outputFileNotestring
Returns
- TSelf
SetCount(int)
Sets the number of outputs to generate (e.g., number of images or responses).
public TSelf SetCount(int count)
Parameters
countint
Returns
- TSelf
SetModel(Api, string)
Added new on 2025.07.17 Sets the AI model with API and model ID.
public TSelf SetModel(Api api, string modelId)
Parameters
apiApimodelIdstring
Returns
- TSelf
SetModel(Model)
Sets the AI model to be used for generation.
public TSelf SetModel(Model model)
Parameters
modelModel
Returns
- TSelf
SetOptions(TOptions)
public TSelf SetOptions(TOptions apiOptions)
Parameters
apiOptionsTOptions
Returns
- TSelf
SetRequestMimeType(MIMEType)
public TSelf SetRequestMimeType(MIMEType mimeType)
Parameters
mimeTypeMIMEType
Returns
- TSelf
SetResponseMimeType(MIMEType)
Sets a custom MIME type for the output.
public TSelf SetResponseMimeType(MIMEType mimeType)
Parameters
mimeTypeMIMEType
Returns
- TSelf
YieldAsync()
Allows to set N more than the selected model allows. This is useful for streaming the responses one by one.
public IAsyncEnumerable<TResult> YieldAsync()
Returns
- IAsyncEnumerable<TResult>
YieldAsyncINTERNAL()
protected virtual IAsyncEnumerable<TResult> YieldAsyncINTERNAL()
Returns
- IAsyncEnumerable<TResult>