Hello,
The following code from the documentation and the cookbook gives me the error :
TypeError: ‘Collection’ object is not callable. If you meant to call the ‘create’ method on a ‘Database’ object it is failing because no such method exists.
Did I miss something obvious or is it an API problem ?
from openai import OpenAI
client = OpenAI(api_key='XXXXXXXXX', )
data = [
{"custom_id": "request-1",
"method": "POST",
"url": "/v1/chat/completions",
"body": {"model": "gpt-3.5-turbo-0125",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello world!"
}
],
"max_tokens": 1000
}},
{"custom_id": "request-2", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo-0125", "messages": [{"role": "system", "content": "You are an unhelpful assistant."},{"role": "user", "content": "Hello world!"}],"max_tokens": 1000}}
]
file_name = "new_file.jsonl"
with open(file_name, 'w') as file:
for obj in data:
file.write(json.dumps(obj) + '\n')
batch_input_file = client.files.create(
file=open(file_name, "rb"),
purpose="batch"
)
PS : trying to figure out how to post formatted code…
Hi,
Thank you for your answer, it’s strange because when I run exactly your code, I still have the same error… I will retry in an hour with another computer.
Hi,
I did the update just in case.
It seems there is some randomness in this : I was able to run the code @jr.2509 posted and then my code after (with a more complex dataset). And a few hours laters, I had the same error with the code from @jr.2509 …
So it seems the problem is “solved”