| 57 | return response |
| 58 | |
| 59 | def download_file(self, batch_id): |
| 60 | response = self.client.batches.retrieve(batch_id) |
| 61 | if response.status != "completed": |
| 62 | raise ValueError("The batch is not completed and its status is {}.".format(response.status)) |
| 63 | output_file = response.output_file_id |
| 64 | content = self.client.files.content(output_file) |
| 65 | contents = content.content.splitlines() |
| 66 | outputs = [] |
| 67 | for line in contents: |
| 68 | outputs.append(json.loads(line)) |
| 69 | return outputs |
| 70 | |
| 71 | def collect_errors(self, batch_id): |
| 72 | response = self.client.batches.retrieve(batch_id) |