Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…openai.finetunes into example
  • Loading branch information
KATTA-00 committed Aug 21, 2024
2 parents 48cf550 + b5e40f2 commit bcb83bc
Show file tree
Hide file tree
Showing 23 changed files with 37 additions and 39 deletions.
3 changes: 1 addition & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@

# See: https://help.github.com/articles/about-codeowners/

# TODO: Add code owners
# These owners will be the default owners for everything in the repo.
*
* @NipunaRanasinghe
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

[OpenAI](https://openai.com/), an AI research organization focused on creating friendly AI for humanity, offers the [OpenAI API](https://platform.openai.com/docs/api-reference/introduction) to access its powerful AI models for tasks like natural language processing and image generation.

The `ballarinax/openai.finetunes` package offers APIs to connect and interact with [the fine-tuning related endpoints of OpenAI REST API v1](https://platform.openai.com/docs/guides/fine-tuning) allowing users to customize OpenAI's AI models to meet specific needs.
The `ballarinax/openai.finetunes` package offers APIs to connect and interact with [the fine-tuning related endpoints of OpenAI REST API v1](https://platform.openai.com/docs/api-reference/fine-tuning) allowing users to customize OpenAI's AI models to meet specific needs.

## Setup guide

Expand Down Expand Up @@ -50,11 +50,11 @@ import ballerina/io;
Create a `finetunes:ConnectionConfig` with the obtained API Key and initialize the connector.

```ballerina
configurable string apiKey = ?;
configurable string token = ?;
final finetunes:Client openAIFinetunes = check new({
auth: {
token: apiKey
token
}
});
```
Expand Down Expand Up @@ -97,11 +97,11 @@ bal run

## Examples

The `OpenAI Finetunes` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/module-ballerinax-openai.finetunes/tree/main/examples/), covering the following use cases:
The `OpenAI Finetunes` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples), covering the following use cases:

1. [Sarcastic bot](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/Sarcastic-bot) - Fine-tune the GPT-3.5-turbo model to generate sarcastic responses
1. [Sarcastic bot](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/sarcastic-bot) - Fine-tune the GPT-3.5-turbo model to generate sarcastic responses

2. [Sports headline analyzer](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/Sports-headline-analyzer) - Fine-tune the GPT-4o-mini model to extract structured information (player, team, sport, and gender) from sports headlines.
2. [Sports headline analyzer](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/sports-headline-analyzer) - Fine-tune the GPT-4o-mini model to extract structured information (player, team, sport, and gender) from sports headlines.

## Build from the source

Expand Down
12 changes: 6 additions & 6 deletions ballerina/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[OpenAI](https://openai.com/), an AI research organization focused on creating friendly AI for humanity, offers the [OpenAI API](https://platform.openai.com/docs/api-reference/introduction) to access its powerful AI models for tasks like natural language processing and image generation.

The `ballarinax/openai.finetunes` package offers APIs to connect and interact with [the fine-tuning related endpoints of OpenAI REST API v1](https://platform.openai.com/docs/guides/fine-tuning) allowing users to customize OpenAI's AI models to meet specific needs.
The `ballarinax/openai.finetunes` package offers APIs to connect and interact with [the fine-tuning related endpoints of OpenAI REST API v1](https://platform.openai.com/docs/api-reference/fine-tuning) allowing users to customize OpenAI's AI models to meet specific needs.

## Setup guide

Expand Down Expand Up @@ -43,11 +43,11 @@ import ballerina/io;
Create a `finetunes:ConnectionConfig` with the obtained API Key and initialize the connector.

```ballerina
configurable string apiKey = ?;
configurable string token = ?;
final finetunes:Client openAIFinetunes = check new({
auth: {
token: apiKey
token
}
});
```
Expand Down Expand Up @@ -90,8 +90,8 @@ bal run

## Examples

The `OpenAI Finetunes` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/module-ballerinax-openai.finetunes/tree/main/examples/), covering the following use cases:
The `OpenAI Finetunes` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples), covering the following use cases:

1. [Sarcastic bot](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/Sarcastic-bot) - Fine-tune the GPT-3.5-turbo model to generate sarcastic responses
1. [Sarcastic bot](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/sarcastic-bot) - Fine-tune the GPT-3.5-turbo model to generate sarcastic responses

2. [Sports headline analyzer](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/Sports-headline-analyzer) - Fine-tune the GPT-4o-mini model to extract structured information (player, team, sport, and gender) from sports headlines.
2. [Sports headline analyzer](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/sports-headline-analyzer) - Fine-tune the GPT-4o-mini model to extract structured information (player, team, sport, and gender) from sports headlines.
12 changes: 6 additions & 6 deletions ballerina/Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[OpenAI](https://openai.com/), an AI research organization focused on creating friendly AI for humanity, offers the [OpenAI API](https://platform.openai.com/docs/api-reference/introduction) to access its powerful AI models for tasks like natural language processing and image generation.

The `ballarinax/openai.finetunes` package offers APIs to connect and interact with [the fine-tuning related endpoints of OpenAI REST API v1](https://platform.openai.com/docs/guides/fine-tuning) allowing users to customize OpenAI's AI models to meet specific needs.
The `ballarinax/openai.finetunes` package offers APIs to connect and interact with [the fine-tuning related endpoints of OpenAI REST API v1](https://platform.openai.com/docs/api-reference/fine-tuning) allowing users to customize OpenAI's AI models to meet specific needs.

## Setup guide

Expand Down Expand Up @@ -43,11 +43,11 @@ import ballerina/io;
Create a `finetunes:ConnectionConfig` with the obtained API Key and initialize the connector.

```ballerina
configurable string apiKey = ?;
configurable string token = ?;
final finetunes:Client openAIFinetunes = check new({
auth: {
token: apiKey
token
}
});
```
Expand Down Expand Up @@ -90,8 +90,8 @@ bal run

## Examples

The `OpenAI Finetunes` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/module-ballerinax-openai.finetunes/tree/main/examples/), covering the following use cases:
The `OpenAI Finetunes` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples), covering the following use cases:

1. [Sarcastic bot](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/Sarcastic-bot) - Fine-tune the GPT-3.5-turbo model to generate sarcastic responses
1. [Sarcastic bot](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/sarcastic-bot) - Fine-tune the GPT-3.5-turbo model to generate sarcastic responses

2. [Sports headline analyzer](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/Sports-headline-analyzer) - Fine-tune the GPT-4o-mini model to extract structured information (player, team, sport, and gender) from sports headlines.
2. [Sports headline analyzer](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/sports-headline-analyzer) - Fine-tune the GPT-4o-mini model to extract structured information (player, team, sport, and gender) from sports headlines.
14 changes: 7 additions & 7 deletions ballerina/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You can run the tests in either of these environments, and each has its own comp

## Running Tests in the Mock Server

To execute the tests on the mock server, ensure that the `isLiveServer` environment variable is either set to `false` or left unset before initiating the tests.
To execute the tests on the mock server, ensure that the `IS_LIVE_SERVER` environment variable is either set to `false` or left unset before initiating the tests.

This environment variable can be configured within the `Config.toml` file located in the `tests` directory or specified as an environment variable.

Expand All @@ -38,13 +38,13 @@ Alternatively, you can set the environment variable directly.
For Linux or macOS:

```bash
export isLiveServer=false
export IS_LIVE_SERVER=false
```

For Windows:

```bash
setx isLiveServer false
setx IS_LIVE_SERVER false
```

Then, run the following command to execute the tests:
Expand All @@ -71,15 +71,15 @@ Alternatively, you can set your authentication credentials as environment variab
For Linux or macOS:

```bash
export isLiveServer=true
export token="<your-openAI-api-key>"
export IS_LIVE_SERVER=true
export OPENAI_API_KEY="<your-openAI-api-key>"
```

For Windows:

```bash
setx isLiveServer true
setx token <your-openAI-api-key>
setx IS_LIVE_SERVER true
setx OPENAI_API_KEY <your-openAI-api-key>
```

Then, run the following command to execute the tests:
Expand Down
7 changes: 3 additions & 4 deletions ballerina/tests/test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
import ballerina/os;
import ballerina/test;

configurable boolean isLiveServer = os:getEnv("isLiveServer") == "true";
configurable string token = isLiveServer ? os:getEnv("OPENAI_API_KEY") : "test";
configurable boolean isLiveServer = os:getEnv("IS_LIVE_SERVER") == "true";
configurable string token = isLiveServer ? os:getEnv("OPENAI_API_KEY") : "";
configurable string serviceUrl = isLiveServer ? "https://api.openai.com/v1" : "http://localhost:9090";
configurable string apiKey = isLiveServer ? token : "";

final ConnectionConfig config = {
auth: {
token: apiKey
token
}
};
final Client openAIFinetunes = check new Client(config, serviceUrl);
Expand Down
Binary file modified docs/setup/resources/api-key-dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/setup/resources/create-new-secret-key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/setup/resources/navigate-api-key-dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/setup/resources/saved-key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions docs/spec/sanitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ _Edition_: Swan Lake

This document records the sanitation done on top of the official OpenAPI specification from OpenAI Finetune. The OpenAPI specification is obtained from the [OpenAPI specification for the OpenAI API](https://github.com/openai/openai-openapi/blob/master/openapi.yaml). These changes are implemented to enhance the overall usability and readability of the generated client.

1. **Changed the `status_details` property parameter of the `OpenAIFile` object**:
1. **Changed the `status_details` property parameter of the `OpenAIFile` object as a workaround for the issue https://github.com/ballerina-platform/ballerina-lang/issues/43304**:

- **Original**:
- Deprecated: `true`
- Nullable parameter: Not included
Expand All @@ -16,8 +17,7 @@ This document records the sanitation done on top of the official OpenAPI specifi
- Removed the `deprecated` parameter
- Added the `nullable` parameter as `true`

- **Reasons**: The original configuration was generated successfully, but it caused a compile-time error. Updating the parameters resolved this error, enhancing the overall functionality and ensuring smooth compilation.

- **Reasons**: The original configuration was generated successfully, but it caused a run-time error.

2. **Removed the `default:null` property from the following schemas**:
- **Changed Schemas**: `CreateCompletionRequest`,`ChatCompletionStreamOptions`,`CreateChatCompletionRequest`
Expand All @@ -28,16 +28,16 @@ This document records the sanitation done on top of the official OpenAPI specifi
- **Updated**:
- Removed the `default` parameter

- **Reason**: This change is done as a workaround for ballerina openapi tool not allowing to generate the client.
- **Reason**: This change is done as a temporary workaround until the Ballerina OpenAPI tool supports OpenAPI Specification version v3.1.x(Currently supported upto version 3.0.0)

3. **Removed the Required Field from the `Error` Property of `FineTuningJob` Object`**
3. **Removed the Required Field from the `Error` Property of `FineTuningJob` Object**:
- **Original**: The error property of the FineTuningJob object included the code, message, and param as required.

- **Updated**: Removed the required field from the error property.

- **Reasons**: The response does not include the code, message, and param, causing an error of missing required fields when converting.

4. **Changed the response content type in `/files/{file_id}/content` endpoint**
4. **Changed the response content type in `/files/{file_id}/content` endpoint**:
- **Original**: The response content type of the `/files/{file_id}/content` endpoint was originally `application/json`.

- **Updated**: The content type has been changed to `application/octet-stream`.
Expand Down
4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

The `ballerinax/openai.finetunes` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples), covering use cases like file uploading, finetuning models, getting events/checkpoints of a job and deleting files.

1. [Sarcastic Bot](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/Sarcastic-bot) - Fine-tune the GPT-3.5-turbo model to generate sarcastic responses
1. [Sarcastic Bot](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/sarcastic-bot) - Fine-tune the GPT-3.5-turbo model to generate sarcastic responses

2. [Sports Headline Analyzer](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/Sports-headline-analyzer) - Fine-tune the GPT-4o-mini model to extract structured information (player, team, sport, and gender) from sports headlines.
2. [Sports Headline Analyzer](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/tree/main/examples/sports-headline-analyzer) - Fine-tune the GPT-4o-mini model to extract structured information (player, team, sport, and gender) from sports headlines.

## Prerequisites

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit bcb83bc

Please sign in to comment.