From 5b6b81e524e9566eea2b07879d37683602c2c75c Mon Sep 17 00:00:00 2001 From: KATTA-00 Date: Wed, 21 Aug 2024 10:08:21 +0530 Subject: [PATCH 1/2] Change the client init in examples --- examples/Sarcastic-bot/main.bal | 6 +++--- examples/Sports-headline-analyzer/main.bal | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/Sarcastic-bot/main.bal b/examples/Sarcastic-bot/main.bal index 8fc50e1..17b2c5f 100644 --- a/examples/Sarcastic-bot/main.bal +++ b/examples/Sarcastic-bot/main.bal @@ -25,11 +25,11 @@ const VALIDATION_FILENAME = "validation.jsonl"; const TRAINING_FILEPATH = "./data/" + TRAINING_FILENAME; const VALIDATION_FILEPATH = "./data/" + VALIDATION_FILENAME; -final finetunes:ConnectionConfig config = {auth: {token}}; -final finetunes:Client openAIFinetunes = check new finetunes:Client(config, SERVICE_URL); - public function main() returns error? { + final finetunes:ConnectionConfig config = {auth: {token}}; + final finetunes:Client openAIFinetunes = check new finetunes:Client(config, SERVICE_URL); + byte[] trainingFileContent = check io:fileReadBytes(TRAINING_FILEPATH); byte[] validationFileContent = check io:fileReadBytes(VALIDATION_FILEPATH); diff --git a/examples/Sports-headline-analyzer/main.bal b/examples/Sports-headline-analyzer/main.bal index 42a0cea..05ec645 100644 --- a/examples/Sports-headline-analyzer/main.bal +++ b/examples/Sports-headline-analyzer/main.bal @@ -23,11 +23,11 @@ string SERVICE_URL = "https://api.openai.com/v1"; string TRAINING_FILENAME = "training.jsonl"; string TRAINING_FILEPATH = "./data/" + TRAINING_FILENAME; -final finetunes:ConnectionConfig config = {auth: {token}}; -final finetunes:Client openAIFinetunes = check new finetunes:Client(config, SERVICE_URL); - public function main() returns error? { + final finetunes:ConnectionConfig config = {auth: {token}}; + final finetunes:Client openAIFinetunes = check new finetunes:Client(config, SERVICE_URL); + byte[] trainingFileContent = check io:fileReadBytes(TRAINING_FILEPATH); finetunes:CreateFileRequest trainingFileRequest = { From 48cf550575f76e48c8c5b008e720c2240e3dd0bd Mon Sep 17 00:00:00 2001 From: KATTA-00 Date: Wed, 21 Aug 2024 10:57:51 +0530 Subject: [PATCH 2/2] Refactor the ConnectionConfig --- examples/Sarcastic-bot/main.bal | 6 +++++- examples/Sports-headline-analyzer/main.bal | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/Sarcastic-bot/main.bal b/examples/Sarcastic-bot/main.bal index 17b2c5f..38ffc3f 100644 --- a/examples/Sarcastic-bot/main.bal +++ b/examples/Sarcastic-bot/main.bal @@ -27,7 +27,11 @@ const VALIDATION_FILEPATH = "./data/" + VALIDATION_FILENAME; public function main() returns error? { - final finetunes:ConnectionConfig config = {auth: {token}}; + final finetunes:ConnectionConfig config = { + auth: { + token + } + }; final finetunes:Client openAIFinetunes = check new finetunes:Client(config, SERVICE_URL); byte[] trainingFileContent = check io:fileReadBytes(TRAINING_FILEPATH); diff --git a/examples/Sports-headline-analyzer/main.bal b/examples/Sports-headline-analyzer/main.bal index 05ec645..9ae499e 100644 --- a/examples/Sports-headline-analyzer/main.bal +++ b/examples/Sports-headline-analyzer/main.bal @@ -25,7 +25,11 @@ string TRAINING_FILEPATH = "./data/" + TRAINING_FILENAME; public function main() returns error? { - final finetunes:ConnectionConfig config = {auth: {token}}; + final finetunes:ConnectionConfig config = { + auth: { + token + } + }; final finetunes:Client openAIFinetunes = check new finetunes:Client(config, SERVICE_URL); byte[] trainingFileContent = check io:fileReadBytes(TRAINING_FILEPATH);