Class FluentApiRequest<TSelf, TResult>
public abstract class FluentApiRequest<TSelf, TResult> where TSelf : FluentApiRequest<TSelf, TResult>
Type Parameters
TSelfTResult
- Inheritance
-
objectFluentApiRequest<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
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
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
Options
public FluentApiRequestOptions Options { get; }
Property Value
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
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
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
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
ctCancellationToken
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
ctCancellationToken
Returns
- UniTask<T>
Type Parameters
T
Exceptions
- InvalidOperationException
ResolveOutputPath(string)
protected virtual string ResolveOutputPath(string rawOutputPath = null)
Parameters
rawOutputPathstring
Returns
- string
SetListener(IListener)
public TSelf SetListener(IListener listener)
Parameters
listenerIListener
Returns
- TSelf
SetLogLevel(TraceLevel)
Sets the log level for this request.
public TSelf SetLogLevel(TraceLevel logLevel)
Parameters
logLevelTraceLevel
Returns
- TSelf
SetMetadata(ServerDictionary)
Sets OpenAI-specific metadata for the request.
public TSelf SetMetadata(ServerDictionary metadata)
Parameters
metadataServerDictionary
Returns
- TSelf
SetOutputPath(string)
Sets the output path for this request.
public TSelf SetOutputPath(string outputPath)
Parameters
outputPathstring
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
SetSafetyIdentifier(string)
public TSelf SetSafetyIdentifier(string id)
Parameters
idstring
Returns
- TSelf
SetSender(string)
Sets the sender ID for tracking or attribution purposes.
public TSelf SetSender(string sender)
Parameters
senderstring
Returns
- TSelf
SetStream(bool)
public TSelf SetStream(bool stream)
Parameters
streambool
Returns
- TSelf
StreamAsync(IListener, CancellationToken)
[Obsolete("Use CreateStreamAsync() for streaming requests.")]
public virtual UniTask<TResult> StreamAsync(IListener listener = null, CancellationToken ct = default)
Parameters
listenerIListenerctCancellationToken
Returns
- UniTask<TResult>