Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.1.6.3 BatchJob.create_from_messages produces jsonl with wrong structure #1119

Open
andreskull opened this issue Oct 25, 2024 · 2 comments
Open

Comments

@andreskull
Copy link

The function produces json lines with wrong structure. Missing method and url keys.
This results 'missing required 'method'* error when posted to openai.
v.1.6.2 works fine

@DGoettlich
Copy link

same issue here (accidentally opened another issue in parallel):

I am creating a batch for gpt-3.5-turbo:

chunks = pd.read_csv(input_path)

def create_batch(chunks):
for index, row in chunks.iterrows():
chunk_text = row["chunk_text"]
yield [
{
"role": "system",
"content": system_prompt,
},
{
"role": "user",
"content": prompt.format(chunk=chunk_text, examples=examples),
},
]

batch_job = BatchJob.create_from_messages(
messages_batch=messages,
model=model,
temperature=temp,
file_path=output_path,
response_model=ClassModel
)

but when i want to upload it using

$instructor batch create-from-file --file-path /my/path/example_batchname.jsonl

I'm getting the processing status "failed". Checking the OpenAI message revealed its missing the method, url, and body in the jsonl. In other words, the format isn't what OpenAI expects.

the json format is:

{"custom_id":"b43f1dca-dac0-4ece-b6cf-3aae7b433ac4","params":{"model":"gpt-3.5-turbo","messages":[...],"max_tokens":1000,"temperature":0.0,"tools":[{"type":"function","function":{"name":"ClassModel","description":"Correctly extracted ClassModel with all the required parameters with correct types","parameters":{"properties":{"relevant":{"title":"Relevant","type":"integer"},"confidence":{"title":"Confidence","type":"integer"},"relevant_section":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Relevant Section"},"justification":{"title":"Justification","type":"string"}},"required":["confidence","justification","relevant","relevant_section"],"type":"object"}}}],"tool_choice":{"type":"function","function":{"name":"ClassModel"}}}}

Any idea what I'm doing wrong? Help would be appreciated. Thanks in advance.

@RubenHf
Copy link

RubenHf commented Nov 2, 2024

By replacing

"params":

TO

"method": "POST", "url": "/v1/chat/completions", "body":

fixed the issue for me.

batch create-from-file seems to not create the proper file structure for openai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants