Spaces:
Sleeping
Sleeping
File size: 667 Bytes
97208ad |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from openai import OpenAI
import os
from dotenv import load_dotenv
load_dotenv()
def retrieve_results(output_file_id, output_path):
client = OpenAI(
api_key=os.getenv("OPENAI_API_KEY"),
organization=os.getenv("OPENAI_ORG_ID")
)
file_response = client.files.content(output_file_id)
# Write the binary content to the output file
with open(output_path, "wb") as out_file:
out_file.write(file_response.read())
print(f"Batch results downloaded to {output_path}")
if __name__ == "__main__":
output_file_id = "" # Replace with your actual output file ID
retrieve_results(output_file_id, "batch_output.jsonl")
|