Spaces:
Sleeping
Sleeping
Calling OpenAI Batch steps
Guide to OpenAI batch api --> https://platform.openai.com/docs/guides/batch
Step 1: Prepare Batch File (prepare_batch.py)
- Prepare a .jsonl file containing your batch requests. Each line represents a single API request.
- Usage: Run the script to process all files in the specified directory and generate the batch file.
Step 2: Upload Batch File (upload_batch_file.py)
- Upload the prepared batch file to OpenAI using the Files API.
- The script uploads batch_input.jsonl and returns the file ID.
Step 3: Create Batch (create_batch.py)
- Create a batch job using the uploaded file's ID. Add the file ID obtained from running upload_batch_file.py to create_batch.py.
- Returns a batch ID.
Step 4: Check Batch Status (check_batch_status.py)
- Use the batch iD from create_batch.py to check the status of the batch job to monitor progress.
Possible statuses:
- validating: Validating the input file.
- in_progress: Batch is running.
- completed: Batch is finished and results are ready.
- failed: Validation failed.
- expired: Batch did not complete within the window.
- Retrieves the output_file_ID if completed.
Step 5: Retrieve Results (retrieve_results.py)
- Download the results using the output_file_id retrieved from the batch status.
Helper scripts
Cancel Batch (cancel_batch.py)
- Cancel an ongoing batch if required. Changes batch status to cancelling and eventually cancelled.
List Batches (list_batches.py)
- View all batches created, including their status and metadata.
Consolidated script that combines all the functionalities (Except helpers)
- batch_processing.py