diff --git a/ballerina/tests/mock_service.bal b/ballerina/tests/mock_service.bal index ac41234..e645f74 100644 --- a/ballerina/tests/mock_service.bal +++ b/ballerina/tests/mock_service.bal @@ -36,7 +36,6 @@ listener http:Listener httpListener = new (9090); http:Service mockService = service object { - # Delete a fine-tuned model. You must have the Owner role in your organization to delete a model. # # + model - The model to delete @@ -59,7 +58,7 @@ http:Service mockService = service object { resource function post fine_tuning/jobs/[string fine_tuning_job_id]/cancel() returns OkFineTuningJob { OkFineTuningJob response = { - body:{ + body: { "object": "fine_tuning.job", "id": fine_tuning_job_id, "model": "gpt-3.5-turbo-0125", @@ -82,11 +81,11 @@ http:Service mockService = service object { "seed": 1776549854, "estimated_finish": null, "integrations": [] - }, - headers: { - "Content-Type": "application/json" - } - }; + }, + headers: { + "Content-Type": "application/json" + } + }; return response; } @@ -139,7 +138,6 @@ http:Service mockService = service object { }; return response; - } # Returns information about a specific file. @@ -160,7 +158,6 @@ http:Service mockService = service object { }; return response; - } # Returns the contents of the specified file. @@ -172,7 +169,6 @@ http:Service mockService = service object { byte[] response = [123, 34, 116, 101, 120, 116, 34, 58, 34, 72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 34, 125]; return response; - } # List your organization's fine-tuning jobs @@ -218,11 +214,10 @@ http:Service mockService = service object { }; return response; - } # Get info about a fine-tuning job. - # + # # [Learn more about fine-tuning](/docs/guides/fine-tuning) # # + fine_tuning_job_id - The ID of the fine-tuning job. @@ -259,7 +254,6 @@ http:Service mockService = service object { }; return response; - } # List checkpoints for a fine-tuning job. @@ -280,7 +274,7 @@ http:Service mockService = service object { "fine_tuned_model_checkpoint": "gpt-3.5-turbo-0125-1", "fine_tuning_job_id": fine_tuning_job_id, "metrics": { - "step":1 + "step": 1 }, "step_number": 2 } @@ -289,7 +283,6 @@ http:Service mockService = service object { }; return response; - } # Get status updates for a fine-tuning job. @@ -314,14 +307,13 @@ http:Service mockService = service object { }; return response; - } # Lists the currently available models, and provides basic information about each one such as the owner and availability. # # + return - OK resource function get models() returns ListModelsResponse { - + ListModelsResponse response = { 'object: "list", data: [ @@ -341,7 +333,6 @@ http:Service mockService = service object { }; return response; - } # Retrieves a model instance, providing basic information about the model such as the owner and permissioning. @@ -358,17 +349,16 @@ http:Service mockService = service object { }; return response; - } # Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB. - # + # # The Assistants API supports files up to 2 million tokens and of specific file types. See the [Assistants Tools guide](/docs/assistants/tools) for details. - # + # # The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning [chat](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) models. - # + # # The Batch API only supports `.jsonl` files up to 100 MB in size. The input also has a specific required [format](/docs/api-reference/batch/request-input). - # + # # Please [contact us](https://help.openai.com/) if you need to increase these storage limits. # # + return - OK @@ -391,20 +381,19 @@ http:Service mockService = service object { }; return response; - } # Creates a fine-tuning job which begins the process of creating a new model from a given dataset. - # + # # Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. - # + # # [Learn more about fine-tuning](/docs/guides/fine-tuning) # # + return - OK resource function post fine_tuning/jobs(@http:Payload CreateFineTuningJobRequest payload) returns OkFineTuningJob { OkFineTuningJob response = { - body:{ + body: { "object": "fine_tuning.job", "id": "ftjob-5NikxOY1BsPHxt8Z8YBm8AX1", "model": "gpt-3.5-turbo-0125", @@ -427,16 +416,14 @@ http:Service mockService = service object { "seed": 1776549854, "estimated_finish": null, "integrations": [] - }, - headers: { - "Content-Type": "application/json" - } - }; + }, + headers: { + "Content-Type": "application/json" + } + }; return response; - } - }; function init() returns error? { diff --git a/ballerina/tests/test.bal b/ballerina/tests/test.bal index 37a91fe..96d3002 100644 --- a/ballerina/tests/test.bal +++ b/ballerina/tests/test.bal @@ -31,7 +31,7 @@ final Client openAIFinetunes = check new Client(config, serviceUrl); // Define sample file content and name. final string fileName = "sample.jsonl"; -const byte[] fileContent = [123,13,10,32,32,32,32,34,112,114,111,109,112,116,34,58,32,34,87,104,97,116,32,105,115,32,116,104,101,32,97,110,115,119,101,114,32,116,111,32,50,43,50,34,44,13,10,32,32,32,32,34,99,111,109,112,108,101,116,105,111,110,34,58,32,34,52,34,13,10,125]; +const byte[] fileContent = [123, 13, 10, 32, 32, 32, 32, 34, 112, 114, 111, 109, 112, 116, 34, 58, 32, 34, 87, 104, 97, 116, 32, 105, 115, 32, 116, 104, 101, 32, 97, 110, 115, 119, 101, 114, 32, 116, 111, 32, 50, 43, 50, 34, 44, 13, 10, 32, 32, 32, 32, 34, 99, 111, 109, 112, 108, 101, 116, 105, 111, 110, 34, 58, 32, 34, 52, 34, 13, 10, 125]; // Record type to hold test data. public type TestData record { @@ -49,7 +49,7 @@ function dataGen() returns TestData[][] { } @test:Config { - dataProvider: dataGen, + dataProvider: dataGen, groups: ["Models"] } isolated function testListModels(TestData testData) returns error? { @@ -60,7 +60,7 @@ isolated function testListModels(TestData testData) returns error? { } @test:Config { - dataProvider: dataGen, + dataProvider: dataGen, dependsOn: [testListModels], groups: ["Models"] } @@ -73,8 +73,8 @@ isolated function testRetrieveModel(TestData testData) returns error? { @test:Config { dependsOn: [testCreateFineTuningJob, testListModels, testRetrieveModel, testListFineTuningJobCheckpoints, testListFineTuningEvents], - dataProvider: dataGen, - enable: isLiveServer? false : true, // Enable this test only for mock server. + dataProvider: dataGen, + enable: isLiveServer ? false : true, // Enable this test only for mock server. groups: ["Models"] } isolated function testDeleteModel(TestData testData) returns error? { @@ -124,7 +124,7 @@ isolated function testRetrieveFile(TestData testData) returns error? { @test:Config { dependsOn: [testCreateFile], - dataProvider: dataGen, + dataProvider: dataGen, groups: ["Files"] } isolated function testDownloadFile(TestData testData) returns error? { @@ -135,7 +135,7 @@ isolated function testDownloadFile(TestData testData) returns error? { @test:Config { dependsOn: [testCreateFile, testRetrieveFile, testDownloadFile, testCreateFineTuningJob], - dataProvider: dataGen, + dataProvider: dataGen, groups: ["Files"] } isolated function testDeleteFile(TestData testData) returns error? { @@ -156,7 +156,7 @@ isolated function testListPaginatedFineTuningJobs() returns error? { @test:Config { dependsOn: [testListModels, testCreateFile], - dataProvider: dataGen, + dataProvider: dataGen, groups: ["Fine-tuning"] } isolated function testCreateFineTuningJob(TestData testData) returns error? { @@ -176,7 +176,7 @@ isolated function testCreateFineTuningJob(TestData testData) returns error? { @test:Config { dependsOn: [testCreateFineTuningJob], - dataProvider: dataGen, + dataProvider: dataGen, groups: ["Fine-tuning"] } isolated function testRetrieveFineTuningJob(TestData testData) returns error? { @@ -188,7 +188,7 @@ isolated function testRetrieveFineTuningJob(TestData testData) returns error? { @test:Config { dependsOn: [testCreateFineTuningJob], - dataProvider: dataGen, + dataProvider: dataGen, groups: ["Fine-tuning"] } isolated function testListFineTuningEvents(TestData testData) returns error? { @@ -200,7 +200,7 @@ isolated function testListFineTuningEvents(TestData testData) returns error? { @test:Config { dependsOn: [testCreateFineTuningJob], - dataProvider: dataGen, + dataProvider: dataGen, groups: ["Fine-tuning"] } isolated function testListFineTuningJobCheckpoints(TestData testData) returns error? { @@ -212,8 +212,8 @@ isolated function testListFineTuningJobCheckpoints(TestData testData) returns er @test:Config { dependsOn: [testCreateFineTuningJob], - dataProvider: dataGen, - enable: isLiveServer? false : true, // Enable this test only for mock server. + dataProvider: dataGen, + enable: isLiveServer ? false : true, // Enable this test only for mock server. groups: ["Fine-tuning"] } isolated function testCancelFineTuningJob(TestData testData) returns error? {