Table of Contents

Class GenerativeSequence

Namespace
Glitch9.AIDevKit

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 with ExecuteAsync().
  • 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
object
GenerativeSequence

Methods

AppendAudio(IGenerativeRequest)

Append a task expected to produce AudioClip output.

  • Contract: nextTask.ExecuteAsync<AudioClip>() must succeed.
  • Stores the result into the internal audio buffer.
public GenerativeSequence AppendAudio(IGenerativeRequest nextTask)

Parameters

nextTask IGenerativeRequest

Returns

GenerativeSequence

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

nextTask Func<AudioClip, IGenerativeRequest>

Returns

GenerativeSequence

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

nextTask Func<AudioClip, IGenerativeRequest>

Returns

GenerativeSequence

AppendImage(IGenerativeRequest)

Append a task expected to produce Texture2D output.

  • Contract: nextTask.ExecuteAsync<Texture2D>() must succeed.
  • Stores the result into the internal image buffer.
public GenerativeSequence AppendImage(IGenerativeRequest nextTask)

Parameters

nextTask IGenerativeRequest

Returns

GenerativeSequence

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

nextTask Func<Texture2D, IGenerativeRequest>

Returns

GenerativeSequence

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

nextTask Func<Texture2D, IGenerativeRequest>

Returns

GenerativeSequence

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

seconds float

Returns

GenerativeSequence

AppendText(IGenerativeRequest)

Append a task expected to produce string output.

  • Contract: nextTask.ExecuteAsync<string>() must succeed.
  • Stores the result into the internal text buffer.
public GenerativeSequence AppendText(IGenerativeRequest nextTask)

Parameters

nextTask IGenerativeRequest

Returns

GenerativeSequence

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

nextTask Func<string, IGenerativeRequest>

Returns

GenerativeSequence

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

nextTask Func<string, IGenerativeRequest>

Returns

GenerativeSequence

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

nextTask Func<string, IGenerativeRequest>

Returns

GenerativeSequence

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