-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Describe the bug
Title: Error when uploading JSONL file for training
Description: I am trying to upload a JSONL file for training on OpenAI, but I'm encountering an error. The error message says "Expected file to have JSONL format, where every line is a JSON dictionary. Line 1 is not a dictionary (HINT: line starts with: "{...")."
I created the JSONL file by converting a CSV file to JSONL using Python's csv and json libraries. I followed the instructions on OpenAI's documentation for formatting the file: each line is a JSON dictionary with the keys "prompt" and "completion".
Here is an example of the first two lines of the file:
{"prompt": "date: 3/11/2015, open: 1.070939064, high: 1.071455359, low: 1.056140184, close: 1.070870161, adj close: 1.070870161, sma: 1.121346676, ema: 1.114991641, rsi: 19.71425449, %K: 17.71232347, %D: 12.06409742, sma_50: 1.143293602, ema_20: 1.114991641, stoch_k: 17.71232347, stoch_d: 12.06409742", "completion": "Price Decreased"}
{"prompt": "date: 3/12/2015, open: 1.054941297, high: 1.068150163, low: 1.050155401, close: 1.054874539, adj close: 1.054874539, sma: 1.117530596, ema: 1.109266202, rsi: 16.57194042, %K: 5.293653385, %D: 13.38069099, sma_50: 1.140193837, ema_20: 1.109266202, stoch_k: 5.293653385, stoch_d: 13.38069099", "completion": "Price Decreased"}
To Reproduce
Run the code below and try to upload to fine tune.
Traceback (most recent call last):
File "ChatGPTPlaygrounf\train_py.py", line 155, in
upload_training_data(training_data)
File "ChatGPTPlaygrounf\train_py.py", line 132, in upload_training_data
response = openai.File.create(
File "chatgpt\lib\site-packages\openai\api_resources\file.py", line 59, in create
response, _, api_key = requestor.request("post", url, files=files)
File "chatgpt\lib\site-packages\openai\api_requestor.py", line 181, in request
resp, got_stream = self._interpret_response(result, stream)
File "chatgpt\lib\site-packages\openai\api_requestor.py", line 396, in _interpret_response
self._interpret_response_line(
File "chatgpt\lib\site-packages\openai\api_requestor.py", line 429, in _interpret_response_line
raise self.handle_error_response(
openai.error.InvalidRequestError: Expected file to have JSONL format, where every line is a JSON dictionary. Line 1 is not a dictionary (HINT: line starts with: "[{"p...").
Code snippets
`def create_json():
csv_file = "csv/eurusd_historical_data_with_indicators.csv"
jsonl_file = 'data.jsonl'
with open(csv_file, 'r') as f_csv, open(jsonl_file, 'w') as f_jsonl:
reader = csv.DictReader(f_csv, delimiter=',')
for row in reader:
prompt = {
"prompt": f"date: {row['date']}, open: {row['open']}, high: {row['high']}, low: {row['low']}, close: {row['close']}, adj close: {row['adj close']}, sma: {row['sma']}, ema: {row['ema']}, rsi: {row['rsi']}, %K: {row['%K']}, %D: {row['%D']}, sma_50: {row['sma_50']}, ema_20: {row['ema_20']}, stoch_k: {row['stoch_k']}, stoch_d: {row['stoch_d']}"
}
completion = {"completion": row['price movement']}
data = {**prompt, **completion}
f_jsonl.write(json.dumps(data) + '\n')
`OS
Windows 11
Python version
v3.9
Library version
v0.27