Class GeneratorBehaviour<TRequest, TInput, TOutput, TPrompt, TEvent, TResult, TOptions, TSettings>
Base class for AI components that generate output based on input.
Handles configuration, queuing, streaming, and final output events.
Inheritance
Object
Component
Behaviour
MonoBehaviour
GeneratorBehaviour<TRequest, TInput, TOutput, TPrompt, TEvent, TResult, TOptions, TSettings>
Inherited Members
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.didStart
MonoBehaviour.didAwake
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.GetComponentIndex()
Component.CompareTag(TagHandle)
Component.transform
Component.transformHandle
Component.gameObject
Component.tag
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags
Assembly: Glitch9.AIDevKit.Agent.dll
Syntax
public abstract class GeneratorBehaviour<TRequest, TInput, TOutput, TPrompt, TEvent, TResult, TOptions, TSettings> : AIBehaviour, IErrorEventListener, IUsageEventListener, IUniTaskQueueEventListener, IStreamVisitor<TEvent, Generated<TResult>> where TRequest : GenerativeRequest<TRequest, TPrompt, TResult, TOptions> where TPrompt : IPrompt where TResult : class where TOptions : IProviderRequestOptions where TSettings : GenerationSettings
Type Parameters
| Name |
Description |
| TRequest |
The provider-specific request type sent to the backend API.
Must inherit GenerativeRequest<TSelf, TPrompt, TResult, TOptions>.
|
| TInput |
The raw input type accepted by this component (e.g. string, AudioClip).
|
| TOutput |
The Unity-facing output type exposed via onOutput and onStream
(e.g. string, AudioClip, Texture2D).
Produced by converting TResult in ConvertResultAsync.
|
| TPrompt |
The prompt wrapper type passed to the request. Must implement IPrompt.
(e.g. Prompt, AudioPrompt).
|
| TEvent |
The streamed chunk type emitted during streaming
(e.g. Delta<IAudioChunk>, TranscriptDelta).
|
| TResult |
The raw result type returned by the API
(e.g. IAudioAsset, Transcript). Must be a reference type.
|
| TOptions |
The request options interface used to configure the API call.
Must implement IProviderRequestOptions
(e.g. IAudioRequestOptions).
|
| TSettings |
The serializable settings type used in the Unity Inspector.
Must inherit GenerationSettings.
|
Fields
|
Edit this page
View Source
onOutput
Declaration
[FormerlySerializedAs("onGenerated")]
[FormerlySerializedAs("onReceiveResponse")]
[FormerlySerializedAs("onReceiveOutput")]
[FormerlySerializedAs("output")]
public UnityEvent<TOutput> onOutput
Field Value
| Type |
Description |
| UnityEvent<TOutput> |
|
|
Edit this page
View Source
onStatusChanged
Declaration
public UnityEvent<ResponseStatus> onStatusChanged
Field Value
|
Edit this page
View Source
onStream
Declaration
public UnityStreamEvent<TOutput> onStream
Field Value
Properties
|
Edit this page
View Source
Api
Selected AI model's provider API.
Declaration
public override Api Api { get; }
Property Value
Overrides
|
Edit this page
View Source
CurrentRequest
Declaration
public TRequest CurrentRequest { get; protected set; }
Property Value
| Type |
Description |
| TRequest |
|
|
Edit this page
View Source
Model
Declaration
public virtual Model Model { get; }
Property Value
|
Edit this page
View Source
ModelType
Declaration
public abstract ModelType ModelType { get; }
Property Value
|
Edit this page
View Source
SaveFolderPath
Declaration
public string SaveFolderPath { get; set; }
Property Value
|
Edit this page
View Source
SaveOutputs
Declaration
public bool SaveOutputs { get; set; }
Property Value
|
Edit this page
View Source
Settings
Declaration
public TSettings Settings { get; protected set; }
Property Value
| Type |
Description |
| TSettings |
|
|
Edit this page
View Source
Stream
Declaration
public bool Stream { get; set; }
Property Value
Methods
|
Edit this page
View Source
Awake()
Declaration
protected override void Awake()
Overrides
|
Edit this page
View Source
BuildRequest(TInput)
Declaration
protected abstract TRequest BuildRequest(TInput input)
Parameters
| Type |
Name |
Description |
| TInput |
input |
|
Returns
| Type |
Description |
| TRequest |
|
|
Edit this page
View Source
Configures the generator with the specified parameters.
It will overwrite the existing parameters including the serialized parameters.
Overwritten parameters will not be saved(serialized).
Declaration
public void Configure(TSettings settings)
Parameters
| Type |
Name |
Description |
| TSettings |
settings |
|
|
Edit this page
View Source
ConvertEventAsync(TEvent)
Declaration
protected abstract UniTask<TOutput> ConvertEventAsync(TEvent evt)
Parameters
| Type |
Name |
Description |
| TEvent |
evt |
|
Returns
| Type |
Description |
| UniTask<TOutput> |
|
|
Edit this page
View Source
ConvertResultAsync(TResult)
Declaration
protected abstract UniTask<TOutput> ConvertResultAsync(TResult result)
Parameters
| Type |
Name |
Description |
| TResult |
result |
|
Returns
| Type |
Description |
| UniTask<TOutput> |
|
|
Edit this page
View Source
Generate(TInput)
Generates output based on the provided input prompt.
This method enqueues the generation task and triggers the onSendRequest event.
It should be called to start the generation process.
Declaration
public void Generate(TInput prompt)
Parameters
| Type |
Name |
Description |
| TInput |
prompt |
|
|
Edit this page
View Source
GenerateAsync(TInput)
Asynchronously generates output based on the provided input prompt.
This method should be overridden in derived classes to implement the actual generation logic.
It returns a UniTask that resolves to the generated output.
The onReceiveGeneratedContent event is triggered with the generated output once the task completes.
Declaration
public UniTask<Generated<TResult>> GenerateAsync(TInput prompt)
Parameters
| Type |
Name |
Description |
| TInput |
prompt |
|
Returns
|
Edit this page
View Source
InitializeAsync()
Initialize the component asynchronously.
This method must be called before using the component.
Declaration
public override UniTask InitializeAsync()
Returns
Overrides
|
Edit this page
View Source
OnComplete(Generated<TResult>)
Declaration
public virtual void OnComplete(Generated<TResult> result)
Parameters
| Type |
Name |
Description |
| Generated<TResult> |
result |
|
|
Edit this page
View Source
OnDelta(TEvent)
Declaration
public virtual void OnDelta(TEvent evt)
Parameters
| Type |
Name |
Description |
| TEvent |
evt |
|
|
Edit this page
View Source
OnStatusChanged(ResponseStatus)
Declaration
public void OnStatusChanged(ResponseStatus status)
Parameters
|
Edit this page
View Source
StreamAsync(TInput)
Declaration
public UniTask<IGenerativeStream<TEvent, TResult>> StreamAsync(TInput input)
Parameters
| Type |
Name |
Description |
| TInput |
input |
|
Returns
Implements
Extension Methods