FineTuningJobBuilder

Struct FineTuningJobBuilder 

Source
pub struct FineTuningJobBuilder { /* private fields */ }
Expand description

Builder for creating fine-tuning jobs.

Fine-tuning jobs train models on your specific data to improve performance for your particular use case.

ImplementationsΒ§

SourceΒ§

impl FineTuningJobBuilder

Source

pub fn new(model: impl Into<String>, training_file: impl Into<String>) -> Self

Create a new fine-tuning job builder.

Β§Examples
use openai_ergonomic::builders::fine_tuning::FineTuningJobBuilder;

let builder = FineTuningJobBuilder::new("gpt-3.5-turbo", "file-training-data");
Examples found in repository?
examples/fine_tuning.rs (line 120)
89async fn main() -> Result<(), Box<dyn std::error::Error>> {
90    println!("πŸš€ OpenAI Ergonomic - Comprehensive Fine-tuning Example\n");
91
92    // Initialize client from environment variables
93    println!("πŸ“ Initializing OpenAI client...");
94    let client = match Client::from_env() {
95        Ok(c) => {
96            println!("βœ… Client initialized successfully\n");
97            c.build()
98        }
99        Err(e) => {
100            eprintln!("❌ Failed to initialize client: {}", e);
101            eprintln!("πŸ’‘ Make sure OPENAI_API_KEY is set");
102            return Ok(());
103        }
104    };
105
106    // Example 1: Create a fine-tuning job
107    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
108    println!("πŸ“Œ Example 1: Create Fine-tuning Job");
109    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
110
111    // Note: You need to upload a training file first
112    // For demonstration purposes, we'll use a placeholder file ID
113    let training_file_id = "file-training-data";
114
115    println!("Creating fine-tuning job...");
116    println!("  Base Model: gpt-3.5-turbo");
117    println!("  Training File: {}", training_file_id);
118    println!("  Suffix: my-custom-model");
119
120    let builder = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
121        .suffix("my-custom-model")
122        .epochs(3);
123
124    println!("\nπŸ’‘ Note: This would create a real fine-tuning job with your API key.");
125    println!("   Commented out to avoid accidental charges.\n");
126
127    // Uncomment to actually create the job:
128    // match client.fine_tuning().create_job(builder).await {
129    //     Ok(job) => {
130    //         println!("βœ… Fine-tuning job created successfully!");
131    //         println!("  Job ID: {}", job.id);
132    //         println!("  Status: {}", job.status);
133    //         println!("  Model: {}", job.model);
134    //     }
135    //     Err(e) => {
136    //         eprintln!("❌ Failed to create fine-tuning job: {}", e);
137    //     }
138    // }
139
140    // Simulate job creation for demonstration
141    let demo_job = JobInfo::new(
142        "ftjob-demo123",
143        "gpt-3.5-turbo",
144        "validating",
145        training_file_id,
146    );
147    println!("πŸ“Š Demo Job Created:");
148    demo_job.display();
149
150    // Example 2: List fine-tuning jobs
151    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
152    println!("πŸ“Œ Example 2: List Fine-tuning Jobs");
153    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
154
155    println!("Listing fine-tuning jobs (limit: 5)...\n");
156
157    // Uncomment to actually list jobs:
158    // match client.fine_tuning().list_jobs(None, Some(5)).await {
159    //     Ok(response) => {
160    //         println!("βœ… Found {} fine-tuning jobs", response.data.len());
161    //         for (i, job) in response.data.iter().enumerate() {
162    //             println!("\nπŸ“ Job {}:", i + 1);
163    //             println!("  ID: {}", job.id);
164    //             println!("  Model: {}", job.model);
165    //             println!("  Status: {}", job.status);
166    //             println!("  Created At: {}", job.created_at);
167    //         }
168    //     }
169    //     Err(e) => {
170    //         eprintln!("❌ Failed to list fine-tuning jobs: {}", e);
171    //     }
172    // }
173
174    println!("πŸ’‘ Demo: Would list your fine-tuning jobs here");
175
176    // Example 3: Get specific fine-tuning job
177    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
178    println!("πŸ“Œ Example 3: Get Fine-tuning Job Details");
179    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
180
181    let job_id = "ftjob-demo123";
182    println!("Retrieving job: {}\n", job_id);
183
184    // Uncomment to actually get job:
185    // match client.fine_tuning().get_job(job_id).await {
186    //     Ok(job) => {
187    //         println!("βœ… Job retrieved successfully!");
188    //         println!("  ID: {}", job.id);
189    //         println!("  Model: {}", job.model);
190    //         println!("  Status: {}", job.status);
191    //         println!("  Created At: {}", job.created_at);
192    //         if let Some(finished_at) = job.finished_at {
193    //             println!("  Finished At: {}", finished_at);
194    //         }
195    //     }
196    //     Err(e) => {
197    //         eprintln!("❌ Failed to get fine-tuning job: {}", e);
198    //     }
199    // }
200
201    println!("πŸ’‘ Demo: Would show detailed job information");
202
203    // Example 4: List job events
204    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
205    println!("πŸ“Œ Example 4: List Fine-tuning Job Events");
206    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
207
208    println!("Listing events for job: {}\n", job_id);
209
210    // Uncomment to actually list events:
211    // match client.fine_tuning().list_events(job_id, None, Some(10)).await {
212    //     Ok(response) => {
213    //         println!("βœ… Found {} events", response.data.len());
214    //         for (i, event) in response.data.iter().enumerate() {
215    //             println!("\nπŸ“‹ Event {}:", i + 1);
216    //             println!("  Message: {}", event.message);
217    //             println!("  Created At: {}", event.created_at);
218    //             if let Some(level) = &event.level {
219    //                 println!("  Level: {}", level);
220    //             }
221    //         }
222    //     }
223    //     Err(e) => {
224    //         eprintln!("❌ Failed to list events: {}", e);
225    //     }
226    // }
227
228    println!("πŸ’‘ Demo: Would show training events like:");
229    println!("  - Job started");
230    println!("  - Training step 1/100 complete");
231    println!("  - Validation loss: 0.452");
232    println!("  - Training complete");
233
234    // Example 5: List job checkpoints
235    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
236    println!("πŸ“Œ Example 5: List Fine-tuning Job Checkpoints");
237    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
238
239    println!("Listing checkpoints for job: {}\n", job_id);
240
241    // Uncomment to actually list checkpoints:
242    // match client.fine_tuning().list_checkpoints(job_id, None, Some(5)).await {
243    //     Ok(response) => {
244    //         println!("βœ… Found {} checkpoints", response.data.len());
245    //         for (i, checkpoint) in response.data.iter().enumerate() {
246    //             println!("\nπŸ’Ύ Checkpoint {}:", i + 1);
247    //             println!("  ID: {}", checkpoint.id);
248    //             println!("  Created At: {}", checkpoint.created_at);
249    //             println!("  Step Number: {}", checkpoint.step_number);
250    //         }
251    //     }
252    //     Err(e) => {
253    //         eprintln!("❌ Failed to list checkpoints: {}", e);
254    //     }
255    // }
256
257    println!("πŸ’‘ Demo: Would show model checkpoints from training");
258
259    // Example 6: Cancel fine-tuning job
260    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
261    println!("πŸ“Œ Example 6: Cancel Fine-tuning Job");
262    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
263
264    println!("Cancelling job: {}\n", job_id);
265
266    // Uncomment to actually cancel job:
267    // match client.fine_tuning().cancel_job(job_id).await {
268    //     Ok(job) => {
269    //         println!("βœ… Job cancelled successfully!");
270    //         println!("  Job ID: {}", job.id);
271    //         println!("  Status: {}", job.status);
272    //     }
273    //     Err(e) => {
274    //         eprintln!("❌ Failed to cancel job: {}", e);
275    //     }
276    // }
277
278    println!("πŸ’‘ Demo: Would cancel the running fine-tuning job");
279
280    // Example 7: Create job with validation file
281    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
282    println!("πŸ“Œ Example 7: Create Job with Validation File");
283    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
284
285    let validation_file_id = "file-validation-data";
286
287    println!("Creating fine-tuning job with validation...");
288    println!("  Base Model: gpt-3.5-turbo");
289    println!("  Training File: {}", training_file_id);
290    println!("  Validation File: {}", validation_file_id);
291    println!("  Epochs: 5");
292    println!("  Learning Rate Multiplier: 0.1");
293
294    let builder_with_validation = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
295        .validation_file(validation_file_id)
296        .epochs(5)
297        .learning_rate_multiplier(0.1);
298
299    println!("\nπŸ’‘ Note: Validation files help monitor overfitting during training");
300
301    // Example 8: Create job with Weights & Biases integration
302    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
303    println!("πŸ“Œ Example 8: Create Job with W&B Integration");
304    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
305
306    println!("Creating fine-tuning job with W&B...");
307    println!("  Base Model: gpt-3.5-turbo");
308    println!("  Training File: {}", training_file_id);
309    println!("  W&B Project: my-finetuning-project");
310
311    let builder_with_wandb = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
312        .with_wandb("my-finetuning-project");
313
314    println!("\nπŸ’‘ Note: W&B integration provides detailed training metrics visualization");
315
316    // Summary
317    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
318    println!("πŸ“Š Summary");
319    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
320
321    println!("βœ… Fine-tuning API examples completed!");
322    println!("\nπŸ“š Key Takeaways:");
323    println!("  β€’ Fine-tuning allows customizing models for specific tasks");
324    println!("  β€’ Jobs can be created with various hyperparameters");
325    println!("  β€’ Progress can be monitored through events and checkpoints");
326    println!("  β€’ Validation files help prevent overfitting");
327    println!("  β€’ Integrations like W&B provide detailed metrics");
328    println!("  β€’ Jobs can be cancelled if needed");
329
330    println!("\nπŸ’‘ Next Steps:");
331    println!("  1. Prepare your training data in JSONL format");
332    println!("  2. Upload training data using the Files API");
333    println!("  3. Create a fine-tuning job with appropriate parameters");
334    println!("  4. Monitor progress through events");
335    println!("  5. Use the fine-tuned model in your applications");
336
337    println!("\nπŸŽ‰ Example completed successfully!");
338
339    Ok(())
340}
Source

pub fn validation_file(self, file_id: impl Into<String>) -> Self

Set the validation file for the fine-tuning job.

Examples found in repository?
examples/fine_tuning.rs (line 295)
89async fn main() -> Result<(), Box<dyn std::error::Error>> {
90    println!("πŸš€ OpenAI Ergonomic - Comprehensive Fine-tuning Example\n");
91
92    // Initialize client from environment variables
93    println!("πŸ“ Initializing OpenAI client...");
94    let client = match Client::from_env() {
95        Ok(c) => {
96            println!("βœ… Client initialized successfully\n");
97            c.build()
98        }
99        Err(e) => {
100            eprintln!("❌ Failed to initialize client: {}", e);
101            eprintln!("πŸ’‘ Make sure OPENAI_API_KEY is set");
102            return Ok(());
103        }
104    };
105
106    // Example 1: Create a fine-tuning job
107    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
108    println!("πŸ“Œ Example 1: Create Fine-tuning Job");
109    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
110
111    // Note: You need to upload a training file first
112    // For demonstration purposes, we'll use a placeholder file ID
113    let training_file_id = "file-training-data";
114
115    println!("Creating fine-tuning job...");
116    println!("  Base Model: gpt-3.5-turbo");
117    println!("  Training File: {}", training_file_id);
118    println!("  Suffix: my-custom-model");
119
120    let builder = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
121        .suffix("my-custom-model")
122        .epochs(3);
123
124    println!("\nπŸ’‘ Note: This would create a real fine-tuning job with your API key.");
125    println!("   Commented out to avoid accidental charges.\n");
126
127    // Uncomment to actually create the job:
128    // match client.fine_tuning().create_job(builder).await {
129    //     Ok(job) => {
130    //         println!("βœ… Fine-tuning job created successfully!");
131    //         println!("  Job ID: {}", job.id);
132    //         println!("  Status: {}", job.status);
133    //         println!("  Model: {}", job.model);
134    //     }
135    //     Err(e) => {
136    //         eprintln!("❌ Failed to create fine-tuning job: {}", e);
137    //     }
138    // }
139
140    // Simulate job creation for demonstration
141    let demo_job = JobInfo::new(
142        "ftjob-demo123",
143        "gpt-3.5-turbo",
144        "validating",
145        training_file_id,
146    );
147    println!("πŸ“Š Demo Job Created:");
148    demo_job.display();
149
150    // Example 2: List fine-tuning jobs
151    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
152    println!("πŸ“Œ Example 2: List Fine-tuning Jobs");
153    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
154
155    println!("Listing fine-tuning jobs (limit: 5)...\n");
156
157    // Uncomment to actually list jobs:
158    // match client.fine_tuning().list_jobs(None, Some(5)).await {
159    //     Ok(response) => {
160    //         println!("βœ… Found {} fine-tuning jobs", response.data.len());
161    //         for (i, job) in response.data.iter().enumerate() {
162    //             println!("\nπŸ“ Job {}:", i + 1);
163    //             println!("  ID: {}", job.id);
164    //             println!("  Model: {}", job.model);
165    //             println!("  Status: {}", job.status);
166    //             println!("  Created At: {}", job.created_at);
167    //         }
168    //     }
169    //     Err(e) => {
170    //         eprintln!("❌ Failed to list fine-tuning jobs: {}", e);
171    //     }
172    // }
173
174    println!("πŸ’‘ Demo: Would list your fine-tuning jobs here");
175
176    // Example 3: Get specific fine-tuning job
177    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
178    println!("πŸ“Œ Example 3: Get Fine-tuning Job Details");
179    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
180
181    let job_id = "ftjob-demo123";
182    println!("Retrieving job: {}\n", job_id);
183
184    // Uncomment to actually get job:
185    // match client.fine_tuning().get_job(job_id).await {
186    //     Ok(job) => {
187    //         println!("βœ… Job retrieved successfully!");
188    //         println!("  ID: {}", job.id);
189    //         println!("  Model: {}", job.model);
190    //         println!("  Status: {}", job.status);
191    //         println!("  Created At: {}", job.created_at);
192    //         if let Some(finished_at) = job.finished_at {
193    //             println!("  Finished At: {}", finished_at);
194    //         }
195    //     }
196    //     Err(e) => {
197    //         eprintln!("❌ Failed to get fine-tuning job: {}", e);
198    //     }
199    // }
200
201    println!("πŸ’‘ Demo: Would show detailed job information");
202
203    // Example 4: List job events
204    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
205    println!("πŸ“Œ Example 4: List Fine-tuning Job Events");
206    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
207
208    println!("Listing events for job: {}\n", job_id);
209
210    // Uncomment to actually list events:
211    // match client.fine_tuning().list_events(job_id, None, Some(10)).await {
212    //     Ok(response) => {
213    //         println!("βœ… Found {} events", response.data.len());
214    //         for (i, event) in response.data.iter().enumerate() {
215    //             println!("\nπŸ“‹ Event {}:", i + 1);
216    //             println!("  Message: {}", event.message);
217    //             println!("  Created At: {}", event.created_at);
218    //             if let Some(level) = &event.level {
219    //                 println!("  Level: {}", level);
220    //             }
221    //         }
222    //     }
223    //     Err(e) => {
224    //         eprintln!("❌ Failed to list events: {}", e);
225    //     }
226    // }
227
228    println!("πŸ’‘ Demo: Would show training events like:");
229    println!("  - Job started");
230    println!("  - Training step 1/100 complete");
231    println!("  - Validation loss: 0.452");
232    println!("  - Training complete");
233
234    // Example 5: List job checkpoints
235    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
236    println!("πŸ“Œ Example 5: List Fine-tuning Job Checkpoints");
237    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
238
239    println!("Listing checkpoints for job: {}\n", job_id);
240
241    // Uncomment to actually list checkpoints:
242    // match client.fine_tuning().list_checkpoints(job_id, None, Some(5)).await {
243    //     Ok(response) => {
244    //         println!("βœ… Found {} checkpoints", response.data.len());
245    //         for (i, checkpoint) in response.data.iter().enumerate() {
246    //             println!("\nπŸ’Ύ Checkpoint {}:", i + 1);
247    //             println!("  ID: {}", checkpoint.id);
248    //             println!("  Created At: {}", checkpoint.created_at);
249    //             println!("  Step Number: {}", checkpoint.step_number);
250    //         }
251    //     }
252    //     Err(e) => {
253    //         eprintln!("❌ Failed to list checkpoints: {}", e);
254    //     }
255    // }
256
257    println!("πŸ’‘ Demo: Would show model checkpoints from training");
258
259    // Example 6: Cancel fine-tuning job
260    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
261    println!("πŸ“Œ Example 6: Cancel Fine-tuning Job");
262    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
263
264    println!("Cancelling job: {}\n", job_id);
265
266    // Uncomment to actually cancel job:
267    // match client.fine_tuning().cancel_job(job_id).await {
268    //     Ok(job) => {
269    //         println!("βœ… Job cancelled successfully!");
270    //         println!("  Job ID: {}", job.id);
271    //         println!("  Status: {}", job.status);
272    //     }
273    //     Err(e) => {
274    //         eprintln!("❌ Failed to cancel job: {}", e);
275    //     }
276    // }
277
278    println!("πŸ’‘ Demo: Would cancel the running fine-tuning job");
279
280    // Example 7: Create job with validation file
281    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
282    println!("πŸ“Œ Example 7: Create Job with Validation File");
283    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
284
285    let validation_file_id = "file-validation-data";
286
287    println!("Creating fine-tuning job with validation...");
288    println!("  Base Model: gpt-3.5-turbo");
289    println!("  Training File: {}", training_file_id);
290    println!("  Validation File: {}", validation_file_id);
291    println!("  Epochs: 5");
292    println!("  Learning Rate Multiplier: 0.1");
293
294    let builder_with_validation = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
295        .validation_file(validation_file_id)
296        .epochs(5)
297        .learning_rate_multiplier(0.1);
298
299    println!("\nπŸ’‘ Note: Validation files help monitor overfitting during training");
300
301    // Example 8: Create job with Weights & Biases integration
302    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
303    println!("πŸ“Œ Example 8: Create Job with W&B Integration");
304    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
305
306    println!("Creating fine-tuning job with W&B...");
307    println!("  Base Model: gpt-3.5-turbo");
308    println!("  Training File: {}", training_file_id);
309    println!("  W&B Project: my-finetuning-project");
310
311    let builder_with_wandb = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
312        .with_wandb("my-finetuning-project");
313
314    println!("\nπŸ’‘ Note: W&B integration provides detailed training metrics visualization");
315
316    // Summary
317    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
318    println!("πŸ“Š Summary");
319    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
320
321    println!("βœ… Fine-tuning API examples completed!");
322    println!("\nπŸ“š Key Takeaways:");
323    println!("  β€’ Fine-tuning allows customizing models for specific tasks");
324    println!("  β€’ Jobs can be created with various hyperparameters");
325    println!("  β€’ Progress can be monitored through events and checkpoints");
326    println!("  β€’ Validation files help prevent overfitting");
327    println!("  β€’ Integrations like W&B provide detailed metrics");
328    println!("  β€’ Jobs can be cancelled if needed");
329
330    println!("\nπŸ’‘ Next Steps:");
331    println!("  1. Prepare your training data in JSONL format");
332    println!("  2. Upload training data using the Files API");
333    println!("  3. Create a fine-tuning job with appropriate parameters");
334    println!("  4. Monitor progress through events");
335    println!("  5. Use the fine-tuned model in your applications");
336
337    println!("\nπŸŽ‰ Example completed successfully!");
338
339    Ok(())
340}
Source

pub fn epochs(self, epochs: i32) -> Self

Set the number of epochs to train for.

Examples found in repository?
examples/fine_tuning.rs (line 122)
89async fn main() -> Result<(), Box<dyn std::error::Error>> {
90    println!("πŸš€ OpenAI Ergonomic - Comprehensive Fine-tuning Example\n");
91
92    // Initialize client from environment variables
93    println!("πŸ“ Initializing OpenAI client...");
94    let client = match Client::from_env() {
95        Ok(c) => {
96            println!("βœ… Client initialized successfully\n");
97            c.build()
98        }
99        Err(e) => {
100            eprintln!("❌ Failed to initialize client: {}", e);
101            eprintln!("πŸ’‘ Make sure OPENAI_API_KEY is set");
102            return Ok(());
103        }
104    };
105
106    // Example 1: Create a fine-tuning job
107    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
108    println!("πŸ“Œ Example 1: Create Fine-tuning Job");
109    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
110
111    // Note: You need to upload a training file first
112    // For demonstration purposes, we'll use a placeholder file ID
113    let training_file_id = "file-training-data";
114
115    println!("Creating fine-tuning job...");
116    println!("  Base Model: gpt-3.5-turbo");
117    println!("  Training File: {}", training_file_id);
118    println!("  Suffix: my-custom-model");
119
120    let builder = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
121        .suffix("my-custom-model")
122        .epochs(3);
123
124    println!("\nπŸ’‘ Note: This would create a real fine-tuning job with your API key.");
125    println!("   Commented out to avoid accidental charges.\n");
126
127    // Uncomment to actually create the job:
128    // match client.fine_tuning().create_job(builder).await {
129    //     Ok(job) => {
130    //         println!("βœ… Fine-tuning job created successfully!");
131    //         println!("  Job ID: {}", job.id);
132    //         println!("  Status: {}", job.status);
133    //         println!("  Model: {}", job.model);
134    //     }
135    //     Err(e) => {
136    //         eprintln!("❌ Failed to create fine-tuning job: {}", e);
137    //     }
138    // }
139
140    // Simulate job creation for demonstration
141    let demo_job = JobInfo::new(
142        "ftjob-demo123",
143        "gpt-3.5-turbo",
144        "validating",
145        training_file_id,
146    );
147    println!("πŸ“Š Demo Job Created:");
148    demo_job.display();
149
150    // Example 2: List fine-tuning jobs
151    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
152    println!("πŸ“Œ Example 2: List Fine-tuning Jobs");
153    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
154
155    println!("Listing fine-tuning jobs (limit: 5)...\n");
156
157    // Uncomment to actually list jobs:
158    // match client.fine_tuning().list_jobs(None, Some(5)).await {
159    //     Ok(response) => {
160    //         println!("βœ… Found {} fine-tuning jobs", response.data.len());
161    //         for (i, job) in response.data.iter().enumerate() {
162    //             println!("\nπŸ“ Job {}:", i + 1);
163    //             println!("  ID: {}", job.id);
164    //             println!("  Model: {}", job.model);
165    //             println!("  Status: {}", job.status);
166    //             println!("  Created At: {}", job.created_at);
167    //         }
168    //     }
169    //     Err(e) => {
170    //         eprintln!("❌ Failed to list fine-tuning jobs: {}", e);
171    //     }
172    // }
173
174    println!("πŸ’‘ Demo: Would list your fine-tuning jobs here");
175
176    // Example 3: Get specific fine-tuning job
177    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
178    println!("πŸ“Œ Example 3: Get Fine-tuning Job Details");
179    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
180
181    let job_id = "ftjob-demo123";
182    println!("Retrieving job: {}\n", job_id);
183
184    // Uncomment to actually get job:
185    // match client.fine_tuning().get_job(job_id).await {
186    //     Ok(job) => {
187    //         println!("βœ… Job retrieved successfully!");
188    //         println!("  ID: {}", job.id);
189    //         println!("  Model: {}", job.model);
190    //         println!("  Status: {}", job.status);
191    //         println!("  Created At: {}", job.created_at);
192    //         if let Some(finished_at) = job.finished_at {
193    //             println!("  Finished At: {}", finished_at);
194    //         }
195    //     }
196    //     Err(e) => {
197    //         eprintln!("❌ Failed to get fine-tuning job: {}", e);
198    //     }
199    // }
200
201    println!("πŸ’‘ Demo: Would show detailed job information");
202
203    // Example 4: List job events
204    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
205    println!("πŸ“Œ Example 4: List Fine-tuning Job Events");
206    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
207
208    println!("Listing events for job: {}\n", job_id);
209
210    // Uncomment to actually list events:
211    // match client.fine_tuning().list_events(job_id, None, Some(10)).await {
212    //     Ok(response) => {
213    //         println!("βœ… Found {} events", response.data.len());
214    //         for (i, event) in response.data.iter().enumerate() {
215    //             println!("\nπŸ“‹ Event {}:", i + 1);
216    //             println!("  Message: {}", event.message);
217    //             println!("  Created At: {}", event.created_at);
218    //             if let Some(level) = &event.level {
219    //                 println!("  Level: {}", level);
220    //             }
221    //         }
222    //     }
223    //     Err(e) => {
224    //         eprintln!("❌ Failed to list events: {}", e);
225    //     }
226    // }
227
228    println!("πŸ’‘ Demo: Would show training events like:");
229    println!("  - Job started");
230    println!("  - Training step 1/100 complete");
231    println!("  - Validation loss: 0.452");
232    println!("  - Training complete");
233
234    // Example 5: List job checkpoints
235    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
236    println!("πŸ“Œ Example 5: List Fine-tuning Job Checkpoints");
237    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
238
239    println!("Listing checkpoints for job: {}\n", job_id);
240
241    // Uncomment to actually list checkpoints:
242    // match client.fine_tuning().list_checkpoints(job_id, None, Some(5)).await {
243    //     Ok(response) => {
244    //         println!("βœ… Found {} checkpoints", response.data.len());
245    //         for (i, checkpoint) in response.data.iter().enumerate() {
246    //             println!("\nπŸ’Ύ Checkpoint {}:", i + 1);
247    //             println!("  ID: {}", checkpoint.id);
248    //             println!("  Created At: {}", checkpoint.created_at);
249    //             println!("  Step Number: {}", checkpoint.step_number);
250    //         }
251    //     }
252    //     Err(e) => {
253    //         eprintln!("❌ Failed to list checkpoints: {}", e);
254    //     }
255    // }
256
257    println!("πŸ’‘ Demo: Would show model checkpoints from training");
258
259    // Example 6: Cancel fine-tuning job
260    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
261    println!("πŸ“Œ Example 6: Cancel Fine-tuning Job");
262    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
263
264    println!("Cancelling job: {}\n", job_id);
265
266    // Uncomment to actually cancel job:
267    // match client.fine_tuning().cancel_job(job_id).await {
268    //     Ok(job) => {
269    //         println!("βœ… Job cancelled successfully!");
270    //         println!("  Job ID: {}", job.id);
271    //         println!("  Status: {}", job.status);
272    //     }
273    //     Err(e) => {
274    //         eprintln!("❌ Failed to cancel job: {}", e);
275    //     }
276    // }
277
278    println!("πŸ’‘ Demo: Would cancel the running fine-tuning job");
279
280    // Example 7: Create job with validation file
281    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
282    println!("πŸ“Œ Example 7: Create Job with Validation File");
283    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
284
285    let validation_file_id = "file-validation-data";
286
287    println!("Creating fine-tuning job with validation...");
288    println!("  Base Model: gpt-3.5-turbo");
289    println!("  Training File: {}", training_file_id);
290    println!("  Validation File: {}", validation_file_id);
291    println!("  Epochs: 5");
292    println!("  Learning Rate Multiplier: 0.1");
293
294    let builder_with_validation = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
295        .validation_file(validation_file_id)
296        .epochs(5)
297        .learning_rate_multiplier(0.1);
298
299    println!("\nπŸ’‘ Note: Validation files help monitor overfitting during training");
300
301    // Example 8: Create job with Weights & Biases integration
302    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
303    println!("πŸ“Œ Example 8: Create Job with W&B Integration");
304    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
305
306    println!("Creating fine-tuning job with W&B...");
307    println!("  Base Model: gpt-3.5-turbo");
308    println!("  Training File: {}", training_file_id);
309    println!("  W&B Project: my-finetuning-project");
310
311    let builder_with_wandb = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
312        .with_wandb("my-finetuning-project");
313
314    println!("\nπŸ’‘ Note: W&B integration provides detailed training metrics visualization");
315
316    // Summary
317    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
318    println!("πŸ“Š Summary");
319    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
320
321    println!("βœ… Fine-tuning API examples completed!");
322    println!("\nπŸ“š Key Takeaways:");
323    println!("  β€’ Fine-tuning allows customizing models for specific tasks");
324    println!("  β€’ Jobs can be created with various hyperparameters");
325    println!("  β€’ Progress can be monitored through events and checkpoints");
326    println!("  β€’ Validation files help prevent overfitting");
327    println!("  β€’ Integrations like W&B provide detailed metrics");
328    println!("  β€’ Jobs can be cancelled if needed");
329
330    println!("\nπŸ’‘ Next Steps:");
331    println!("  1. Prepare your training data in JSONL format");
332    println!("  2. Upload training data using the Files API");
333    println!("  3. Create a fine-tuning job with appropriate parameters");
334    println!("  4. Monitor progress through events");
335    println!("  5. Use the fine-tuned model in your applications");
336
337    println!("\nπŸŽ‰ Example completed successfully!");
338
339    Ok(())
340}
Source

pub fn batch_size(self, batch_size: i32) -> Self

Set the batch size for training.

Source

pub fn learning_rate_multiplier(self, multiplier: f64) -> Self

Set the learning rate multiplier.

Examples found in repository?
examples/fine_tuning.rs (line 297)
89async fn main() -> Result<(), Box<dyn std::error::Error>> {
90    println!("πŸš€ OpenAI Ergonomic - Comprehensive Fine-tuning Example\n");
91
92    // Initialize client from environment variables
93    println!("πŸ“ Initializing OpenAI client...");
94    let client = match Client::from_env() {
95        Ok(c) => {
96            println!("βœ… Client initialized successfully\n");
97            c.build()
98        }
99        Err(e) => {
100            eprintln!("❌ Failed to initialize client: {}", e);
101            eprintln!("πŸ’‘ Make sure OPENAI_API_KEY is set");
102            return Ok(());
103        }
104    };
105
106    // Example 1: Create a fine-tuning job
107    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
108    println!("πŸ“Œ Example 1: Create Fine-tuning Job");
109    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
110
111    // Note: You need to upload a training file first
112    // For demonstration purposes, we'll use a placeholder file ID
113    let training_file_id = "file-training-data";
114
115    println!("Creating fine-tuning job...");
116    println!("  Base Model: gpt-3.5-turbo");
117    println!("  Training File: {}", training_file_id);
118    println!("  Suffix: my-custom-model");
119
120    let builder = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
121        .suffix("my-custom-model")
122        .epochs(3);
123
124    println!("\nπŸ’‘ Note: This would create a real fine-tuning job with your API key.");
125    println!("   Commented out to avoid accidental charges.\n");
126
127    // Uncomment to actually create the job:
128    // match client.fine_tuning().create_job(builder).await {
129    //     Ok(job) => {
130    //         println!("βœ… Fine-tuning job created successfully!");
131    //         println!("  Job ID: {}", job.id);
132    //         println!("  Status: {}", job.status);
133    //         println!("  Model: {}", job.model);
134    //     }
135    //     Err(e) => {
136    //         eprintln!("❌ Failed to create fine-tuning job: {}", e);
137    //     }
138    // }
139
140    // Simulate job creation for demonstration
141    let demo_job = JobInfo::new(
142        "ftjob-demo123",
143        "gpt-3.5-turbo",
144        "validating",
145        training_file_id,
146    );
147    println!("πŸ“Š Demo Job Created:");
148    demo_job.display();
149
150    // Example 2: List fine-tuning jobs
151    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
152    println!("πŸ“Œ Example 2: List Fine-tuning Jobs");
153    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
154
155    println!("Listing fine-tuning jobs (limit: 5)...\n");
156
157    // Uncomment to actually list jobs:
158    // match client.fine_tuning().list_jobs(None, Some(5)).await {
159    //     Ok(response) => {
160    //         println!("βœ… Found {} fine-tuning jobs", response.data.len());
161    //         for (i, job) in response.data.iter().enumerate() {
162    //             println!("\nπŸ“ Job {}:", i + 1);
163    //             println!("  ID: {}", job.id);
164    //             println!("  Model: {}", job.model);
165    //             println!("  Status: {}", job.status);
166    //             println!("  Created At: {}", job.created_at);
167    //         }
168    //     }
169    //     Err(e) => {
170    //         eprintln!("❌ Failed to list fine-tuning jobs: {}", e);
171    //     }
172    // }
173
174    println!("πŸ’‘ Demo: Would list your fine-tuning jobs here");
175
176    // Example 3: Get specific fine-tuning job
177    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
178    println!("πŸ“Œ Example 3: Get Fine-tuning Job Details");
179    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
180
181    let job_id = "ftjob-demo123";
182    println!("Retrieving job: {}\n", job_id);
183
184    // Uncomment to actually get job:
185    // match client.fine_tuning().get_job(job_id).await {
186    //     Ok(job) => {
187    //         println!("βœ… Job retrieved successfully!");
188    //         println!("  ID: {}", job.id);
189    //         println!("  Model: {}", job.model);
190    //         println!("  Status: {}", job.status);
191    //         println!("  Created At: {}", job.created_at);
192    //         if let Some(finished_at) = job.finished_at {
193    //             println!("  Finished At: {}", finished_at);
194    //         }
195    //     }
196    //     Err(e) => {
197    //         eprintln!("❌ Failed to get fine-tuning job: {}", e);
198    //     }
199    // }
200
201    println!("πŸ’‘ Demo: Would show detailed job information");
202
203    // Example 4: List job events
204    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
205    println!("πŸ“Œ Example 4: List Fine-tuning Job Events");
206    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
207
208    println!("Listing events for job: {}\n", job_id);
209
210    // Uncomment to actually list events:
211    // match client.fine_tuning().list_events(job_id, None, Some(10)).await {
212    //     Ok(response) => {
213    //         println!("βœ… Found {} events", response.data.len());
214    //         for (i, event) in response.data.iter().enumerate() {
215    //             println!("\nπŸ“‹ Event {}:", i + 1);
216    //             println!("  Message: {}", event.message);
217    //             println!("  Created At: {}", event.created_at);
218    //             if let Some(level) = &event.level {
219    //                 println!("  Level: {}", level);
220    //             }
221    //         }
222    //     }
223    //     Err(e) => {
224    //         eprintln!("❌ Failed to list events: {}", e);
225    //     }
226    // }
227
228    println!("πŸ’‘ Demo: Would show training events like:");
229    println!("  - Job started");
230    println!("  - Training step 1/100 complete");
231    println!("  - Validation loss: 0.452");
232    println!("  - Training complete");
233
234    // Example 5: List job checkpoints
235    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
236    println!("πŸ“Œ Example 5: List Fine-tuning Job Checkpoints");
237    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
238
239    println!("Listing checkpoints for job: {}\n", job_id);
240
241    // Uncomment to actually list checkpoints:
242    // match client.fine_tuning().list_checkpoints(job_id, None, Some(5)).await {
243    //     Ok(response) => {
244    //         println!("βœ… Found {} checkpoints", response.data.len());
245    //         for (i, checkpoint) in response.data.iter().enumerate() {
246    //             println!("\nπŸ’Ύ Checkpoint {}:", i + 1);
247    //             println!("  ID: {}", checkpoint.id);
248    //             println!("  Created At: {}", checkpoint.created_at);
249    //             println!("  Step Number: {}", checkpoint.step_number);
250    //         }
251    //     }
252    //     Err(e) => {
253    //         eprintln!("❌ Failed to list checkpoints: {}", e);
254    //     }
255    // }
256
257    println!("πŸ’‘ Demo: Would show model checkpoints from training");
258
259    // Example 6: Cancel fine-tuning job
260    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
261    println!("πŸ“Œ Example 6: Cancel Fine-tuning Job");
262    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
263
264    println!("Cancelling job: {}\n", job_id);
265
266    // Uncomment to actually cancel job:
267    // match client.fine_tuning().cancel_job(job_id).await {
268    //     Ok(job) => {
269    //         println!("βœ… Job cancelled successfully!");
270    //         println!("  Job ID: {}", job.id);
271    //         println!("  Status: {}", job.status);
272    //     }
273    //     Err(e) => {
274    //         eprintln!("❌ Failed to cancel job: {}", e);
275    //     }
276    // }
277
278    println!("πŸ’‘ Demo: Would cancel the running fine-tuning job");
279
280    // Example 7: Create job with validation file
281    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
282    println!("πŸ“Œ Example 7: Create Job with Validation File");
283    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
284
285    let validation_file_id = "file-validation-data";
286
287    println!("Creating fine-tuning job with validation...");
288    println!("  Base Model: gpt-3.5-turbo");
289    println!("  Training File: {}", training_file_id);
290    println!("  Validation File: {}", validation_file_id);
291    println!("  Epochs: 5");
292    println!("  Learning Rate Multiplier: 0.1");
293
294    let builder_with_validation = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
295        .validation_file(validation_file_id)
296        .epochs(5)
297        .learning_rate_multiplier(0.1);
298
299    println!("\nπŸ’‘ Note: Validation files help monitor overfitting during training");
300
301    // Example 8: Create job with Weights & Biases integration
302    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
303    println!("πŸ“Œ Example 8: Create Job with W&B Integration");
304    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
305
306    println!("Creating fine-tuning job with W&B...");
307    println!("  Base Model: gpt-3.5-turbo");
308    println!("  Training File: {}", training_file_id);
309    println!("  W&B Project: my-finetuning-project");
310
311    let builder_with_wandb = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
312        .with_wandb("my-finetuning-project");
313
314    println!("\nπŸ’‘ Note: W&B integration provides detailed training metrics visualization");
315
316    // Summary
317    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
318    println!("πŸ“Š Summary");
319    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
320
321    println!("βœ… Fine-tuning API examples completed!");
322    println!("\nπŸ“š Key Takeaways:");
323    println!("  β€’ Fine-tuning allows customizing models for specific tasks");
324    println!("  β€’ Jobs can be created with various hyperparameters");
325    println!("  β€’ Progress can be monitored through events and checkpoints");
326    println!("  β€’ Validation files help prevent overfitting");
327    println!("  β€’ Integrations like W&B provide detailed metrics");
328    println!("  β€’ Jobs can be cancelled if needed");
329
330    println!("\nπŸ’‘ Next Steps:");
331    println!("  1. Prepare your training data in JSONL format");
332    println!("  2. Upload training data using the Files API");
333    println!("  3. Create a fine-tuning job with appropriate parameters");
334    println!("  4. Monitor progress through events");
335    println!("  5. Use the fine-tuned model in your applications");
336
337    println!("\nπŸŽ‰ Example completed successfully!");
338
339    Ok(())
340}
Source

pub fn suffix(self, suffix: impl Into<String>) -> Self

Set a suffix for the fine-tuned model name.

Examples found in repository?
examples/fine_tuning.rs (line 121)
89async fn main() -> Result<(), Box<dyn std::error::Error>> {
90    println!("πŸš€ OpenAI Ergonomic - Comprehensive Fine-tuning Example\n");
91
92    // Initialize client from environment variables
93    println!("πŸ“ Initializing OpenAI client...");
94    let client = match Client::from_env() {
95        Ok(c) => {
96            println!("βœ… Client initialized successfully\n");
97            c.build()
98        }
99        Err(e) => {
100            eprintln!("❌ Failed to initialize client: {}", e);
101            eprintln!("πŸ’‘ Make sure OPENAI_API_KEY is set");
102            return Ok(());
103        }
104    };
105
106    // Example 1: Create a fine-tuning job
107    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
108    println!("πŸ“Œ Example 1: Create Fine-tuning Job");
109    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
110
111    // Note: You need to upload a training file first
112    // For demonstration purposes, we'll use a placeholder file ID
113    let training_file_id = "file-training-data";
114
115    println!("Creating fine-tuning job...");
116    println!("  Base Model: gpt-3.5-turbo");
117    println!("  Training File: {}", training_file_id);
118    println!("  Suffix: my-custom-model");
119
120    let builder = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
121        .suffix("my-custom-model")
122        .epochs(3);
123
124    println!("\nπŸ’‘ Note: This would create a real fine-tuning job with your API key.");
125    println!("   Commented out to avoid accidental charges.\n");
126
127    // Uncomment to actually create the job:
128    // match client.fine_tuning().create_job(builder).await {
129    //     Ok(job) => {
130    //         println!("βœ… Fine-tuning job created successfully!");
131    //         println!("  Job ID: {}", job.id);
132    //         println!("  Status: {}", job.status);
133    //         println!("  Model: {}", job.model);
134    //     }
135    //     Err(e) => {
136    //         eprintln!("❌ Failed to create fine-tuning job: {}", e);
137    //     }
138    // }
139
140    // Simulate job creation for demonstration
141    let demo_job = JobInfo::new(
142        "ftjob-demo123",
143        "gpt-3.5-turbo",
144        "validating",
145        training_file_id,
146    );
147    println!("πŸ“Š Demo Job Created:");
148    demo_job.display();
149
150    // Example 2: List fine-tuning jobs
151    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
152    println!("πŸ“Œ Example 2: List Fine-tuning Jobs");
153    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
154
155    println!("Listing fine-tuning jobs (limit: 5)...\n");
156
157    // Uncomment to actually list jobs:
158    // match client.fine_tuning().list_jobs(None, Some(5)).await {
159    //     Ok(response) => {
160    //         println!("βœ… Found {} fine-tuning jobs", response.data.len());
161    //         for (i, job) in response.data.iter().enumerate() {
162    //             println!("\nπŸ“ Job {}:", i + 1);
163    //             println!("  ID: {}", job.id);
164    //             println!("  Model: {}", job.model);
165    //             println!("  Status: {}", job.status);
166    //             println!("  Created At: {}", job.created_at);
167    //         }
168    //     }
169    //     Err(e) => {
170    //         eprintln!("❌ Failed to list fine-tuning jobs: {}", e);
171    //     }
172    // }
173
174    println!("πŸ’‘ Demo: Would list your fine-tuning jobs here");
175
176    // Example 3: Get specific fine-tuning job
177    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
178    println!("πŸ“Œ Example 3: Get Fine-tuning Job Details");
179    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
180
181    let job_id = "ftjob-demo123";
182    println!("Retrieving job: {}\n", job_id);
183
184    // Uncomment to actually get job:
185    // match client.fine_tuning().get_job(job_id).await {
186    //     Ok(job) => {
187    //         println!("βœ… Job retrieved successfully!");
188    //         println!("  ID: {}", job.id);
189    //         println!("  Model: {}", job.model);
190    //         println!("  Status: {}", job.status);
191    //         println!("  Created At: {}", job.created_at);
192    //         if let Some(finished_at) = job.finished_at {
193    //             println!("  Finished At: {}", finished_at);
194    //         }
195    //     }
196    //     Err(e) => {
197    //         eprintln!("❌ Failed to get fine-tuning job: {}", e);
198    //     }
199    // }
200
201    println!("πŸ’‘ Demo: Would show detailed job information");
202
203    // Example 4: List job events
204    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
205    println!("πŸ“Œ Example 4: List Fine-tuning Job Events");
206    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
207
208    println!("Listing events for job: {}\n", job_id);
209
210    // Uncomment to actually list events:
211    // match client.fine_tuning().list_events(job_id, None, Some(10)).await {
212    //     Ok(response) => {
213    //         println!("βœ… Found {} events", response.data.len());
214    //         for (i, event) in response.data.iter().enumerate() {
215    //             println!("\nπŸ“‹ Event {}:", i + 1);
216    //             println!("  Message: {}", event.message);
217    //             println!("  Created At: {}", event.created_at);
218    //             if let Some(level) = &event.level {
219    //                 println!("  Level: {}", level);
220    //             }
221    //         }
222    //     }
223    //     Err(e) => {
224    //         eprintln!("❌ Failed to list events: {}", e);
225    //     }
226    // }
227
228    println!("πŸ’‘ Demo: Would show training events like:");
229    println!("  - Job started");
230    println!("  - Training step 1/100 complete");
231    println!("  - Validation loss: 0.452");
232    println!("  - Training complete");
233
234    // Example 5: List job checkpoints
235    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
236    println!("πŸ“Œ Example 5: List Fine-tuning Job Checkpoints");
237    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
238
239    println!("Listing checkpoints for job: {}\n", job_id);
240
241    // Uncomment to actually list checkpoints:
242    // match client.fine_tuning().list_checkpoints(job_id, None, Some(5)).await {
243    //     Ok(response) => {
244    //         println!("βœ… Found {} checkpoints", response.data.len());
245    //         for (i, checkpoint) in response.data.iter().enumerate() {
246    //             println!("\nπŸ’Ύ Checkpoint {}:", i + 1);
247    //             println!("  ID: {}", checkpoint.id);
248    //             println!("  Created At: {}", checkpoint.created_at);
249    //             println!("  Step Number: {}", checkpoint.step_number);
250    //         }
251    //     }
252    //     Err(e) => {
253    //         eprintln!("❌ Failed to list checkpoints: {}", e);
254    //     }
255    // }
256
257    println!("πŸ’‘ Demo: Would show model checkpoints from training");
258
259    // Example 6: Cancel fine-tuning job
260    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
261    println!("πŸ“Œ Example 6: Cancel Fine-tuning Job");
262    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
263
264    println!("Cancelling job: {}\n", job_id);
265
266    // Uncomment to actually cancel job:
267    // match client.fine_tuning().cancel_job(job_id).await {
268    //     Ok(job) => {
269    //         println!("βœ… Job cancelled successfully!");
270    //         println!("  Job ID: {}", job.id);
271    //         println!("  Status: {}", job.status);
272    //     }
273    //     Err(e) => {
274    //         eprintln!("❌ Failed to cancel job: {}", e);
275    //     }
276    // }
277
278    println!("πŸ’‘ Demo: Would cancel the running fine-tuning job");
279
280    // Example 7: Create job with validation file
281    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
282    println!("πŸ“Œ Example 7: Create Job with Validation File");
283    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
284
285    let validation_file_id = "file-validation-data";
286
287    println!("Creating fine-tuning job with validation...");
288    println!("  Base Model: gpt-3.5-turbo");
289    println!("  Training File: {}", training_file_id);
290    println!("  Validation File: {}", validation_file_id);
291    println!("  Epochs: 5");
292    println!("  Learning Rate Multiplier: 0.1");
293
294    let builder_with_validation = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
295        .validation_file(validation_file_id)
296        .epochs(5)
297        .learning_rate_multiplier(0.1);
298
299    println!("\nπŸ’‘ Note: Validation files help monitor overfitting during training");
300
301    // Example 8: Create job with Weights & Biases integration
302    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
303    println!("πŸ“Œ Example 8: Create Job with W&B Integration");
304    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
305
306    println!("Creating fine-tuning job with W&B...");
307    println!("  Base Model: gpt-3.5-turbo");
308    println!("  Training File: {}", training_file_id);
309    println!("  W&B Project: my-finetuning-project");
310
311    let builder_with_wandb = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
312        .with_wandb("my-finetuning-project");
313
314    println!("\nπŸ’‘ Note: W&B integration provides detailed training metrics visualization");
315
316    // Summary
317    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
318    println!("πŸ“Š Summary");
319    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
320
321    println!("βœ… Fine-tuning API examples completed!");
322    println!("\nπŸ“š Key Takeaways:");
323    println!("  β€’ Fine-tuning allows customizing models for specific tasks");
324    println!("  β€’ Jobs can be created with various hyperparameters");
325    println!("  β€’ Progress can be monitored through events and checkpoints");
326    println!("  β€’ Validation files help prevent overfitting");
327    println!("  β€’ Integrations like W&B provide detailed metrics");
328    println!("  β€’ Jobs can be cancelled if needed");
329
330    println!("\nπŸ’‘ Next Steps:");
331    println!("  1. Prepare your training data in JSONL format");
332    println!("  2. Upload training data using the Files API");
333    println!("  3. Create a fine-tuning job with appropriate parameters");
334    println!("  4. Monitor progress through events");
335    println!("  5. Use the fine-tuned model in your applications");
336
337    println!("\nπŸŽ‰ Example completed successfully!");
338
339    Ok(())
340}
Source

pub fn with_wandb(self, project: impl Into<String>) -> Self

Add a Weights & Biases integration.

Examples found in repository?
examples/fine_tuning.rs (line 312)
89async fn main() -> Result<(), Box<dyn std::error::Error>> {
90    println!("πŸš€ OpenAI Ergonomic - Comprehensive Fine-tuning Example\n");
91
92    // Initialize client from environment variables
93    println!("πŸ“ Initializing OpenAI client...");
94    let client = match Client::from_env() {
95        Ok(c) => {
96            println!("βœ… Client initialized successfully\n");
97            c.build()
98        }
99        Err(e) => {
100            eprintln!("❌ Failed to initialize client: {}", e);
101            eprintln!("πŸ’‘ Make sure OPENAI_API_KEY is set");
102            return Ok(());
103        }
104    };
105
106    // Example 1: Create a fine-tuning job
107    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
108    println!("πŸ“Œ Example 1: Create Fine-tuning Job");
109    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
110
111    // Note: You need to upload a training file first
112    // For demonstration purposes, we'll use a placeholder file ID
113    let training_file_id = "file-training-data";
114
115    println!("Creating fine-tuning job...");
116    println!("  Base Model: gpt-3.5-turbo");
117    println!("  Training File: {}", training_file_id);
118    println!("  Suffix: my-custom-model");
119
120    let builder = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
121        .suffix("my-custom-model")
122        .epochs(3);
123
124    println!("\nπŸ’‘ Note: This would create a real fine-tuning job with your API key.");
125    println!("   Commented out to avoid accidental charges.\n");
126
127    // Uncomment to actually create the job:
128    // match client.fine_tuning().create_job(builder).await {
129    //     Ok(job) => {
130    //         println!("βœ… Fine-tuning job created successfully!");
131    //         println!("  Job ID: {}", job.id);
132    //         println!("  Status: {}", job.status);
133    //         println!("  Model: {}", job.model);
134    //     }
135    //     Err(e) => {
136    //         eprintln!("❌ Failed to create fine-tuning job: {}", e);
137    //     }
138    // }
139
140    // Simulate job creation for demonstration
141    let demo_job = JobInfo::new(
142        "ftjob-demo123",
143        "gpt-3.5-turbo",
144        "validating",
145        training_file_id,
146    );
147    println!("πŸ“Š Demo Job Created:");
148    demo_job.display();
149
150    // Example 2: List fine-tuning jobs
151    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
152    println!("πŸ“Œ Example 2: List Fine-tuning Jobs");
153    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
154
155    println!("Listing fine-tuning jobs (limit: 5)...\n");
156
157    // Uncomment to actually list jobs:
158    // match client.fine_tuning().list_jobs(None, Some(5)).await {
159    //     Ok(response) => {
160    //         println!("βœ… Found {} fine-tuning jobs", response.data.len());
161    //         for (i, job) in response.data.iter().enumerate() {
162    //             println!("\nπŸ“ Job {}:", i + 1);
163    //             println!("  ID: {}", job.id);
164    //             println!("  Model: {}", job.model);
165    //             println!("  Status: {}", job.status);
166    //             println!("  Created At: {}", job.created_at);
167    //         }
168    //     }
169    //     Err(e) => {
170    //         eprintln!("❌ Failed to list fine-tuning jobs: {}", e);
171    //     }
172    // }
173
174    println!("πŸ’‘ Demo: Would list your fine-tuning jobs here");
175
176    // Example 3: Get specific fine-tuning job
177    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
178    println!("πŸ“Œ Example 3: Get Fine-tuning Job Details");
179    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
180
181    let job_id = "ftjob-demo123";
182    println!("Retrieving job: {}\n", job_id);
183
184    // Uncomment to actually get job:
185    // match client.fine_tuning().get_job(job_id).await {
186    //     Ok(job) => {
187    //         println!("βœ… Job retrieved successfully!");
188    //         println!("  ID: {}", job.id);
189    //         println!("  Model: {}", job.model);
190    //         println!("  Status: {}", job.status);
191    //         println!("  Created At: {}", job.created_at);
192    //         if let Some(finished_at) = job.finished_at {
193    //             println!("  Finished At: {}", finished_at);
194    //         }
195    //     }
196    //     Err(e) => {
197    //         eprintln!("❌ Failed to get fine-tuning job: {}", e);
198    //     }
199    // }
200
201    println!("πŸ’‘ Demo: Would show detailed job information");
202
203    // Example 4: List job events
204    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
205    println!("πŸ“Œ Example 4: List Fine-tuning Job Events");
206    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
207
208    println!("Listing events for job: {}\n", job_id);
209
210    // Uncomment to actually list events:
211    // match client.fine_tuning().list_events(job_id, None, Some(10)).await {
212    //     Ok(response) => {
213    //         println!("βœ… Found {} events", response.data.len());
214    //         for (i, event) in response.data.iter().enumerate() {
215    //             println!("\nπŸ“‹ Event {}:", i + 1);
216    //             println!("  Message: {}", event.message);
217    //             println!("  Created At: {}", event.created_at);
218    //             if let Some(level) = &event.level {
219    //                 println!("  Level: {}", level);
220    //             }
221    //         }
222    //     }
223    //     Err(e) => {
224    //         eprintln!("❌ Failed to list events: {}", e);
225    //     }
226    // }
227
228    println!("πŸ’‘ Demo: Would show training events like:");
229    println!("  - Job started");
230    println!("  - Training step 1/100 complete");
231    println!("  - Validation loss: 0.452");
232    println!("  - Training complete");
233
234    // Example 5: List job checkpoints
235    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
236    println!("πŸ“Œ Example 5: List Fine-tuning Job Checkpoints");
237    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
238
239    println!("Listing checkpoints for job: {}\n", job_id);
240
241    // Uncomment to actually list checkpoints:
242    // match client.fine_tuning().list_checkpoints(job_id, None, Some(5)).await {
243    //     Ok(response) => {
244    //         println!("βœ… Found {} checkpoints", response.data.len());
245    //         for (i, checkpoint) in response.data.iter().enumerate() {
246    //             println!("\nπŸ’Ύ Checkpoint {}:", i + 1);
247    //             println!("  ID: {}", checkpoint.id);
248    //             println!("  Created At: {}", checkpoint.created_at);
249    //             println!("  Step Number: {}", checkpoint.step_number);
250    //         }
251    //     }
252    //     Err(e) => {
253    //         eprintln!("❌ Failed to list checkpoints: {}", e);
254    //     }
255    // }
256
257    println!("πŸ’‘ Demo: Would show model checkpoints from training");
258
259    // Example 6: Cancel fine-tuning job
260    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
261    println!("πŸ“Œ Example 6: Cancel Fine-tuning Job");
262    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
263
264    println!("Cancelling job: {}\n", job_id);
265
266    // Uncomment to actually cancel job:
267    // match client.fine_tuning().cancel_job(job_id).await {
268    //     Ok(job) => {
269    //         println!("βœ… Job cancelled successfully!");
270    //         println!("  Job ID: {}", job.id);
271    //         println!("  Status: {}", job.status);
272    //     }
273    //     Err(e) => {
274    //         eprintln!("❌ Failed to cancel job: {}", e);
275    //     }
276    // }
277
278    println!("πŸ’‘ Demo: Would cancel the running fine-tuning job");
279
280    // Example 7: Create job with validation file
281    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
282    println!("πŸ“Œ Example 7: Create Job with Validation File");
283    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
284
285    let validation_file_id = "file-validation-data";
286
287    println!("Creating fine-tuning job with validation...");
288    println!("  Base Model: gpt-3.5-turbo");
289    println!("  Training File: {}", training_file_id);
290    println!("  Validation File: {}", validation_file_id);
291    println!("  Epochs: 5");
292    println!("  Learning Rate Multiplier: 0.1");
293
294    let builder_with_validation = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
295        .validation_file(validation_file_id)
296        .epochs(5)
297        .learning_rate_multiplier(0.1);
298
299    println!("\nπŸ’‘ Note: Validation files help monitor overfitting during training");
300
301    // Example 8: Create job with Weights & Biases integration
302    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
303    println!("πŸ“Œ Example 8: Create Job with W&B Integration");
304    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
305
306    println!("Creating fine-tuning job with W&B...");
307    println!("  Base Model: gpt-3.5-turbo");
308    println!("  Training File: {}", training_file_id);
309    println!("  W&B Project: my-finetuning-project");
310
311    let builder_with_wandb = FineTuningJobBuilder::new("gpt-3.5-turbo", training_file_id)
312        .with_wandb("my-finetuning-project");
313
314    println!("\nπŸ’‘ Note: W&B integration provides detailed training metrics visualization");
315
316    // Summary
317    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
318    println!("πŸ“Š Summary");
319    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
320
321    println!("βœ… Fine-tuning API examples completed!");
322    println!("\nπŸ“š Key Takeaways:");
323    println!("  β€’ Fine-tuning allows customizing models for specific tasks");
324    println!("  β€’ Jobs can be created with various hyperparameters");
325    println!("  β€’ Progress can be monitored through events and checkpoints");
326    println!("  β€’ Validation files help prevent overfitting");
327    println!("  β€’ Integrations like W&B provide detailed metrics");
328    println!("  β€’ Jobs can be cancelled if needed");
329
330    println!("\nπŸ’‘ Next Steps:");
331    println!("  1. Prepare your training data in JSONL format");
332    println!("  2. Upload training data using the Files API");
333    println!("  3. Create a fine-tuning job with appropriate parameters");
334    println!("  4. Monitor progress through events");
335    println!("  5. Use the fine-tuned model in your applications");
336
337    println!("\nπŸŽ‰ Example completed successfully!");
338
339    Ok(())
340}
Source

pub fn model(&self) -> &str

Get the base model for this fine-tuning job.

Source

pub fn training_file(&self) -> &str

Get the training file ID.

Source

pub fn validation_file_ref(&self) -> Option<&str>

Get the validation file ID.

Source

pub fn hyperparameters(&self) -> &FineTuningHyperparameters

Get the hyperparameters.

Source

pub fn suffix_ref(&self) -> Option<&str>

Get the model suffix.

Source

pub fn integrations(&self) -> &[FineTuningIntegration]

Get the integrations.

Trait ImplementationsΒ§

SourceΒ§

impl Clone for FineTuningJobBuilder

SourceΒ§

fn clone(&self) -> FineTuningJobBuilder

Returns a duplicate of the value. Read more
1.0.0 Β· SourceΒ§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
SourceΒ§

impl Debug for FineTuningJobBuilder

SourceΒ§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait ImplementationsΒ§

Blanket ImplementationsΒ§

SourceΒ§

impl<T> Any for T
where T: 'static + ?Sized,

SourceΒ§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
SourceΒ§

impl<T> Borrow<T> for T
where T: ?Sized,

SourceΒ§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
SourceΒ§

impl<T> BorrowMut<T> for T
where T: ?Sized,

SourceΒ§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
SourceΒ§

impl<T> CloneToUninit for T
where T: Clone,

SourceΒ§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

πŸ”¬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
SourceΒ§

impl<T> From<T> for T

SourceΒ§

fn from(t: T) -> T

Returns the argument unchanged.

SourceΒ§

impl<T> FutureExt for T

SourceΒ§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
SourceΒ§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
SourceΒ§

impl<T> Instrument for T

SourceΒ§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
SourceΒ§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
SourceΒ§

impl<T, U> Into<U> for T
where U: From<T>,

SourceΒ§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

SourceΒ§

impl<T> PolicyExt for T
where T: ?Sized,

SourceΒ§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
SourceΒ§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
SourceΒ§

impl<T> ToOwned for T
where T: Clone,

SourceΒ§

type Owned = T

The resulting type after obtaining ownership.
SourceΒ§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
SourceΒ§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
SourceΒ§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

SourceΒ§

type Error = Infallible

The type returned in the event of a conversion error.
SourceΒ§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
SourceΒ§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

SourceΒ§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
SourceΒ§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
SourceΒ§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

SourceΒ§

fn vzip(self) -> V

SourceΒ§

impl<T> WithSubscriber for T

SourceΒ§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
SourceΒ§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
SourceΒ§

impl<T> ErasedDestructor for T
where T: 'static,