Table of Contents

Class FluentApiRequest<TSelf, TResult>

Namespace
Glitch9.AIDevKit
public abstract class FluentApiRequest<TSelf, TResult> where TSelf : FluentApiRequest<TSelf, TResult>

Type Parameters

TSelf
TResult
Inheritance
object
FluentApiRequest<TSelf, TResult>
Derived

Properties

Api

The cloud service provider associated with this task. Automatically resolved from the selected model if not explicitly set.

public virtual Api Api { get; set; }

Property Value

Api

IsCanceled

public bool IsCanceled { get; }

Property Value

bool

IsWrapperTask

public virtual bool IsWrapperTask { get; }

Property Value

bool

Listener

Required if Stream is true. Event listener to handle streaming events such as receiving text, tool calls, deltas, and completion.

public IListener Listener { get; set; }

Property Value

IListener

LogLevel

public TraceLevel? LogLevel { get; set; }

Property Value

TraceLevel?

Metadata

OpenAI-specific. Optional. Set of 16 key-value pairs that can be attached to an object.

public ServerDictionary Metadata { get; set; }

Property Value

ServerDictionary

Options

public FluentApiRequestOptions Options { get; }

Property Value

FluentApiRequestOptions

OutputPath

public string OutputPath { get; set; }

Property Value

string

RequestMimeType

public virtual MimeType RequestMimeType { get; set; }

Property Value

MimeType

ResponseMimeType

public virtual MimeType ResponseMimeType { get; set; }

Property Value

MimeType

SafetyIdentifier

A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies. The IDs should be a string that uniquely identifies each user. We recommend hashing their username or email address, in order to avoid sending us any identifying information. https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers

public SafetyIdentifier SafetyIdentifier { get; set; }

Property Value

SafetyIdentifier

Sender

public string Sender { get; set; }

Property Value

string

ServiceTier

The service tier to use for the request. "auto" lets the system choose the appropriate tier based on context. Different providers may have different tier names and meanings. See provider documentation for details.

public ServiceTier? ServiceTier { get; set; }

Property Value

ServiceTier?

Stream

Optional. Defaults to false If set to true, the model response data will be streamed to the client as it is generated.

public bool Stream { get; set; }

Property Value

bool

Type

public abstract FluentApiRequestType Type { get; }

Property Value

FluentApiRequestType

Methods

Cancel()

Cancels the current task.

public void Cancel()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

ExecuteAsync(CancellationToken)

Executes the task and returns the output of type TResult. This is the main entry point for executing the task.

public virtual UniTask<TResult> ExecuteAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

UniTask<TResult>

ExecuteAsyncInternal()

protected abstract UniTask<TResult> ExecuteAsyncInternal()

Returns

UniTask<TResult>

ExecuteSequenceAsync<T>(CancellationToken)

Interface method to execute the task and return a specific type. This is useful for tasks that return a specific type of output. Mainly used internally for GenerativeSequence.

public UniTask<T> ExecuteSequenceAsync<T>(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

UniTask<T>

Type Parameters

T

Exceptions

InvalidOperationException

ResolveOutputPath(string)

protected virtual string ResolveOutputPath(string rawOutputPath = null)

Parameters

rawOutputPath string

Returns

string

SetListener(IListener)

public TSelf SetListener(IListener listener)

Parameters

listener IListener

Returns

TSelf

SetLogLevel(TraceLevel)

Sets the log level for this request.

public TSelf SetLogLevel(TraceLevel logLevel)

Parameters

logLevel TraceLevel

Returns

TSelf

SetMetadata(ServerDictionary)

Sets OpenAI-specific metadata for the request.

public TSelf SetMetadata(ServerDictionary metadata)

Parameters

metadata ServerDictionary

Returns

TSelf

SetOutputPath(string)

Sets the output path for this request.

public TSelf SetOutputPath(string outputPath)

Parameters

outputPath string

Returns

TSelf

SetRequestMimeType(MimeType)

public TSelf SetRequestMimeType(MimeType mimeType)

Parameters

mimeType MimeType

Returns

TSelf

SetResponseMimeType(MimeType)

Sets a custom MIME type for the output.

public TSelf SetResponseMimeType(MimeType mimeType)

Parameters

mimeType MimeType

Returns

TSelf

SetSafetyIdentifier(string)

public TSelf SetSafetyIdentifier(string id)

Parameters

id string

Returns

TSelf

SetSender(string)

Sets the sender ID for tracking or attribution purposes.

public TSelf SetSender(string sender)

Parameters

sender string

Returns

TSelf

SetStream(bool)

public TSelf SetStream(bool stream)

Parameters

stream bool

Returns

TSelf

StreamAsync(IListener, CancellationToken)

[Obsolete("Use CreateStreamAsync() for streaming requests.")]
public virtual UniTask<TResult> StreamAsync(IListener listener = null, CancellationToken ct = default)

Parameters

listener IListener
ct CancellationToken

Returns

UniTask<TResult>