ballerinax/openai.finetunes Ballerina library

1.0.4

Overview

This is a generated connector for the OpenAI Fine-tunes API OpenAPI specification. OpenAI is an American artificial intelligence research laboratory consisting of a non-profit corporation and a for-profit subsidiary. OpenAI conducts AI research with the declared intention of promoting and developing friendly AI. The OpenAI Fine-tunes API provides a way to customize new AI models developed by OpenAI for your specific needs.

Prerequisites

Before using this connector in your Ballerina application, complete the following:

Quick start

To use the OpenAI Fine-tunes connector in your Ballerina application, update the .bal file as follows:

Step 1: Import the connector

First, import the ballerinax/openai.finetunes module (along with the other required imports) as given below.

Copy
import ballerinax/openai.finetunes;
import ballerina/io;

Step 2: Create a new connector instance

Create and initialize a finetunes:Client with the obtained apiKey.

Copy
finetunes:Client finetunesClient = check new ({
    auth: {
        token: "sk-XXXXXXXXX"
    }
});

Step 3: Invoke the connector operation

  1. Now, you can use the operations available within the connector.

    Following is an example on fine tuning the GPT-3 ada model:

    Copy
    public function main() returns error? {
        finetunes:CreateFileRequest req = {
            file: {fileContent: check io:fileReadBytes("sample.jsonl"), fileName: "sample.jsonl"},
            purpose: "fine-tune"
        };
        finetunes:OpenAIFile fileRes = check finetunesClient->/files.post(req);
        string fileId = fileRes.id;
    
        finetunes:CreateFineTuneRequest createFineTuneRequest = {
            model: "ada",
            training_file: fileId
        };
    
        finetunes:FineTune res = check finetunesClient->/fine\-tunes.post(createFineTuneRequest);
        io:println(res.id);
    }
  2. Use the bal run command to compile and run the Ballerina program.

Import

import ballerinax/openai.finetunes;Copy

Metadata

Released date: 11 months ago

Version: 1.0.4

License: Apache-2.0


Compatibility

Platform: any

Ballerina version: 2201.4.1

GraalVM compatible: Yes


Pull count

Total: 12

Current verison: 1


Weekly downloads


Source repository


Keywords

AI/Fine-tunes

OpenAI

Cost/Paid

Files

Models

Vendor/OpenAI


Contributors

Other versions

See more...