-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update examples for fine_tuning
- Loading branch information
1 parent
0f6e052
commit 662d50e
Showing
4 changed files
with
62 additions
and
76 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use dotenvy::dotenv; | ||
use futures::StreamExt; | ||
use rs_openai::{fine_tuning::CreateFineTuningRequestBuilder, OpenAI}; | ||
use std::env::var; | ||
use std::io::{stdout, Write}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
dotenv().ok(); | ||
let api_key = var("OPENAI_API_KEY").unwrap(); | ||
|
||
let client = OpenAI::new(&OpenAI { | ||
api_key, | ||
org_id: None, | ||
}); | ||
|
||
// create | ||
let req = CreateFineTuningRequestBuilder::default() | ||
.training_file("YOUR_FINE_TUNE_FILE") | ||
.model("davinci") | ||
.build()?; | ||
|
||
let res = client.fine_tuning().create(&req).await?; | ||
println!("{:?}", res); | ||
|
||
// list | ||
let res = client.fine_tuning().list().await?; | ||
println!("{:?}", res); | ||
|
||
// list events | ||
let res = client.fine_tuning().list_events("").await?; | ||
println!("{:?}", res); | ||
|
||
// list checkpoints | ||
let res = client.fine_tuning().list_checkpoints("").await?; | ||
println!("{:?}", res); | ||
|
||
// retrieve | ||
let res = client.fine_tuning().retrieve("").await?; | ||
println!("{:?}", res); | ||
|
||
// cancel | ||
let res = client.fine_tuning().cancel("").await?; | ||
println!("{:?}", res); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters