Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples #12

Merged
merged 33 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8557efc
Add a temp example
KATTA-00 Aug 13, 2024
83bb670
Remove temp example and add sarcastic-bot example
KATTA-00 Aug 13, 2024
61751b3
Add the Sport headlines analyzer example
KATTA-00 Aug 14, 2024
9b0ea37
Update the printing messages in examples
KATTA-00 Aug 14, 2024
8bbc2fa
Update the README.md of examples
KATTA-00 Aug 14, 2024
00e9395
Remove unwanted lines
KATTA-00 Aug 14, 2024
15bb1c0
Update imports of examples
KATTA-00 Aug 14, 2024
c025a9d
Update Ballerina.toml
KATTA-00 Aug 14, 2024
d8a4512
Update README.md
KATTA-00 Aug 14, 2024
d261808
Add licenses to examples
KATTA-00 Aug 14, 2024
e98e0be
Updatethe examples and versions
KATTA-00 Aug 14, 2024
0a9127a
remove unwanted spaces
KATTA-00 Aug 14, 2024
2a75cdd
Update examples/Sarcastic-bot/Ballerina.toml
KATTA-00 Aug 14, 2024
8228921
Update examples/Sarcastic-bot/Ballerina.toml
KATTA-00 Aug 14, 2024
ba483c0
Update examples/Sarcastic-bot/main.bal
KATTA-00 Aug 14, 2024
d78bbbb
Update examples/Sports-headline-analyzer/Ballerina.toml
KATTA-00 Aug 14, 2024
7a4a2b9
Update examples/Sports-headline-analyzer/main.bal
KATTA-00 Aug 14, 2024
3cc6f6a
Update examples/Sports-headline-analyzer/main.bal
KATTA-00 Aug 14, 2024
2e85221
Update examples/Sports-headline-analyzer/Ballerina.toml
KATTA-00 Aug 14, 2024
623d863
Update examples
KATTA-00 Aug 14, 2024
84d75ee
Update examples/README.md
KATTA-00 Aug 14, 2024
ed5c957
Update examples/Sports-headline-analyzer/Sports headline analyzer.md
KATTA-00 Aug 14, 2024
c18fa99
Update examples/Sports-headline-analyzer/Sports headline analyzer.md
KATTA-00 Aug 14, 2024
38ed1da
Remove gitignore from examples
KATTA-00 Aug 14, 2024
972a15c
Update API key generation step in Sports headline analyzer.md
KATTA-00 Aug 14, 2024
c1c2ba7
Add the examples to README.md
KATTA-00 Aug 14, 2024
edbd1b8
Update examples/Sarcastic-bot/Sarcastic bot.md
KATTA-00 Aug 15, 2024
8de9072
Update README.md
KATTA-00 Aug 15, 2024
38bd08d
Update README.md
KATTA-00 Aug 15, 2024
d74d6f3
Add examples in Module.md and Package.md
KATTA-00 Aug 15, 2024
128267e
Merge branch 'main' into example
KATTA-00 Aug 15, 2024
fb9ae0f
Update README.md
KATTA-00 Aug 15, 2024
5091637
Apply suggestions from code review
NipunaRanasinghe Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
distribution = "2201.9.2"
org = "ballerinax"
name = "openai.finetunes"
version = "1.0.5"
version = "1.0.7"
KATTA-00 marked this conversation as resolved.
Show resolved Hide resolved
license = ["Apache-2.0"]
authors = ["Ballerina"]
keywords = [] # TODO: Add keywords
Expand Down
6 changes: 3 additions & 3 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ distribution-version = "2201.9.2"
[[package]]
org = "ballerina"
name = "auth"
version = "2.11.1"
version = "2.11.2"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -107,7 +107,7 @@ version = "0.0.0"
[[package]]
org = "ballerina"
name = "jwt"
version = "2.12.1"
version = "2.11.0"
NipunaRanasinghe marked this conversation as resolved.
Show resolved Hide resolved
dependencies = [
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "crypto"},
Expand Down Expand Up @@ -289,7 +289,7 @@ modules = [
[[package]]
org = "ballerinax"
name = "openai.finetunes"
version = "1.0.5"
version = "1.0.7"
NipunaRanasinghe marked this conversation as resolved.
Show resolved Hide resolved
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "mime"},
Expand Down
34 changes: 11 additions & 23 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Examples

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 cache management, session management, and rate limiting.
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.

[//]: # (TODO: Add examples)
1.
2.
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.

## Prerequisites

[//]: # (TODO: Add prerequisites)
1. Generate a API as described in the [Setup guide](https://central.ballerina.io/ballerinax/openai.finetunes/latest#setup-guide).
KATTA-00 marked this conversation as resolved.
Show resolved Hide resolved

2. For each example, create a `Config.toml` file the related configuration. Here's an example of how your `Config.toml` file should look:

```toml
token = "<API Key>"
```

## Running an Example

Expand All @@ -24,22 +30,4 @@ Execute the following commands to build an example from the source:

```bash
bal run
```

## Building the Examples with the Local Module

**Warning**: Due to the absence of support for reading local repositories for single Ballerina files, the Bala of the module is manually written to the central repository as a workaround. Consequently, the bash script may modify your local Ballerina repositories.

Execute the following commands to build all the examples against the changes you have made to the module locally:

* To build all the examples:

```bash
./build.sh build
```

* To run all the examples:

```bash
./build.sh run
```
11 changes: 11 additions & 0 deletions examples/Sarcastic-bot/.gitignore
KATTA-00 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ballerina generates this directory during the compilation of a package.
# It contains compiler-generated artifacts and the final executable if this is an application package.
target/

# Ballerina maintains the compiler-generated source code here.
# Remove this if you want to commit generated sources.
generated/

# Contains configuration values used during development time.
# See https://ballerina.io/learn/provide-values-to-configurable-variables/ for more details.
Config.toml
14 changes: 14 additions & 0 deletions examples/Sarcastic-bot/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
org = "kanishka"
KATTA-00 marked this conversation as resolved.
Show resolved Hide resolved
name = "Sports_headline_analyzer"
KATTA-00 marked this conversation as resolved.
Show resolved Hide resolved
version = "0.1.0"
distribution = "2201.9.2"

[build-options]
observabilityIncluded = true

[[dependency]]
org = "ballerinax"
name = "openai.finetunes"
version = "1.0.7"
repository = "local"
KATTA-00 marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading