You are on page 1of 2

import openai

# Define a function to open a file and return its contents as a string

def open_file(filepath):

with open(filepath, 'r', encoding='utf-8') as infile:

return infile.read()

# Define a function to save content to a file

def save_file(filepath, content):

with open(filepath, 'a', encoding='utf-8') as outfile:

outfile.write(content)

# Set the OpenAI API keys by reading them from files

api_key = open_file('openaiapikey.txt')

openai.api_key = api_key

# Using the provided file_id

file_id = "0x0000000000000000006200000000ea9c"

model_name = "gpt-3.5-turbo" # Or another base model if you prefer

# Assuming the file name is 'processed_data.jsonl'

with open("C:\Users\DELL\Downloads\trainingdata\convertjson.jsonl", "rb") as file:

response = openai.File.create(

file=file,

purpose='fine-tune'
)

file_id = response['id']

print(f"File uploaded successfully with ID: {file_id}")

You might also like