Class UnifiedApiRequestBase<TSelf, TResult, TProviderOptions>
Base class for all Fluent API requests.
Provides common properties and methods for configuring and executing requests.
Inheritance
UnifiedApiRequestBase<TSelf, TResult, TProviderOptions>
Assembly: Glitch9.AIDevKit.dll
Syntax
public abstract class UnifiedApiRequestBase<TSelf, TResult, TProviderOptions> where TSelf : UnifiedApiRequestBase<TSelf, TResult, TProviderOptions> where TProviderOptions : IProviderRequestOptions
Type Parameters
| Name |
Description |
| TSelf |
|
| TResult |
|
| TProviderOptions |
|
Constructors
|
Edit this page
View Source
UnifiedApiRequestBase()
Declaration
protected UnifiedApiRequestBase()
Fields
|
Edit this page
View Source
m_Api
Declaration
Field Value
Properties
|
Edit this page
View Source
Api
The cloud service provider associated with this task.
Automatically resolved from the selected model if not explicitly set.
Declaration
public virtual Api Api { get; }
Property Value
|
Edit this page
View Source
ContentType
MIME type for the request content.
Declaration
public virtual MimeType ContentType { get; set; }
Property Value
|
Edit this page
View Source
DownloadOptions
Download options for this
Declaration
public DownloadOptions DownloadOptions { get; set; }
Property Value
|
Edit this page
View Source
HttpOptions
Declaration
public RequestOptions HttpOptions { get; set; }
Property Value
|
Edit this page
View Source
IsCanceled
Indicates if the request has been canceled.
Declaration
public bool IsCanceled { get; }
Property Value
|
Edit this page
View Source
LogOptions
Declaration
public CurlLogOptions LogOptions { get; set; }
Property Value
|
Edit this page
View Source
Optional metadata for the request (OpenAI-specific).
Declaration
public ServerDictionary Metadata { get; set; }
Property Value
|
Edit this page
View Source
Options
Declaration
[Obsolete("Use ProviderOptions instead.")]
public TProviderOptions Options { get; }
Property Value
| Type |
Description |
| TProviderOptions |
|
|
Edit this page
View Source
ProviderOptions
Provider(Vendor)-specific options for this request.
Declaration
public TProviderOptions ProviderOptions { get; set; }
Property Value
| Type |
Description |
| TProviderOptions |
|
|
Edit this page
View Source
RequestType
The endpoint type for this
Declaration
public abstract RequestType RequestType { get; }
Property Value
|
Edit this page
View Source
ResponseType
MIME type for the response. Defaults to JSON.
Declaration
public virtual MimeType ResponseType { get; set; }
Property Value
|
Edit this page
View Source
SafetyIdentifier
Safety identifier for moderation and safety checks.
Declaration
public SafetyIdentifier SafetyIdentifier { get; set; }
Property Value
|
Edit this page
View Source
Sender
The sender ID for tracking or attribution purposes.
Declaration
public string Sender { get; set; }
Property Value
|
Edit this page
View Source
ServiceTier
Service tier for the request (e.g., free, paid, premium).
Declaration
public ServiceTier? ServiceTier { get; set; }
Property Value
|
Edit this page
View Source
Stream
If true, the model response data will be streamed to the client as it is generated.
Declaration
public bool Stream { get; set; }
Property Value
Methods
|
Edit this page
View Source
Cancel()
Cancels the current task.
Declaration
|
Edit this page
View Source
ExecuteAsync(CancellationToken)
Executes the task and returns the output of type TResult.
This is the main entry point for executing the task.
Declaration
public virtual UniTask<TResult> ExecuteAsync(CancellationToken ct = default)
Parameters
Returns
| Type |
Description |
| UniTask<TResult> |
|
|
Edit this page
View Source
ExecuteAsyncInternal()
Executes the actual task logic. Must be implemented in derived classes.
Declaration
protected abstract UniTask<TResult> ExecuteAsyncInternal()
Returns
| Type |
Description |
| UniTask<TResult> |
|
|
Edit this page
View Source
GenerateDefaultFileName()
Generates a default file name for downloaded content.
Override in derived classes to provide type-specific file naming.
Declaration
protected virtual string GenerateDefaultFileName()
Returns
|
Edit this page
View Source
GetConfig<T>()
Gets the specific options for this
Declaration
public T GetConfig<T>() where T : TProviderOptions
Returns
Type Parameters
|
Edit this page
View Source
ResolveDownloadOptions(DownloadOptions)
Resolves download options for this
Declaration
protected virtual DownloadOptions ResolveDownloadOptions(DownloadOptions options = null)
Parameters
Returns
|
Edit this page
View Source
SetApi(Api)
Sets API explicitly for requests that cannot infer it from model/context.
Declaration
protected void SetApi(Api api)
Parameters
| Type |
Name |
Description |
| Api |
api |
|
|
Edit this page
View Source
SetDownloadOptions(DownloadOptions)
Sets the download options for this
Declaration
public TSelf SetDownloadOptions(DownloadOptions downloadOptions)
Parameters
Returns
|
Edit this page
View Source
SetLogOptions(CurlLogOptions)
Sets the log options for this
Declaration
public TSelf SetLogOptions(CurlLogOptions logOptions)
Parameters
Returns
|
Edit this page
View Source
Sets metadata for the request (OpenAI-specific).
Declaration
public TSelf SetMetadata(ServerDictionary metadata)
Parameters
Returns
|
Edit this page
View Source
SetOutputDirectory(string)
Sets the output directory for this request. The file name will be auto-generated.
Declaration
public TSelf SetOutputDirectory(string directoryPath)
Parameters
| Type |
Name |
Description |
| string |
directoryPath |
|
Returns
|
Edit this page
View Source
SetOutputPath(string)
Sets the output path for this
Declaration
public TSelf SetOutputPath(string fullPath)
Parameters
| Type |
Name |
Description |
| string |
fullPath |
|
Returns
|
Edit this page
View Source
SetOutputPath(string, string)
Declaration
public TSelf SetOutputPath(string directoryPath, string fileName)
Parameters
Returns
|
Edit this page
View Source
SetProviderOptions(TProviderOptions)
Sets specific options for the
Declaration
public TSelf SetProviderOptions(TProviderOptions options)
Parameters
| Type |
Name |
Description |
| TProviderOptions |
options |
|
Returns
|
Edit this page
View Source
SetRequestMimeType(MimeType)
Sets the MIME type for the request content.
Declaration
public TSelf SetRequestMimeType(MimeType mimeType)
Parameters
Returns
|
Edit this page
View Source
SetResponseMimeType(MimeType)
Sets a custom MIME type for the output.
Declaration
public TSelf SetResponseMimeType(MimeType mimeType)
Parameters
Returns
|
Edit this page
View Source
SetSafetyIdentifier(string)
Sets the safety identifier for moderation and safety checks.
Declaration
public TSelf SetSafetyIdentifier(string id)
Parameters
| Type |
Name |
Description |
| string |
id |
|
Returns
|
Edit this page
View Source
SetSender(string)
Sets the sender ID for tracking or attribution purposes.
Declaration
public TSelf SetSender(string sender)
Parameters
| Type |
Name |
Description |
| string |
sender |
|
Returns
|
Edit this page
View Source
SetSpecificOptions(TProviderOptions)
Declaration
[Obsolete("Use SetProviderOptions(TProviderOptions) instead.")]
public TSelf SetSpecificOptions(TProviderOptions options)
Parameters
| Type |
Name |
Description |
| TProviderOptions |
options |
|
Returns
|
Edit this page
View Source
SetStream(bool)
Enables or disables streaming for this
Declaration
public TSelf SetStream(bool stream)
Parameters
| Type |
Name |
Description |
| bool |
stream |
|
Returns
|
Edit this page
View Source
ValidateRequest()
Validates the request before execution.
Override in derived classes to implement request validation logic.
Declaration
protected virtual void ValidateRequest()
Extension Methods