///
import { Asset, AssetType, BaseEngine, DataType, DeleteAssetResponse, ListAssetsResponse, PresignedUrlTransferApi, StsTransferApi, TransferApiType } from "../generated/assetLake";
import { Client } from "./client";
/**
* Request for creating an asset.
*
* @remarks
* This is used with {@link AssetLibrary.create}. The `data` field requires
* data from the matching asset_type. This includes {@link FileData},
* {@link CheckpointData}, {@link LoraData}, {@link VAEData},
* and {@link TextualInversionData}.
*/
export declare class CreateAssetRequest {
/**
* string representing filepath, Buffer, or ArrayBuffer containing data of
* asset to upload.
*/
file?: string | Buffer | ArrayBuffer;
/**
* {@link AssetType } one of the valid asset types,
* including 'file', 'checkpoint', 'lora', and 'textual_inversion'.
*/
asset_type: AssetType;
/**
* Data specific to the asset type; use the class named (asset_type)Data.
* Includes {@link FileData}, {@link CheckpointData}, {@link LoraData},
* {@link VAEData}, and {@link TextualInversionData}.
*/
data: any;
/**
* Alphanumeric, _, or - allowed.
*/
name: string;
/**
* Description of asset.
*/
description: string | null;
/**
* `true` if asset is public.
*/
is_public?: boolean;
/**
* {@link TransferApiType} - If left undefined,
* the OctoAI TypeScript SDK will select the fastest method for upload based on
* file size.
*/
transfer_api_type?: TransferApiType;
/**
* The URL of the asset to upload.
*/
url?: string;
constructor(request: Record);
}
export declare class ListAssetsRequest {
/**
* Asset name, alphanumeric, -, and _ allowed.
*/
name?: string;
/**
* Whether to filter for public assets, such as looking for `octoai` public
* assets.
*/
is_public?: boolean;
/**
* {@link DataType}, including fp16, fp32, int4, and int8.
*/
data_type?: DataType;
/**
* {@link AssetType} - one of the valid asset types,
* including 'file', 'checkpoint', 'lora', and 'textual_inversion'.
*/
asset_type?: AssetType | AssetType[];
/**
* {@link BaseEngine} of assets such as "image/stable-diffusion-v1-5"
*/
engine?: BaseEngine | BaseEngine[];
/**
* Max number of assets to return.
*/
limit?: number;
/**
* Where to start including next list of assets
*/
offset?: number;
/**
* ID of owner. Can set to `octoai` and `is_public` to true to search octoai
* public assets.
*/
owner?: string;
/**
* Asset IDs. Should start with `asset`, be alphanumeric, `-`, or `_`
* characters.
*/
asset_ids?: string;
constructor(request: Record);
}
/**
* Request to retrieve an asset. Must include a name or id, but not both.
*/
export interface GetAssetRequest {
/**
* string that matches the asset's name
*/
name?: string;
/**
* string that matches the asset's ID, generally starts with `asset`.
*/
id?: string;
}
export interface WaitForOptions {
pollIntervalMs?: number;
timeoutMs?: number;
}
/**
* The AssetLibrary class. Generally accessed through the client through
* `client.asset`, but can be instantiated directly if a different endpoint is
* desired.
*/
export declare class AssetLibrary {
readonly client: Client;
readonly endpoint: string;
constructor(client: Client, endpoint?: string);
/**
* Get a single asset.
*
* @param request - {@link GetAssetRequest} - includes either the name or the
* id of the requested asset.
*
* @throws {@link OctoAIValidationError} - if no token was found when creating
* the {@link Client} class, if neither an `id` nor `name` is provided, if both
* are provided, or if the name or id provided is invalid.
*/
get(request: GetAssetRequest): Promise;
/**
* List assets based on the search parameters provided. Array of assets can be
* accessed in response's `data` field.
*
* @remarks
* This method is used with the {@link ListAssetsRequest} class to query
* the assets and return. If there are more assets, the {@link ListAssetsResponse}
* will return `true` for has_more as well as the `total` number of assets.
*
* You can search by `name`, `data_type` such as "fp16", set a `limit`, or
* start the next request at a certain `offset` for larger requests.
*
* An example of how to request octoai public assets is below:
* ```
* const client = new Client(process.env.OCTOAI_TOKEN);
* const octoAssets = await client.asset.list({
* is_public: true,
* owner: "octoai",
* engine: "image/stable-diffusion-v1-5",
* asset_type: "lora",
* });
* ```
*
* @param request - {@link ListAssetsRequest} - parameters to use to filter
* assets in response.
*
* @throws {@link OctoAIValidationError} if there isn't a token set in the client.
*/
list(request: ListAssetsRequest): Promise;
/**
* Delete an asset.
*
* @param id - ID of asset to be deleted. Should start with `asset`.
*
* @throws {@link OctoAIValidationError} if no token was found when creating
* the {@link Client} class or if id is invalid.
*/
delete(id: string): Promise;
/**
* Creates and uploads asset, then returns the {@link Asset}.
*
* Will select the most efficient transfer_api_type if left undefined.
*
* @param request - {@link CreateAssetRequest}
*
* @throws {@link OctoAIValidationError} if no token was found when creating
* the {@link Client} class.
*
* @remarks
* This is used with {@link CreateAssetRequest}. The `data` field requires
* data from the matching asset_type. This includes {@link FileData},
* {@link CheckpointData}, {@link LoraData}, {@link VAEData},
* and {@link TextualInversionData}.
*
* @example
* Creating an asset from a local file:
* ```ts
* import { Client, LoraData } from "@octoai/client";
*
* const client = new Client(process.env.OCTOAI_TOKEN);
*
* const loraData = {
* asset_type: "lora",
* data_type: "fp16",
* engine: "image/stable-diffusion-v1-5",
* file_format: "safetensors",
* trigger_words: ["origami paper"],
* } as LoraData;
*
* const createdAsset = await client.asset.create({
* file: "./test_assets/origami-paper.safetensors",
* asset_type: "lora",
* description: "origami paper lora",
* data: loraData,
* name: "origami-paper",
* is_public: false,
* });
* ```
*
* @example
* Creating an asset via URL upload:
* ```ts
* import { Client, LoraData } from "@octoai/client";
*
* const client = new Client(process.env.OCTOAI_TOKEN);
*
* const loraData = {
* asset_type: "lora",
* data_type: "fp16",
* engine: "image/stable-diffusion-xl-v1-0",
* file_format: "safetensors",
* trigger_words: ["my trigger word"],
* } as LoraData;
*
* const createdAsset = await client.asset.create({
* url: "",
* asset_type: "lora",
* description: "My SDXL LoRA",
* data: loraData,
* name: "my-sdxl-lora",
* is_public: false,
* });
* ```
*/
create(request: CreateAssetRequest): Promise;
/**
* Waits for an {@link Asset} to be ready to use. Useful when uploading assets via URL.
*
* @param asset - The {@link Asset} to poll.
* @param options - Additional options for changing the poll interval and timeout durations.
* @returns A ready {@link Asset}.
*
* @throws {@link OctoAIValidationError}
* Thrown if the asset has an upload error or if the asset is rejected for safety.
*
* @throws {@link OctoAITimeoutError}
* Thrown if the asset isn't ready by the specified timeout. Doesn't
* necessarily indicate a failure.
*/
waitForReady(asset: Asset, options?: WaitForOptions): Promise;
/** @private */
getBuffer(file: string | ArrayBuffer | Buffer): Promise;
private createAsset;
/** @private */
completeUpload(id: string): Promise;
/** @private */
uploadPresigned(transferApi: PresignedUrlTransferApi, blob: Buffer): Promise;
/** @private */
uploadSts(transferApi: StsTransferApi, blob: Buffer): Promise;
/** @private */
validateNameOrId(nameOrId: string): void;
}