Skip to content

use tool calls for json_object compatability with chat completions#174

Merged
Ken Jiang (knjiang) merged 1 commit intomainfrom
04-01-use_tool_calls_for_json_object_compatability_with_chat_completions
Apr 2, 2026
Merged

use tool calls for json_object compatability with chat completions#174
Ken Jiang (knjiang) merged 1 commit intomainfrom
04-01-use_tool_calls_for_json_object_compatability_with_chat_completions

Conversation

@knjiang
Copy link
Copy Markdown
Contributor

@knjiang Ken Jiang (knjiang) commented Apr 2, 2026

This takes a similar approach to what we do in the proxy -> https://github.com/braintrustdata/braintrust-proxy/blob/main/packages/proxy/src/proxy.ts#L2791

i made the change and then ran make regenerate-failed-transforms which resulted in all the updated JSON files.

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@knjiang Ken Jiang (knjiang) force-pushed the 04-01-use_tool_calls_for_json_object_compatability_with_chat_completions branch from d3b5472 to 75c2619 Compare April 2, 2026 15:13
@knjiang Ken Jiang (knjiang) marked this pull request as ready for review April 2, 2026 15:58
@knjiang Ken Jiang (knjiang) force-pushed the 04-01-use_tool_calls_for_json_object_compatability_with_chat_completions branch from 75c2619 to 95b7883 Compare April 2, 2026 17:26
Comment on lines -1285 to -1292
ResponseFormatType::JsonObject => Ok(JsonOutputFormat {
schema: serde_json::from_value(json!({
"type": "object",
"additionalProperties": false
}))
.expect("static JSON object is always a valid Map"),
json_output_format_type: JsonOutputFormatType::JsonSchema,
}),
Copy link
Copy Markdown
Contributor Author

@knjiang Ken Jiang (knjiang) Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in practice:

JsonOutputFormat {
                schema: serde_json::from_value(json!({
                    "type": "object",
                    "additionalProperties": false
                }))
                .expect("static JSON object is always a valid Map"),
                json_output_format_type: JsonOutputFormatType::JsonSchema,
            }),

always emits an empty dictionary of {}, i thought we could set it like the above but no it doesn't work :(

see the transforms JSON showing we now produce abritrary json

@knjiang Ken Jiang (knjiang) merged commit 3c22562 into main Apr 2, 2026
9 checks passed
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

Successfully merging this pull request may close these issues.

2 participants