Class GenerativeSequence
Orchestrates a series of generative tasks (text/image/audio) where each step can consume the previous output.
- Build a pipeline with
Append*methods, then run once withExecuteAsync(). - Keeps the most recent outputs (text/image/audio) in an internal buffer for the next step.
- Type safety at runtime: each appended task must return the expected type (e.g., string for Text).
- Stops on first exception; wrap
ExecuteAsync()in your own try/catch if you need partial tolerance.
await new GENSequence()
.AppendText(new GENResponseTask(new TextPrompt("Give me a short poem about the ocean.")))
.AppendTextToImage(text => new GENImageTask(new TextPrompt($"Illustrate: {text}")))
.AppendInterval(0.5f)
.AppendImageToAudio(tex => new GENSpeechTask(new TextPrompt("Narrate the poem over ambient waves.")))
.ExecuteAsync();
public class GenerativeSequence
- Inheritance
-
objectGenerativeSequence
Methods
AppendAudio(IGenerativeRequest)
Append a task expected to produce AudioClip output.
- Contract:
nextTask.ExecuteAsync<AudioClip>()must succeed. - Stores the result into the internal
audiobuffer.
public GenerativeSequence AppendAudio(IGenerativeRequest nextTask)
Parameters
nextTaskIGenerativeRequest
Returns
AppendAudioToAudio(Func<AudioClip, IGenerativeRequest>)
Append an audio task whose factory receives the previous AudioClip as input.
- Typical usage: audio → voice conversion or enhancement.
public GenerativeSequence AppendAudioToAudio(Func<AudioClip, IGenerativeRequest> nextTask)
Parameters
nextTaskFunc<AudioClip, IGenerativeRequest>
Returns
AppendAudioToText(Func<AudioClip, IGenerativeRequest>)
Append a text task whose factory receives the previous AudioClip as input.
- Typical usage: audio → transcription (STT) → text post-processing.
public GenerativeSequence AppendAudioToText(Func<AudioClip, IGenerativeRequest> nextTask)
Parameters
nextTaskFunc<AudioClip, IGenerativeRequest>
Returns
AppendImage(IGenerativeRequest)
Append a task expected to produce Texture2D output.
- Contract:
nextTask.ExecuteAsync<Texture2D>()must succeed. - Stores the result into the internal
imagebuffer.
public GenerativeSequence AppendImage(IGenerativeRequest nextTask)
Parameters
nextTaskIGenerativeRequest
Returns
AppendImageToImage(Func<Texture2D, IGenerativeRequest>)
Append an image task whose factory receives the previous Texture2D as input.
- Typical usage: image → image (inpaint/variation/edit).
public GenerativeSequence AppendImageToImage(Func<Texture2D, IGenerativeRequest> nextTask)
Parameters
nextTaskFunc<Texture2D, IGenerativeRequest>
Returns
AppendImageToText(Func<Texture2D, IGenerativeRequest>)
Append a text task whose factory receives the previous Texture2D as input.
- Typical usage: image → captioning or description.
public GenerativeSequence AppendImageToText(Func<Texture2D, IGenerativeRequest> nextTask)
Parameters
nextTaskFunc<Texture2D, IGenerativeRequest>
Returns
AppendInterval(float)
Insert a non-generative delay between steps.
- Useful for pacing UI updates, rate-limiting, or staging effects.
- Does not alter any stored outputs (text/image/audio remain as-is).
public GenerativeSequence AppendInterval(float seconds)
Parameters
secondsfloat
Returns
AppendText(IGenerativeRequest)
Append a task expected to produce string output.
- Contract:
nextTask.ExecuteAsync<string>()must succeed. - Stores the result into the internal
textbuffer.
public GenerativeSequence AppendText(IGenerativeRequest nextTask)
Parameters
nextTaskIGenerativeRequest
Returns
AppendTextToAudio(Func<string, IGenerativeRequest>)
Append an audio task whose factory receives the previous text as input.
- Typical usage: text → speech (TTS).
public GenerativeSequence AppendTextToAudio(Func<string, IGenerativeRequest> nextTask)
Parameters
nextTaskFunc<string, IGenerativeRequest>
Returns
AppendTextToImage(Func<string, IGenerativeRequest>)
Append an image task whose factory receives the previous text as input.
- Typical usage: text → image (prompting an image model with generated text).
public GenerativeSequence AppendTextToImage(Func<string, IGenerativeRequest> nextTask)
Parameters
nextTaskFunc<string, IGenerativeRequest>
Returns
AppendTextToText(Func<string, IGenerativeRequest>)
Append a text task whose factory receives the previous text as input.
- Use this to feed LLM output into another LLM step.
public GenerativeSequence AppendTextToText(Func<string, IGenerativeRequest> nextTask)
Parameters
nextTaskFunc<string, IGenerativeRequest>
Returns
ExecuteAsync()
Run the pipeline in order, awaiting each step and storing the output for the next step.
- Throws System.InvalidOperationException if no tasks were appended.
- Each step calls
ExecuteAsync<T>()with the expected return type. - On failure, the sequence stops and propagates the exception.
public UniTask ExecuteAsync()
Returns
- UniTask