Class FineTuningClient

The FineTuningClient class. Generally accessed through the client through client.tune, but can be instantiated directly if desired.

This client allows tuning loras using assets created in AssetLibrary.

Constructors

Properties

client: Client
endpoint: string

Methods

  • Cancel a tune.

    Parameters

    • id: string

      ID of tune to be deleted.

    Returns Promise<void>

    Throws

    OctoAIValidationError if no token was found when creating the Client class or if id is invalid.

    Remarks

    Will throw client or server errors if the cancellation request fails.

  • Creates a finetuning job, then returns the Tune.

    Returns Promise<Tune>

    Throws

    OctoAIValidationError if no token was found when creating the Client class.

    Remarks

    This is used with CreateTuneRequest. This method uses assets, such as files, created in AssetLibrary to tune a LoRA.

    A code snippet of how to use this method to create a Stable Diffusion V1.5 LoRA is below:

        import { Client, Asset } from "@octoai/client";

    const client = new Client(process.env.OCTOAI_TOKEN);

    const checkpoint = await (client.asset.list({
    is_public: true,
    owner: "octoai",
    name: "default-sd15",
    })).then(r => r.data[0]);

    let assets: Asset[] = [];
    // It's recommended tunes include at least 5 images
    for (let i = 0; i < 2; i++) {
    const asset = await client.asset.create({
    name: `test_poodle_${i}`,
    file: `test_assets/mitchi${i}.jpg`,
    data: {file_format: "jpg"},
    asset_type: "file",
    description: "an sks3 poodle"
    });
    assets.push(asset);
    }

    console.log(JSON.stringify(assets, undefined, 4));

    const tune = await client.tune.create({
    name: "test-sks3-poodle-sd15",
    description: "sks3 poodle",
    details: {
    base_checkpoint: checkpoint,
    files: assets,
    steps: 500,
    tune_type: "lora_tune",
    trigger_words: ["sks3"],
    });

    console.log(JSON.stringify(tune, undefined, 4));
  • Delete a tune.

    Parameters

    • id: string

      ID of tune to be deleted.

    Returns Promise<void>

    Throws

    OctoAIValidationError if no token was found when creating the Client class or if id is invalid.

    Remarks

    Will throw client or server errors if the deletion requests fails.

  • Get a single tune.

    Parameters

    • id: string

      The tune ID of the tune being requested.

    Returns Promise<Tune>

    Throws

    OctoAIValidationError - if no token was found when creating the Client class, or if an empty string is provided for id.

  • List tunes based on the search parameters provided. Array of tunes can be accessed in response's data field.

    Parameters

    Returns Promise<ListTunesResponse>

    Remarks

    This method is used with the ListTunesRequest class to query the tunes and return. If there are more tunes, the ListTunesResponse will return true for has_more as well as the total number of tunes.

    You can search by name, tune_type such as "lora_tune", engine such as "image/controlnet-sdxl", specific trigger words, set a limit, or start the next request at a certain offset for larger requests.

    An example of how to request your tunes for Stable Diffusion is below:

      const client = new Client(process.env.OCTOAI_TOKEN);
    const sdTunesResp = await client.tune.list({
    engine: "image/stable-diffusion-v1-5",
    });
    const sdTunes = sdTunesResp.data;

    Throws

    OctoAIValidationError if there isn't a token set in the client.

  • Private

    Parameters

    • name: string

    Returns void

Generated using TypeDoc