Closed lobirus closed 1 month ago
@lobirus https://github.com/dongri/openai-api-rs/pull/101/files Added response_format parameter
let mut run_req = CreateRunRequest::new(result.id);
run_req = run_req.clone().response_format(json!({"type": "json_objects"}));
Please check if it works correctly.
Hi @dongri, Good job, thanks. It works well for me. FYI The 5.0.4 crate is not available via cargo yet, using with GitHub repo reference for now.
If someone finds this one, the type is json_object
. Singular, correct in the source code, typo above.
@lobirus sorry... I forgot to publish cargo. I published it now. https://crates.io/crates/openai-api-rs
Thanks. Tested the 5.0.4 package too, works well.
Describe the feature or improvement you're requesting
https://platform.openai.com/docs/api-reference/runs/createRun#runs-createrun-response_format
Runs support response format, mostly to always response with a valid JSON.
Additional context
I'm not sure about the proper solution. It might be another HashMap property of CreateRunRequest but maybe you can figura a better solution. E.g. creating a specific struct, or type constants (or just a json_mode bool). They kept it as a simple object with a string value in the Node.js and Python implementations too. https://platform.openai.com/docs/guides/json-mode
Went through the code, a few branches, examples, haven't noticed its existence, sorry if it already exists.